Inconsistent accounting of undeployedAssets might result in undesired optimal range in the pool #44
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
M-09
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/pools/Pool.sol#L398
https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/pools/Pool.sol#L564-L565
https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/pools/Pool.sol#L572
Vulnerability details
Impact
Inconsistent accounting of undeployedAssets might result in undesired optimal range in the pool
Proof of Concept
undeployedAssets is calculated inconsistently. Currently in
_getUndeployedAssets()
the protocol collected fees are subtracted, however, invalidateOffer
, the protocol collected fees are not subtracted.(1)
_getUndeployedAssets()
:This is called indeployWithdrawalQueue()
to calculate proRata liquid assets to the queue.contractAddress.(2)
uint256 undeployedAssets
: this is manually calculated invalidateOffer
flow, which is used check whether the pool has enough undeployed Assets to cover loan.principalAmount.(https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/pools/Pool.sol#L398)
Note that in (2), undeployedAssets are inflated because
getCollectedFees
are fees protocol collected from liquidation/repayment flows and shouldn't be considered as liquid assets to cover the loan principal amount.(3)
_reallocate()
: This also manually calculate total undeployedassets amount, but again didn't account forgetCollectedFees
._reaalocate()
balances optimal target idle assets ratio by checkingcurrentBalance
/total
ratio. HerecurrentBalance
should be additionally subtracted bygetCollectedFees
because fees are set aside and shouldn't be considered idle. This affects optimal range check.(https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/pools/Pool.sol#L572)
Inconsistent accounting in various flows may result in incorrect checks or undesirable optimal ranges.
Tools Used
Manual
Recommended Mitigation Steps
Account for
getCollectedFees
in (2)&(3).Assessed type
Other
The text was updated successfully, but these errors were encountered: