A critical accounting discrepancy exists in CreditDelegationBranch.sol
where the rebalanceVaultsAssets()
function uses estimated USDC amounts instead of actual received amounts when updating vault states after swaps. This leads to inaccurate protocol accounting and potential misalignment between internal state and real USDC balances.
The issue stems from using pre-swap price estimations rather than actual swap output values when calculating usdDelta
. Over time, this discrepancy could accumulate and cause significant protocol state inconsistencies, impacting vault accounting accuracy.
Credit DelegationBranch.sol:L646~666
BaseAdapter.sol:L95~123
In the CreditDelegationBranch.sol#rebalanceVaultsAssets()
function, there is a critical issue with how the usdDelta
variable is calculated after performing an asset swap.
The function performs the following key operations:
Calculates assetInputNative
through getExpectedOutput()
(L646)
Executes swap using executeSwapExactInputSingle()
(L663)
Sets usdDelta
directly from depositAmountUsdX18
The core issue lies in the fact that while the swap is executed in "exact input" mode, the function ignores the actual USDC amount received from the swap and instead uses the pre-swap estimation for updating the vault states.
This discrepancy leads to:
Incorrect depositedUsdc
values in both vaults
Inaccurate marketsRealizedDebtUsd
state
Misalignment between the protocol's internal accounting and actual USDC balances
The severity is high because this accounting mismatch could accumulate over time and lead to significant protocol state inconsistencies.
The getExpectedOutput()
function in BaseAdapter.sol calculates expected outputs based on price feeds:
However, due to factors like slippage and price impact, the actual received USDC amount will differ from this estimation.
Two potential solutions:
Use actual swap output to update vault states:
In rebalanceVaultsAssets()
function....
Modify the swap execution to use exact output mode instead, ensuring the received USDC matches the expected amount.
The first solution is recommended as it provides better accuracy and transparency in vault accounting.
he rebalanceVaultsAssets function in CreditDelegationBranch.sol updates vault accounting using the pre-swap USD value (usdDelta) rather than the actual post-swap USDC amount received. This means slippage is not accounted for, causing accounting misalignment - if there's negative slippage, the credit vault gets credited more USDC than actually received; if there's positive slippage, it gets credited less.
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.