Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Shrenuj Bansal <[email protected]>
  • Loading branch information
shrenujb committed Mar 4, 2024
1 parent 8cdea7c commit e10accd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion protocol/x/clob/keeper/deleveraging.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func (k Keeper) MaybeDeleverageSubaccount(
return quantumsDeleveraged, err
}

// GetInsuranceFundBalance returns the current balance of the insurance fund (in quote quantums).
// GetInsuranceFundBalance returns the current balance of the specific insurance fund based on the
// perpetual (in quote quantums).
// This calls the Bank Keeper’s GetBalance() function for the Module Address of the insurance fund.
func (k Keeper) GetInsuranceFundBalance(ctx sdk.Context, perpetualId uint32) (balance *big.Int) {
usdcAsset, exists := k.assetsKeeper.GetAsset(ctx, assettypes.AssetUsdc.Id)
Expand Down
9 changes: 9 additions & 0 deletions protocol/x/subaccounts/keeper/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,15 @@ func TestTransferInsuranceFundPayments(t *testing.T) {
expectedInsuranceFundBalance: 300,
expectedErr: sdkerrors.ErrInsufficientFunds,
},
"failure - isolated market insurance fund does not have sufficient funds": {
perpetual: constants.IsoUsd_IsolatedMarket,
insuranceFundBalance: 300,
subaccountModuleAccBalance: 2500,
quantums: big.NewInt(-500),
expectedSubaccountsModuleAccBalance: 2500,
expectedInsuranceFundBalance: 300,
expectedErr: sdkerrors.ErrInsufficientFunds,
},
"panics - asset doesn't exist": {
perpetual: constants.BtcUsd_SmallMarginRequirement,
insuranceFundBalance: 1500,
Expand Down

0 comments on commit e10accd

Please sign in to comment.