-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Describe the bug
The issue with is_allowed_to_withdraw_collateral helper method is, that it passes out an error InsufficientVaultCollateralAmount when trying to withdraw an amount that falls below MinimumCollateral but in some cases it is not ideal
Corner case 1:
When a vault accepts a replace, it doesn't seem to check whether the vault's is below the minimum_collateral_vault threshold.This will cause issues when the vault tries to cancelReplace since, the extrinsic will only allow to cancel if vault is above minimum_collateral_vault threshold.
Steps to reproduce the behavior:
-
Set
minimum_collateral_vaultto amount x. -
Set vault stake to amount y. Where y < x.
-
Send an
acceptReplacerequest to vault -
Try to
cancelReplaceshould pass out an errorInsufficientVaultCollateralAmount -
In
cancelReplaceifcollateralamount is0then don't callforce_withdraw_collateralhence making theis_allowed_to_withdraw_collateralredundant which is causing the issue. -
Only do the collateral calculation if the amount is greater than
0
Corner case 2:
There can be a scenario where the vault is trying to exit and has no issue token to back. The vault is trying to withdraw_collateral amount but after withdrawing the collateral will be less than MinimumCollateralVault hence the call will emit out InsufficientVaultCollateralAmount error. In such cases, the withdraw shouldn't fail.
ToDos
- Find other methods where
is_allowed_to_withdraw_collateralis used and can lead to corner cases.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status