diff --git a/x/liquidity/keeper/pair_test.go b/x/liquidity/keeper/pair_test.go index a02cb1a27..85dd10c81 100644 --- a/x/liquidity/keeper/pair_test.go +++ b/x/liquidity/keeper/pair_test.go @@ -75,7 +75,7 @@ func (s *KeeperTestSuite) TestCreatePair() { Msg: *types.NewMsgCreatePair( appID1, addr1, asset1.Denom, asset2.Denom, ), - ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than 2000000000ucmdx"), "insufficient pair creation fee"), + ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0ucmdx is smaller than 2000000000ucmdx"), "insufficient pair creation fee"), ExpResp: &types.Pair{}, QueryResponseIndex: 0, QueryResponse: nil, diff --git a/x/liquidity/keeper/pool_test.go b/x/liquidity/keeper/pool_test.go index afde96b78..d3a6d737e 100644 --- a/x/liquidity/keeper/pool_test.go +++ b/x/liquidity/keeper/pool_test.go @@ -125,7 +125,7 @@ func (s *KeeperTestSuite) TestCreatePool() { Msg: *types.NewMsgCreatePool( appID1, addr1, dummyPair1.Id, sdk.NewCoins(sdk.NewCoin(dummyPair1.BaseCoinDenom, sdkmath.NewInt(1000000000000)), sdk.NewCoin(dummyPair1.QuoteCoinDenom, sdkmath.NewInt(1000000000000))), ), - ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than 1000000000000%s", dummyPair1.QuoteCoinDenom), + ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0%s is smaller than 1000000000000%s", dummyPair1.QuoteCoinDenom, dummyPair1.QuoteCoinDenom), ExpResp: &types.Pool{}, QueryResponseIndex: 0, QueryResponse: nil, @@ -138,7 +138,7 @@ func (s *KeeperTestSuite) TestCreatePool() { Msg: *types.NewMsgCreatePool( appID1, addr1, dummyPair2.Id, sdk.NewCoins(sdk.NewCoin(dummyPair2.BaseCoinDenom, sdkmath.NewInt(1000000000000)), sdk.NewCoin(dummyPair2.QuoteCoinDenom, sdkmath.NewInt(1000000000000))), ), - ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than %s", params.PoolCreationFee[0].String()), "insufficient pool creation fee"), + ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0ucmdx is smaller than %s", params.PoolCreationFee[0].String()), "insufficient pool creation fee"), ExpResp: &types.Pool{}, QueryResponseIndex: 0, QueryResponse: nil, @@ -453,7 +453,7 @@ func (s *KeeperTestSuite) TestDeposit() { Msg: *types.NewMsgDeposit( appID1, addr1, app1Pool.Id, sdk.NewCoins(sdk.NewCoin(app1Pair.BaseCoinDenom, sdkmath.NewInt(100000000)), sdk.NewCoin(app1Pair.QuoteCoinDenom, sdkmath.NewInt(100000000))), ), - ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than 100000000%s", app1Pair.BaseCoinDenom), + ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0%s is smaller than 100000000%s", app1Pair.BaseCoinDenom, app1Pair.BaseCoinDenom), ExpResp: &types.DepositRequest{}, QueryResponseIndex: 0, QueryResponse: nil, @@ -1058,7 +1058,7 @@ func (s *KeeperTestSuite) TestCreateRangedPool() { appID1, addr1, dummyPair1.Id, sdk.NewCoins(sdk.NewCoin(dummyPair1.BaseCoinDenom, sdkmath.NewInt(1000000000000)), sdk.NewCoin(dummyPair1.QuoteCoinDenom, sdkmath.NewInt(1000000000000))), sdkmath.LegacyMustNewDecFromStr("0.99"), sdkmath.LegacyMustNewDecFromStr("1.01"), sdkmath.LegacyMustNewDecFromStr("1"), ), - ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than 1000000000000%s", dummyPair1.QuoteCoinDenom), + ExpErr: errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0%s is smaller than 1000000000000%s", dummyPair1.QuoteCoinDenom, dummyPair1.QuoteCoinDenom), ExpResp: &types.Pool{}, QueryResponseIndex: 0, QueryResponse: nil, @@ -1072,7 +1072,7 @@ func (s *KeeperTestSuite) TestCreateRangedPool() { appID1, addr1, dummyPair2.Id, sdk.NewCoins(sdk.NewCoin(dummyPair2.BaseCoinDenom, sdkmath.NewInt(1000000000000)), sdk.NewCoin(dummyPair2.QuoteCoinDenom, sdkmath.NewInt(1000000000000))), sdkmath.LegacyMustNewDecFromStr("0.99"), sdkmath.LegacyMustNewDecFromStr("1.01"), sdkmath.LegacyMustNewDecFromStr("1"), ), - ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance is smaller than %s", params.PoolCreationFee[0].String()), "insufficient pool creation fee"), + ExpErr: errorsmod.Wrap(errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, "spendable balance 0ucmdx is smaller than %s", params.PoolCreationFee[0].String()), "insufficient pool creation fee"), ExpResp: &types.Pool{}, QueryResponseIndex: 0, QueryResponse: nil, diff --git a/x/liquidity/legacy/v1/liquidity.pb.go b/x/liquidity/legacy/v1/liquidity.pb.go index b85a4b6d5..0105398f4 100644 --- a/x/liquidity/legacy/v1/liquidity.pb.go +++ b/x/liquidity/legacy/v1/liquidity.pb.go @@ -6,6 +6,7 @@ package types import ( fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + cosmossdk_io_math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -180,7 +181,7 @@ type Pair struct { QuoteCoinDenom string `protobuf:"bytes,3,opt,name=quote_coin_denom,json=quoteCoinDenom,proto3" json:"quote_coin_denom,omitempty"` EscrowAddress string `protobuf:"bytes,4,opt,name=escrow_address,json=escrowAddress,proto3" json:"escrow_address,omitempty"` LastOrderId uint64 `protobuf:"varint,5,opt,name=last_order_id,json=lastOrderId,proto3" json:"last_order_id,omitempty"` - LastPrice *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=last_price,json=lastPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"last_price,omitempty"` + LastPrice *cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=last_price,json=lastPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"last_price,omitempty"` CurrentBatchId uint64 `protobuf:"varint,7,opt,name=current_batch_id,json=currentBatchId,proto3" json:"current_batch_id,omitempty"` SwapFeeCollectorAddress string `protobuf:"bytes,8,opt,name=swap_fee_collector_address,json=swapFeeCollectorAddress,proto3" json:"swap_fee_collector_address,omitempty"` AppId uint64 `protobuf:"varint,9,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` @@ -385,9 +386,9 @@ type Order struct { // received_coin specifies the received coin after the swap ReceivedCoin types.Coin `protobuf:"bytes,8,opt,name=received_coin,json=receivedCoin,proto3" json:"received_coin"` // price specifies the price that an orderer is willing to swap - Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"` - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` - OpenAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=open_amount,json=openAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"open_amount"` + Price cosmossdk_io_math.LegacyDec `protobuf:"bytes,9,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"` + Amount cosmossdk_io_math.Int `protobuf:"bytes,10,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` + OpenAmount cosmossdk_io_math.Int `protobuf:"bytes,11,opt,name=open_amount,json=openAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"open_amount"` // batch_id specifies the pair's batch id when the request is stored BatchId uint64 `protobuf:"varint,12,opt,name=batch_id,json=batchId,proto3" json:"batch_id,omitempty"` ExpireAt time.Time `protobuf:"bytes,13,opt,name=expire_at,json=expireAt,proto3,stdtime" json:"expire_at"` @@ -1725,7 +1726,7 @@ func (m *Pair) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Dec + var v cosmossdk_io_math.LegacyDec m.LastPrice = &v if err := m.LastPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/liquidity/legacy/v1/params.pb.go b/x/liquidity/legacy/v1/params.pb.go index d502aa06b..37d3374c2 100644 --- a/x/liquidity/legacy/v1/params.pb.go +++ b/x/liquidity/legacy/v1/params.pb.go @@ -6,6 +6,8 @@ package types import ( fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + cosmossdk_io_math "cosmossdk.io/math" + cosmossdk_io_store "cosmossdk.io/store" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -72,19 +74,19 @@ type GenericParams struct { TickPrecision uint64 `protobuf:"varint,2,opt,name=tick_precision,json=tickPrecision,proto3" json:"tick_precision,omitempty"` FeeCollectorAddress string `protobuf:"bytes,3,opt,name=fee_collector_address,json=feeCollectorAddress,proto3" json:"fee_collector_address,omitempty"` DustCollectorAddress string `protobuf:"bytes,4,opt,name=dust_collector_address,json=dustCollectorAddress,proto3" json:"dust_collector_address,omitempty"` - MinInitialPoolCoinSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=min_initial_pool_coin_supply,json=minInitialPoolCoinSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_initial_pool_coin_supply"` + MinInitialPoolCoinSupply cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=min_initial_pool_coin_supply,json=minInitialPoolCoinSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_initial_pool_coin_supply"` PairCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=pair_creation_fee,json=pairCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pair_creation_fee"` PoolCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=pool_creation_fee,json=poolCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_creation_fee"` - MinInitialDepositAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=min_initial_deposit_amount,json=minInitialDepositAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_initial_deposit_amount"` - MaxPriceLimitRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=max_price_limit_ratio,json=maxPriceLimitRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_price_limit_ratio"` + MinInitialDepositAmount cosmossdk_io_math.Int `protobuf:"bytes,8,opt,name=min_initial_deposit_amount,json=minInitialDepositAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_initial_deposit_amount"` + MaxPriceLimitRatio cosmossdk_io_math.LegacyDec `protobuf:"bytes,9,opt,name=max_price_limit_ratio,json=maxPriceLimitRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_price_limit_ratio"` MaxOrderLifespan time.Duration `protobuf:"bytes,10,opt,name=max_order_lifespan,json=maxOrderLifespan,proto3,stdduration" json:"max_order_lifespan"` - SwapFeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=swap_fee_rate,json=swapFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee_rate"` - WithdrawFeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=withdraw_fee_rate,json=withdrawFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"withdraw_fee_rate"` - DepositExtraGas github_com_cosmos_cosmos_sdk_types.Gas `protobuf:"varint,13,opt,name=deposit_extra_gas,json=depositExtraGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Gas" json:"deposit_extra_gas"` - WithdrawExtraGas github_com_cosmos_cosmos_sdk_types.Gas `protobuf:"varint,14,opt,name=withdraw_extra_gas,json=withdrawExtraGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Gas" json:"withdraw_extra_gas"` - OrderExtraGas github_com_cosmos_cosmos_sdk_types.Gas `protobuf:"varint,15,opt,name=order_extra_gas,json=orderExtraGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Gas" json:"order_extra_gas"` + SwapFeeRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,11,opt,name=swap_fee_rate,json=swapFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee_rate"` + WithdrawFeeRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,12,opt,name=withdraw_fee_rate,json=withdrawFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"withdraw_fee_rate"` + DepositExtraGas cosmossdk_io_store.Gas `protobuf:"varint,13,opt,name=deposit_extra_gas,json=depositExtraGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Gas" json:"deposit_extra_gas"` + WithdrawExtraGas cosmossdk_io_store.Gas `protobuf:"varint,14,opt,name=withdraw_extra_gas,json=withdrawExtraGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Gas" json:"withdraw_extra_gas"` + OrderExtraGas cosmossdk_io_store.Gas `protobuf:"varint,15,opt,name=order_extra_gas,json=orderExtraGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Gas" json:"order_extra_gas"` SwapFeeDistrDenom string `protobuf:"bytes,16,opt,name=swap_fee_distr_denom,json=swapFeeDistrDenom,proto3" json:"swap_fee_distr_denom,omitempty"` - SwapFeeBurnRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,17,opt,name=swap_fee_burn_rate,json=swapFeeBurnRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee_burn_rate"` + SwapFeeBurnRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,17,opt,name=swap_fee_burn_rate,json=swapFeeBurnRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee_burn_rate"` AppId uint64 `protobuf:"varint,18,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` } @@ -928,7 +930,7 @@ func (m *GenericParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.DepositExtraGas |= github_com_cosmos_cosmos_sdk_types.Gas(b&0x7F) << shift + m.DepositExtraGas |= cosmossdk_io_store.Gas(b&0x7F) << shift if b < 0x80 { break } @@ -947,7 +949,7 @@ func (m *GenericParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.WithdrawExtraGas |= github_com_cosmos_cosmos_sdk_types.Gas(b&0x7F) << shift + m.WithdrawExtraGas |= cosmossdk_io_store.Gas(b&0x7F) << shift if b < 0x80 { break } @@ -966,7 +968,7 @@ func (m *GenericParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.OrderExtraGas |= github_com_cosmos_cosmos_sdk_types.Gas(b&0x7F) << shift + m.OrderExtraGas |= cosmossdk_io_store.Gas(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/liquidity/types/util.go b/x/liquidity/types/util.go index ecde02172..a3b55856f 100644 --- a/x/liquidity/types/util.go +++ b/x/liquidity/types/util.go @@ -9,7 +9,6 @@ import ( "github.com/cometbft/cometbft/crypto" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/comdex-official/comdex/x/liquidity/amm" "github.com/comdex-official/comdex/x/liquidity/expected" @@ -57,15 +56,12 @@ func (op *BulkSendCoinsOperation) QueueSendCoins( // Run runs BankKeeper.InputOutputCoins once for queued operations. func (op *BulkSendCoinsOperation) Run(ctx sdk.Context, bankKeeper expected.BankKeeper) error { if len(op.txs) > 0 { - var ( - inputs []banktypes.Input - outputs []banktypes.Output - ) for _, tx := range op.txs { - inputs = append(inputs, banktypes.NewInput(tx.from, tx.amt)) - outputs = append(outputs, banktypes.NewOutput(tx.to, tx.amt)) + if err := bankKeeper.SendCoins(ctx, tx.from, tx.to, tx.amt); err != nil { + return err + } } - return bankKeeper.InputOutputCoins(ctx, inputs, outputs) + return nil } return nil }