diff --git a/x/margin/client/cli/query_mtp_test.go b/x/margin/client/cli/query_mtp_test.go index 0a5d50e93..db2d4c786 100644 --- a/x/margin/client/cli/query_mtp_test.go +++ b/x/margin/client/cli/query_mtp_test.go @@ -37,12 +37,12 @@ func networkWithMTPObjects(t *testing.T, n int) (*network.Network, []*types.MTP) for i := 0; i < n; i++ { mtp := types.MTP{ Address: addr[i].String(), - Collaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))), + Collaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))}, Liabilities: sdk.NewInt(0), - InterestPaidCollaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))), - InterestPaidCustodies: sdk.NewCoins(sdk.NewCoin("ATOM", sdk.NewInt(0))), - InterestUnpaidCollaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))), - Custodies: sdk.NewCoins(sdk.NewCoin("ATOM", sdk.NewInt(0))), + InterestPaidCollaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))}, + InterestPaidCustodies: []sdk.Coin{sdk.NewCoin("ATOM", sdk.NewInt(0))}, + InterestUnpaidCollaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))}, + Custodies: []sdk.Coin{sdk.NewCoin("ATOM", sdk.NewInt(0))}, Leverages: []sdk.Dec{sdk.NewDec(0)}, MtpHealth: sdk.NewDec(0), Position: types.Position_LONG, diff --git a/x/margin/keeper/close_long_test.go b/x/margin/keeper/close_long_test.go index cbc1db85f..df8c1a206 100644 --- a/x/margin/keeper/close_long_test.go +++ b/x/margin/keeper/close_long_test.go @@ -90,7 +90,7 @@ func TestCloseLong_AmmPoolNotFound(t *testing.T) { } mtp = types.MTP{ AmmPoolId: 2, - Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))), + Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))}, } ) @@ -123,8 +123,8 @@ func TestCloseLong_ErrorHandleInterest(t *testing.T) { } mtp = types.MTP{ AmmPoolId: 2, - Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))), - Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))), + Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))}, + Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))}, } pool = types.Pool{ InterestRate: math.LegacyNewDec(2), @@ -162,8 +162,8 @@ func TestCloseLong_ErrorTakeOutCustody(t *testing.T) { } mtp = types.MTP{ AmmPoolId: 2, - Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))), - Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))), + Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))}, + Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))}, } pool = types.Pool{ InterestRate: math.LegacyNewDec(2), @@ -202,8 +202,8 @@ func TestCloseLong_ErrorEstimateAndRepay(t *testing.T) { } mtp = types.MTP{ AmmPoolId: 2, - Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))), - Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))), + Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))}, + Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))}, } pool = types.Pool{ InterestRate: math.LegacyNewDec(2), @@ -243,8 +243,8 @@ func TestCloseLong_SuccessfulClosingLongPosition(t *testing.T) { } mtp = types.MTP{ AmmPoolId: 2, - Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))), - Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))), + Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))}, + Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))}, } pool = types.Pool{ InterestRate: math.LegacyNewDec(2), diff --git a/x/margin/keeper/close_short_test.go b/x/margin/keeper/close_short_test.go index 2fefda169..aa51a5441 100644 --- a/x/margin/keeper/close_short_test.go +++ b/x/margin/keeper/close_short_test.go @@ -90,7 +90,7 @@ func TestCloseShort_AmmPoolNotFound(t *testing.T) { } mtp = types.MTP{ AmmPoolId: 2, - Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))), + Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))}, } ) @@ -123,8 +123,8 @@ func TestCloseShort_ErrorHandleInterest(t *testing.T) { } mtp = types.MTP{ AmmPoolId: 2, - Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))), - Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))), + Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))}, + Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))}, } pool = types.Pool{ InterestRate: math.LegacyNewDec(2), @@ -162,8 +162,8 @@ func TestCloseShort_ErrorTakeOutCustody(t *testing.T) { } mtp = types.MTP{ AmmPoolId: 2, - Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))), - Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))), + Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))}, + Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))}, } pool = types.Pool{ InterestRate: math.LegacyNewDec(2), @@ -202,8 +202,8 @@ func TestCloseShort_ErrorEstimateAndRepay(t *testing.T) { } mtp = types.MTP{ AmmPoolId: 2, - Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))), - Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))), + Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))}, + Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))}, } pool = types.Pool{ InterestRate: math.LegacyNewDec(2), @@ -243,8 +243,8 @@ func TestCloseShort_SuccessfulClosingLongPosition(t *testing.T) { } mtp = types.MTP{ AmmPoolId: 2, - Custodies: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(0))), - Collaterals: sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))), + Custodies: []sdk.Coin{sdk.NewCoin("uatom", sdk.NewInt(0))}, + Collaterals: []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))}, } pool = types.Pool{ InterestRate: math.LegacyNewDec(2), diff --git a/x/margin/keeper/invariant_check_test.go b/x/margin/keeper/invariant_check_test.go index 640de2b07..b23c9b601 100644 --- a/x/margin/keeper/invariant_check_test.go +++ b/x/margin/keeper/invariant_check_test.go @@ -29,9 +29,9 @@ func TestCheckBalanceInvariant_InvalidBalance(t *testing.T) { // Create a pool // Mint 100000USDC - usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))) + usdcToken := []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))} // Mint 100000ATOM - atomToken := sdk.NewCoins(sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))) + atomToken := []sdk.Coin{sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))} err := app.BankKeeper.MintCoins(ctx, types.ModuleName, usdcToken) require.NoError(t, err) diff --git a/x/margin/keeper/keeper_test.go b/x/margin/keeper/keeper_test.go index b3f94c4f3..4751e244c 100644 --- a/x/margin/keeper/keeper_test.go +++ b/x/margin/keeper/keeper_test.go @@ -28,12 +28,12 @@ func TestSetGetMTP(t *testing.T) { for i := 0; i < 2; i++ { mtp := types.MTP{ Address: addr[i].String(), - Collaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))), + Collaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))}, Liabilities: sdk.NewInt(0), - InterestPaidCollaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))), - InterestPaidCustodies: sdk.NewCoins(sdk.NewCoin("ATOM", sdk.NewInt(0))), - InterestUnpaidCollaterals: sdk.NewCoins(sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))), - Custodies: sdk.NewCoins(sdk.NewCoin("ATOM", sdk.NewInt(0))), + InterestPaidCollaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))}, + InterestPaidCustodies: []sdk.Coin{sdk.NewCoin("ATOM", sdk.NewInt(0))}, + InterestUnpaidCollaterals: []sdk.Coin{sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0))}, + Custodies: []sdk.Coin{sdk.NewCoin("ATOM", sdk.NewInt(0))}, Leverages: []sdk.Dec{sdk.NewDec(0)}, MtpHealth: sdk.NewDec(0), Position: types.Position_LONG, diff --git a/x/margin/keeper/open_long_test.go b/x/margin/keeper/open_long_test.go index 9edbb62d8..a312bf687 100644 --- a/x/margin/keeper/open_long_test.go +++ b/x/margin/keeper/open_long_test.go @@ -417,9 +417,9 @@ func TestOpenLong_BaseCurrency_Collateral(t *testing.T) { // Create a pool // Mint 100000USDC - usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))) + usdcToken := []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))} // Mint 100000ATOM - atomToken := sdk.NewCoins(sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))) + atomToken := []sdk.Coin{sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))} err := app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken) require.NoError(t, err) @@ -521,9 +521,9 @@ func TestOpenLong_ATOM_Collateral(t *testing.T) { // Create a pool // Mint 100000USDC - usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))) + usdcToken := []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))} // Mint 100000ATOM - atomToken := sdk.NewCoins(sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))) + atomToken := []sdk.Coin{sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))} err := app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken) require.NoError(t, err) diff --git a/x/margin/keeper/open_short_process.go b/x/margin/keeper/open_short_process.go index 7f201b4a1..eae0c93f2 100644 --- a/x/margin/keeper/open_short_process.go +++ b/x/margin/keeper/open_short_process.go @@ -67,7 +67,7 @@ func (k Keeper) ProcessOpenShort(ctx sdk.Context, mtp *types.MTP, leverage sdk.D // if position is short then override the custody asset to the base currency if mtp.Position == types.Position_SHORT { - mtp.Custodies = sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))) + mtp.Custodies = []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(0))} } // Borrow the asset the user wants to short. diff --git a/x/margin/keeper/open_short_test.go b/x/margin/keeper/open_short_test.go index 85e20b77f..da566669a 100644 --- a/x/margin/keeper/open_short_test.go +++ b/x/margin/keeper/open_short_test.go @@ -442,9 +442,9 @@ func TestOpenShort_BaseCurrency_Collateral(t *testing.T) { // Create a pool // Mint 100000USDC - usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))) + usdcToken := []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))} // Mint 100000ATOM - atomToken := sdk.NewCoins(sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))) + atomToken := []sdk.Coin{sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))} err := app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken) require.NoError(t, err) @@ -546,9 +546,9 @@ func TestOpenShort_ATOM_Collateral(t *testing.T) { // Create a pool // Mint 100000USDC - usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))) + usdcToken := []sdk.Coin{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))} // Mint 100000ATOM - atomToken := sdk.NewCoins(sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))) + atomToken := []sdk.Coin{sdk.NewCoin(ptypes.ATOM, sdk.NewInt(100000))} err := app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken) require.NoError(t, err) diff --git a/x/margin/types/types.go b/x/margin/types/types.go index 2f35d72f7..4b5726b9a 100644 --- a/x/margin/types/types.go +++ b/x/margin/types/types.go @@ -20,12 +20,12 @@ func GetPositionFromString(s string) Position { func NewMTP(signer string, collateralAsset string, borrowAsset string, position Position, leverage sdk.Dec, poolId uint64) *MTP { return &MTP{ Address: signer, - Collaterals: sdk.NewCoins(sdk.NewCoin(collateralAsset, sdk.ZeroInt())), + Collaterals: []sdk.Coin{sdk.NewCoin(collateralAsset, sdk.ZeroInt())}, Liabilities: sdk.ZeroInt(), - InterestPaidCollaterals: sdk.NewCoins(sdk.NewCoin(collateralAsset, sdk.NewInt(0))), - InterestPaidCustodies: sdk.NewCoins(sdk.NewCoin(borrowAsset, sdk.NewInt(0))), - InterestUnpaidCollaterals: sdk.NewCoins(sdk.NewCoin(collateralAsset, sdk.NewInt(0))), - Custodies: sdk.NewCoins(sdk.NewCoin(borrowAsset, sdk.ZeroInt())), + InterestPaidCollaterals: []sdk.Coin{sdk.NewCoin(collateralAsset, sdk.ZeroInt())}, + InterestPaidCustodies: []sdk.Coin{sdk.NewCoin(borrowAsset, sdk.ZeroInt())}, + InterestUnpaidCollaterals: []sdk.Coin{sdk.NewCoin(collateralAsset, sdk.ZeroInt())}, + Custodies: []sdk.Coin{sdk.NewCoin(borrowAsset, sdk.ZeroInt())}, Leverages: []sdk.Dec{leverage}, MtpHealth: sdk.ZeroDec(), Position: position,