The weight assigned to a single market is considered relative to the total weight of the vault across all its connected markets. In each market has a specific weight that represents its share of the vault's total credit capacity. This individual market weight must then be aggregated into the vault's overall weight, ensuring that the vault's total credit distribution across all connected markets is accurately reflected.
The function recalculateVaultsCreditCapacity is used to calculate the connected markets credit weight to vault in this function updateVaultAndCreditDelegationWeight called first to update the credit weight of each market and total credit weight of the vault see below code snippet
We can see in above snippet that weight will be same for every markets but total weight also same . If two market weight will be same as total weight update in storage state.
In end of the recalculateVaultsCreditCapacity function _updateCreditDelegations will called to calculate and update the credit delegation see below code snippet
In above code snippet we can see two vairables totalCreditDelegationWeightCache and creditDelegation.weight which will same which just assinged in function updateVaultAndCreditDelegationWeight so division will be always 1.
Simulated Flaw Calculation
Market ID | Assigned Weight | Incorrect Total Weight | Incorrect Proportion |
---|---|---|---|
Market 1 | 50 | 50 | 50 / 50 = 100% |
Market 2 | 50 | 50 | 50 / 50 = 100% |
Market 3 | 50 | 50 | 50 / 50 = 100% |
Simulated Correct calculation
Market ID | Assigned Weight | Expected Proportion |
---|---|---|
Market 1 | 50 | 50 / 150 = 33.3% |
Market 2 | 50 | 50 / 150 = 33.3% |
Market 3 | 50 | 50 / 150 = 33.3% |
Every connected market receives the same weight (newWeight
).
The totalCreditDelegationWeight
is also set to newWeight
, meaning that if multiple markets exist, their combined weight should be summed up but isn't.
Manual View
Add Assetion or revert
Change Code in updateVaultAndCreditDelegationWeight function
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.