Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: high
Invalid

Missing check for vaults balances

## Summary
Missing check for vaults balances in `CreditDelegationBranch::rebalanceVaultsAssets`
## Vulnerability Details
`CreditDelegationBranch::rebalanceVaultsAssets` rebalances credit and debt between two vaults by swapping the asset of a
vault in credit to USDC in order to pay the debt in the second vault. However, this function does not check if the vault in
credit has enough assets to cover debt of vault in debt before creating the struct instance to be used for the swap
operation.
For example: At the rate of 1 unit of asset to $1, If $150 is needed to cover for debt of vault in debt then 150 units of
vault assets in credit is needed and the vault in credit only has 100 units of assets.
## Impact
Unexpected behaviour during the swap operation.
## Recommendations
Enforce a check to see if the vault in credit has more assets to be used for the swap operation.
```diff
+ error NotEnoughAssets();
.
.
+ if(ctx.inDebtVaultCollateralAsset.totalAssets() < assetInputNative) {
+ revert NotEnoughAssets();
+ }
```
Updates

Lead Judging Commences

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.