You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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_vault to amount x.
Set vault stake to amount y. Where y < x.
Send an acceptReplace request to vault
Try to cancelReplace should pass out an error InsufficientVaultCollateralAmount
In cancelReplace if collateral amount is 0 then don't call force_withdraw_collateral hence making the is_allowed_to_withdraw_collateral redundant 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_collateral is used and can lead to corner cases.
The text was updated successfully, but these errors were encountered:
The corner case may arise for different method that use the helper function is_allowed_to_withdraw_collateral because of the following check.
Example: vault trying to withdraw_collateral amount but after withdraw the collateral will be less than MinimumCollateralVault hence the call will emit out InsufficientVaultCollateralAmount error.
nakul1010
changed the title
Allow acceptReplace only if vault is above minimum collateral
InsufficientVaultCollateralAmount error when trying to withdraw an amount takes the vault below MinimumCollateral
Jan 5, 2024
Describe the bug
The issue with
is_allowed_to_withdraw_collateral
helper method is, that it passes out an errorInsufficientVaultCollateralAmount
when trying to withdraw an amount that falls belowMinimumCollateral
but in some cases it is not idealCorner 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 tocancelReplace
since, the extrinsic will only allow to cancel if vault is aboveminimum_collateral_vault
threshold.Steps to reproduce the behavior:
Set
minimum_collateral_vault
to amount x.Set vault stake to amount y. Where y < x.
Send an
acceptReplace
request to vaultTry to
cancelReplace
should pass out an errorInsufficientVaultCollateralAmount
In
cancelReplace
ifcollateral
amount is0
then don't callforce_withdraw_collateral
hence making theis_allowed_to_withdraw_collateral
redundant 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 thanMinimumCollateralVault
hence the call will emit outInsufficientVaultCollateralAmount
error. In such cases, the withdraw shouldn't fail.ToDos
is_allowed_to_withdraw_collateral
is used and can lead to corner cases.The text was updated successfully, but these errors were encountered: