After the first call of VaultRouterBranch.sol:redeem() value of newCreditDelegationUsdX18 is less than previousCreditDelegationUsdX18 in Vault.sol:_updateCreditDelegations(), this causes revert due to underflow in functions where Vault.sol:recalculateVaultsCreditCapacity() is called.
VaultRouterBranch.sol:redeem() function calls Vault.sol:recalculateVaultsCreditCapacity() to recalculate vault credit capacity that includes function to update credit delegation - Vault.sol:_updateCreditDelegations():
This function will revert after first redeem, because newCreditDelegationUsdX18 will now always be less than previousCreditDelegationUsdX18:
(Optional) Change src/market-making/leaves/Vault.sol:_updateCreditDelegations(): to emit new events to check values of newCreditDelegationUsdX18 and previousCreditDelegationUsdX18:
Add this test to test/integration/market-making/vault-router-branch/redeem/redeem.t.sol:
Run this test with command:
Output:
As you can see in NewCreditDelegation and PreviousCreditDelegation events newCreditDelegationUsdX18 is less than previousCreditDelegationUsdX18, causing revert.
Functions where Vault.sol:recalculateVaultsCreditCapacity()is called will revert after first redeem, this includes functions like VaultRouterBranch.sol:deposit() and VaultRouterBranch.sol:redeem() too.
Manual Review
creditDeltaUsdX18 calculation should consider that newCreditDelegationUsdX18 may be less than previousCreditDelegationUsdX18.
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.