diff --git a/proto/elys/amm/query.proto b/proto/elys/amm/query.proto index c3a718c29..45c711034 100644 --- a/proto/elys/amm/query.proto +++ b/proto/elys/amm/query.proto @@ -133,11 +133,15 @@ message QueryAllDenomLiquidityResponse { message QuerySwapEstimationRequest { repeated SwapAmountInRoute routes = 1; cosmos.base.v1beta1.Coin token_in = 2 [(gogoproto.nullable) = false]; + string discount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; } message QuerySwapEstimationResponse { string spot_price = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; cosmos.base.v1beta1.Coin token_out = 2 [(gogoproto.nullable) = false ] ; + string swapFee = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string discount = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin available_liquidity = 5 [(gogoproto.nullable) = false ] ; } message QuerySlippageTrackRequest { @@ -185,6 +189,7 @@ message QuerySwapEstimationByDenomRequest { cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.nullable) = false]; string denom_in = 2; string denom_out = 3; + string discount = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; } message QuerySwapEstimationByDenomResponse { @@ -192,8 +197,12 @@ message QuerySwapEstimationByDenomResponse { repeated SwapAmountOutRoute out_route = 2; string spot_price = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false]; + string swapFee = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string discount = 6 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin available_liquidity = 7 [(gogoproto.nullable) = false ] ; } message QueryAMMPriceRequest { cosmos.base.v1beta1.Coin token_in = 1 [(gogoproto.nullable) = false]; + string discount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; } diff --git a/proto/elys/amm/tx.proto b/proto/elys/amm/tx.proto index 6c4a2bc98..e95b35db0 100644 --- a/proto/elys/amm/tx.proto +++ b/proto/elys/amm/tx.proto @@ -63,12 +63,14 @@ message MsgSwapExactAmountIn { cosmos.base.v1beta1.Coin token_in = 3 [(gogoproto.nullable) = false ] ; string token_out_min_amount = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; string discount = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - + string recipient = 6; } message MsgSwapExactAmountInResponse { string token_out_amount = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - string discount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string swap_fee = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string discount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string recipient = 4; } message MsgSwapExactAmountOut { @@ -77,11 +79,14 @@ message MsgSwapExactAmountOut { cosmos.base.v1beta1.Coin token_out = 3 [(gogoproto.nullable) = false ] ; string token_in_max_amount = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; string discount = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string recipient = 6; } message MsgSwapExactAmountOutResponse { string token_in_amount = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - string discount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string swap_fee = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string discount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string recipient = 4; } message MsgFeedMultipleExternalLiquidity { @@ -111,6 +116,7 @@ message MsgSwapByDenom { string denom_in = 5; string denom_out = 6; string discount = 7 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string recipient = 8; } message MsgSwapByDenomResponse { @@ -118,5 +124,7 @@ message MsgSwapByDenomResponse { repeated SwapAmountInRoute in_route = 2; repeated SwapAmountOutRoute out_route = 3; string spot_price = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - string discount = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string swap_fee = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string discount = 6 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string recipient = 7; } diff --git a/x/amm/client/cli/query_swap_estimation.go b/x/amm/client/cli/query_swap_estimation.go index a4e783662..5e45396e2 100644 --- a/x/amm/client/cli/query_swap_estimation.go +++ b/x/amm/client/cli/query_swap_estimation.go @@ -40,6 +40,15 @@ func CmdSwapEstimation() *cobra.Command { }) } + discountStr, err := cmd.Flags().GetString(FlagDiscount) + if err != nil { + return err + } + discount, err := sdk.NewDecFromStr(discountStr) + if err != nil { + return err + } + clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err @@ -48,8 +57,9 @@ func CmdSwapEstimation() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) params := &types.QuerySwapEstimationRequest{ - Routes: reqRoutes, - TokenIn: reqTokenIn, + Routes: reqRoutes, + TokenIn: reqTokenIn, + Discount: discount, } res, err := queryClient.SwapEstimation(cmd.Context(), params) @@ -63,5 +73,7 @@ func CmdSwapEstimation() *cobra.Command { flags.AddQueryFlagsToCmd(cmd) + cmd.Flags().String(FlagDiscount, "0.0", "discount to apply to the swap fee") + return cmd } diff --git a/x/amm/client/cli/query_swap_estimation_by_denom.go b/x/amm/client/cli/query_swap_estimation_by_denom.go index f4f0bfe6e..da4f080ff 100644 --- a/x/amm/client/cli/query_swap_estimation_by_denom.go +++ b/x/amm/client/cli/query_swap_estimation_by_denom.go @@ -26,6 +26,15 @@ func CmdSwapEstimationByDenom() *cobra.Command { reqDenomIn := args[1] reqDenomOut := args[2] + discountStr, err := cmd.Flags().GetString(FlagDiscount) + if err != nil { + return err + } + discount, err := sdk.NewDecFromStr(discountStr) + if err != nil { + return err + } + clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err @@ -34,10 +43,10 @@ func CmdSwapEstimationByDenom() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) params := &types.QuerySwapEstimationByDenomRequest{ - Amount: reqAmount, DenomIn: reqDenomIn, DenomOut: reqDenomOut, + Discount: discount, } res, err := queryClient.SwapEstimationByDenom(cmd.Context(), params) @@ -51,5 +60,7 @@ func CmdSwapEstimationByDenom() *cobra.Command { flags.AddQueryFlagsToCmd(cmd) + cmd.Flags().String(FlagDiscount, "0.0", "discount to apply to the swap fee") + return cmd } diff --git a/x/amm/client/cli/tx.go b/x/amm/client/cli/tx.go index d7540d077..e7256a93b 100644 --- a/x/amm/client/cli/tx.go +++ b/x/amm/client/cli/tx.go @@ -17,6 +17,7 @@ var ( const ( FlagDiscount = "discount" + FlagRecipient = "recipient" flagPacketTimeoutTimestamp = "packet-timeout-timestamp" listSeparator = "," ) diff --git a/x/amm/client/cli/tx_swap_by_denom.go b/x/amm/client/cli/tx_swap_by_denom.go index d7ee70400..ace22572a 100644 --- a/x/amm/client/cli/tx_swap_by_denom.go +++ b/x/amm/client/cli/tx_swap_by_denom.go @@ -65,6 +65,11 @@ func CmdSwapByDenom() *cobra.Command { return err } + recipient, err := cmd.Flags().GetString(FlagRecipient) + if err != nil { + return err + } + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err @@ -72,6 +77,7 @@ func CmdSwapByDenom() *cobra.Command { msg := types.NewMsgSwapByDenom( clientCtx.GetFromAddress().String(), + recipient, argAmount, minAmount, maxAmount, @@ -91,6 +97,7 @@ func CmdSwapByDenom() *cobra.Command { cmd.Flags().String(FlagMinAmount, "", "minimum amount of tokens to receive") cmd.Flags().String(FlagMaxAmount, "", "maximum amount of tokens to send") cmd.Flags().String(FlagDiscount, "0.0", "discount to apply to the swap fee (only smart contract broker can apply the discount)") + cmd.Flags().String(FlagRecipient, "", "optional recipient field for the tokens swapped to be sent to") return cmd } diff --git a/x/amm/client/cli/tx_swap_exact_amount_in.go b/x/amm/client/cli/tx_swap_exact_amount_in.go index 67e639e2d..c8e89f96c 100644 --- a/x/amm/client/cli/tx_swap_exact_amount_in.go +++ b/x/amm/client/cli/tx_swap_exact_amount_in.go @@ -53,6 +53,11 @@ func CmdSwapExactAmountIn() *cobra.Command { return err } + recipient, err := cmd.Flags().GetString(FlagRecipient) + if err != nil { + return err + } + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err @@ -60,6 +65,7 @@ func CmdSwapExactAmountIn() *cobra.Command { msg := types.NewMsgSwapExactAmountIn( clientCtx.GetFromAddress().String(), + recipient, argTokenIn, argTokenOutMinAmount, argSwapRoutePoolIds, @@ -76,6 +82,7 @@ func CmdSwapExactAmountIn() *cobra.Command { flags.AddTxFlagsToCmd(cmd) cmd.Flags().String(FlagDiscount, "0.0", "discount to apply to the swap fee (only smart contract broker can apply the discount)") + cmd.Flags().String(FlagRecipient, "", "optional recipient field for the tokens swapped to be sent to") return cmd } diff --git a/x/amm/client/cli/tx_swap_exact_amount_out.go b/x/amm/client/cli/tx_swap_exact_amount_out.go index 05950cf52..8eff032e3 100644 --- a/x/amm/client/cli/tx_swap_exact_amount_out.go +++ b/x/amm/client/cli/tx_swap_exact_amount_out.go @@ -53,6 +53,11 @@ func CmdSwapExactAmountOut() *cobra.Command { return err } + recipient, err := cmd.Flags().GetString(FlagRecipient) + if err != nil { + return err + } + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err @@ -60,6 +65,7 @@ func CmdSwapExactAmountOut() *cobra.Command { msg := types.NewMsgSwapExactAmountOut( clientCtx.GetFromAddress().String(), + recipient, argTokenOut, argTokenOutMaxAmount, argSwapRoutePoolIds, @@ -76,6 +82,7 @@ func CmdSwapExactAmountOut() *cobra.Command { flags.AddTxFlagsToCmd(cmd) cmd.Flags().String(FlagDiscount, "0.0", "discount to apply to the swap fee (only smart contract broker can apply the discount)") + cmd.Flags().String(FlagRecipient, "", "optional recipient field for the tokens swapped to be sent to") return cmd } diff --git a/x/amm/client/wasm/query_amm_price_by_denom.go b/x/amm/client/wasm/query_amm_price_by_denom.go index 08bd0c465..5314e7582 100644 --- a/x/amm/client/wasm/query_amm_price_by_denom.go +++ b/x/amm/client/wasm/query_amm_price_by_denom.go @@ -36,8 +36,9 @@ func (oq *Querier) queryAmmPriceByDenom(ctx sdk.Context, query *ammtypes.QueryAM routes := resp.InRoute tokenIn := query.TokenIn + discount := query.Discount - spotPrice, _, err := oq.keeper.CalcInRouteSpotPrice(ctx, tokenIn, routes) + spotPrice, _, _, _, _, err := oq.keeper.CalcInRouteSpotPrice(ctx, tokenIn, routes, discount) if err != nil { return nil, errorsmod.Wrap(err, "failed to get in route by denom") } diff --git a/x/amm/keeper/abci.go b/x/amm/keeper/abci.go index 08ba8304d..b2d3c4f42 100644 --- a/x/amm/keeper/abci.go +++ b/x/amm/keeper/abci.go @@ -28,7 +28,11 @@ func (k Keeper) ApplySwapRequest(ctx sdk.Context, msg sdk.Msg) error { if err != nil { return err } - _, err = k.RouteExactAmountIn(ctx, sender, msg.Routes, msg.TokenIn, math.Int(msg.TokenOutMinAmount), msg.Discount) + recipient, err := sdk.AccAddressFromBech32(msg.Recipient) + if err != nil { + recipient = sender + } + _, _, _, err = k.RouteExactAmountIn(ctx, sender, recipient, msg.Routes, msg.TokenIn, math.Int(msg.TokenOutMinAmount), msg.Discount) if err != nil { return err } @@ -38,7 +42,11 @@ func (k Keeper) ApplySwapRequest(ctx sdk.Context, msg sdk.Msg) error { if err != nil { return err } - _, err = k.RouteExactAmountOut(ctx, sender, msg.Routes, msg.TokenInMaxAmount, msg.TokenOut, msg.Discount) + recipient, err := sdk.AccAddressFromBech32(msg.Recipient) + if err != nil { + recipient = sender + } + _, _, _, err = k.RouteExactAmountOut(ctx, sender, recipient, msg.Routes, msg.TokenInMaxAmount, msg.TokenOut, msg.Discount) if err != nil { return err } diff --git a/x/amm/keeper/calc_in_route_spot_price.go b/x/amm/keeper/calc_in_route_spot_price.go index 32a758108..b10f95153 100644 --- a/x/amm/keeper/calc_in_route_spot_price.go +++ b/x/amm/keeper/calc_in_route_spot_price.go @@ -6,9 +6,9 @@ import ( ) // CalcInRouteSpotPrice calculates the spot price of the given token and in route -func (k Keeper) CalcInRouteSpotPrice(ctx sdk.Context, tokenIn sdk.Coin, routes []*types.SwapAmountInRoute) (sdk.Dec, sdk.Coin, error) { +func (k Keeper) CalcInRouteSpotPrice(ctx sdk.Context, tokenIn sdk.Coin, routes []*types.SwapAmountInRoute, discount sdk.Dec) (sdk.Dec, sdk.Coin, sdk.Dec, sdk.Dec, sdk.Coin, error) { if routes == nil || len(routes) == 0 { - return sdk.ZeroDec(), sdk.Coin{}, types.ErrEmptyRoutes + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, types.ErrEmptyRoutes } // Start with the initial token input @@ -17,29 +17,54 @@ func (k Keeper) CalcInRouteSpotPrice(ctx sdk.Context, tokenIn sdk.Coin, routes [ // The final token out denom var tokenOutDenom string + // Initialize the total discounted swap fee + totalDiscountedSwapFee := sdk.ZeroDec() + + // Track the total available liquidity in the pool for final token out denom + var availableLiquidity sdk.Coin + for _, route := range routes { poolId := route.PoolId tokenOutDenom = route.TokenOutDenom pool, found := k.GetPool(ctx, poolId) if !found { - return sdk.ZeroDec(), sdk.Coin{}, types.ErrPoolNotFound + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, types.ErrPoolNotFound + } + + // Get Pool swap fee + swapFee := pool.GetPoolParams().SwapFee + + // Apply discount to swap fee if applicable + swapFee, _, err := k.ApplyDiscount(ctx, swapFee, discount, k.BrokerAddress(ctx)) + if err != nil { + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err } + // Calculate the total discounted swap fee + totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) + // Estimate swap snapshot := k.GetPoolSnapshotOrSet(ctx, pool) - swapResult, err := k.CalcOutAmtGivenIn(ctx, pool.PoolId, k.oracleKeeper, &snapshot, tokensIn, tokenOutDenom, sdk.ZeroDec()) + swapResult, err := k.CalcOutAmtGivenIn(ctx, pool.PoolId, k.oracleKeeper, &snapshot, tokensIn, tokenOutDenom, swapFee) if err != nil { - return sdk.ZeroDec(), sdk.Coin{}, err + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err } if swapResult.IsZero() { - return sdk.ZeroDec(), sdk.Coin{}, types.ErrAmountTooLow + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, types.ErrAmountTooLow } // Use the current swap result as the input for the next iteration tokensIn = sdk.Coins{swapResult} + + // Get the available liquidity for the final token out denom + _, poolAsset, err := pool.GetPoolAssetAndIndex(tokenOutDenom) + if err != nil { + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err + } + availableLiquidity = poolAsset.Token } // Calculate the spot price given the initial token in and the final token out @@ -51,5 +76,5 @@ func (k Keeper) CalcInRouteSpotPrice(ctx sdk.Context, tokenIn sdk.Coin, routes [ // Construct the token out coin tokenOut := sdk.NewCoin(tokenOutDenom, tokenOutAmt.TruncateInt()) - return spotPrice, tokenOut, nil + return spotPrice, tokenOut, totalDiscountedSwapFee, discount, availableLiquidity, nil } diff --git a/x/amm/keeper/calc_in_route_spot_price_test.go b/x/amm/keeper/calc_in_route_spot_price_test.go index 0624ce351..e0be32dd8 100644 --- a/x/amm/keeper/calc_in_route_spot_price_test.go +++ b/x/amm/keeper/calc_in_route_spot_price_test.go @@ -20,7 +20,7 @@ func TestCalcInRouteSpotPrice(t *testing.T) { accountedPoolKeeper.On("GetAccountedBalance", ctx, uint64(1), "denom1").Return(sdk.NewInt(1000)) accountedPoolKeeper.On("GetAccountedBalance", ctx, uint64(1), "denom2").Return(sdk.NewInt(1000)) routes := []*types.SwapAmountInRoute{{PoolId: 1, TokenOutDenom: "denom2"}} - spotPrice, _, err := k.CalcInRouteSpotPrice(ctx, tokenIn, routes) + spotPrice, _, _, _, _, err := k.CalcInRouteSpotPrice(ctx, tokenIn, routes, sdk.ZeroDec()) require.NoError(t, err) require.NotZero(t, spotPrice) accountedPoolKeeper.AssertExpectations(t) @@ -34,17 +34,17 @@ func TestCalcInRouteSpotPrice(t *testing.T) { {PoolId: 2, TokenOutDenom: "baseCurrency"}, {PoolId: 3, TokenOutDenom: "denom3"}, } - spotPrice, _, err = k.CalcInRouteSpotPrice(ctx, tokenIn, routes) + spotPrice, _, _, _, _, err = k.CalcInRouteSpotPrice(ctx, tokenIn, routes, sdk.ZeroDec()) require.NoError(t, err) require.NotZero(t, spotPrice) accountedPoolKeeper.AssertExpectations(t) // Test no routes - _, _, err = k.CalcInRouteSpotPrice(ctx, tokenIn, nil) + _, _, _, _, _, err = k.CalcInRouteSpotPrice(ctx, tokenIn, nil, sdk.ZeroDec()) require.Error(t, err) // Test invalid pool routes = []*types.SwapAmountInRoute{{PoolId: 9999, TokenOutDenom: "denom2"}} - _, _, err = k.CalcInRouteSpotPrice(ctx, tokenIn, routes) + _, _, _, _, _, err = k.CalcInRouteSpotPrice(ctx, tokenIn, routes, sdk.ZeroDec()) require.Error(t, err) } diff --git a/x/amm/keeper/calc_out_route_spot_price.go b/x/amm/keeper/calc_out_route_spot_price.go index c56a5e7e9..fa9766561 100644 --- a/x/amm/keeper/calc_out_route_spot_price.go +++ b/x/amm/keeper/calc_out_route_spot_price.go @@ -6,9 +6,9 @@ import ( ) // CalcOutRouteSpotPrice calculates the spot price of the given token and out route -func (k Keeper) CalcOutRouteSpotPrice(ctx sdk.Context, tokenOut sdk.Coin, routes []*types.SwapAmountOutRoute) (sdk.Dec, sdk.Coin, error) { +func (k Keeper) CalcOutRouteSpotPrice(ctx sdk.Context, tokenOut sdk.Coin, routes []*types.SwapAmountOutRoute, discount sdk.Dec) (sdk.Dec, sdk.Coin, sdk.Dec, sdk.Dec, sdk.Coin, error) { if routes == nil || len(routes) == 0 { - return sdk.ZeroDec(), sdk.Coin{}, types.ErrEmptyRoutes + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, types.ErrEmptyRoutes } // Start with the initial token input @@ -17,29 +17,54 @@ func (k Keeper) CalcOutRouteSpotPrice(ctx sdk.Context, tokenOut sdk.Coin, routes // The final token in denom var tokenInDenom string + // Initialize the total discounted swap fee + totalDiscountedSwapFee := sdk.ZeroDec() + + // Track the total available liquidity in the pool for final token out denom + var availableLiquidity sdk.Coin + for _, route := range routes { poolId := route.PoolId tokenInDenom = route.TokenInDenom pool, found := k.GetPool(ctx, poolId) if !found { - return sdk.ZeroDec(), sdk.Coin{}, types.ErrPoolNotFound + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, types.ErrPoolNotFound + } + + // Get Pool swap fee + swapFee := pool.GetPoolParams().SwapFee + + // Apply discount to swap fee if applicable + swapFee, _, err := k.ApplyDiscount(ctx, swapFee, discount, k.BrokerAddress(ctx)) + if err != nil { + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err } + // Calculate the total discounted swap fee + totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) + // Estimate swap snapshot := k.GetPoolSnapshotOrSet(ctx, pool) - swapResult, err := k.CalcInAmtGivenOut(ctx, pool.PoolId, k.oracleKeeper, &snapshot, tokensOut, tokenInDenom, sdk.ZeroDec()) + swapResult, err := k.CalcInAmtGivenOut(ctx, pool.PoolId, k.oracleKeeper, &snapshot, tokensOut, tokenInDenom, swapFee) if err != nil { - return sdk.ZeroDec(), sdk.Coin{}, err + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err } if swapResult.IsZero() { - return sdk.ZeroDec(), sdk.Coin{}, types.ErrAmountTooLow + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, types.ErrAmountTooLow } // Use the current swap result as the input for the next iteration tokensOut = sdk.Coins{swapResult} + + // Get the available liquidity for the final token in denom + _, poolAsset, err := pool.GetPoolAssetAndIndex(tokenInDenom) + if err != nil { + return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err + } + availableLiquidity = poolAsset.Token } // Calculate the spot price given the initial token in and the final token in @@ -51,5 +76,5 @@ func (k Keeper) CalcOutRouteSpotPrice(ctx sdk.Context, tokenOut sdk.Coin, routes // Construct the token out coin tokenIn := sdk.NewCoin(tokenInDenom, tokenInAmt.TruncateInt()) - return spotPrice, tokenIn, nil + return spotPrice, tokenIn, totalDiscountedSwapFee, discount, availableLiquidity, nil } diff --git a/x/amm/keeper/calc_out_route_spot_price_test.go b/x/amm/keeper/calc_out_route_spot_price_test.go index b2896904b..b72e85777 100644 --- a/x/amm/keeper/calc_out_route_spot_price_test.go +++ b/x/amm/keeper/calc_out_route_spot_price_test.go @@ -18,7 +18,7 @@ func TestCalcOutRouteSpotPrice(t *testing.T) { accountedPoolKeeper.On("GetAccountedBalance", ctx, uint64(1), "denom2").Return(sdk.NewInt(1000)) accountedPoolKeeper.On("GetAccountedBalance", ctx, uint64(1), "denom1").Return(sdk.NewInt(1000)) routes := []*types.SwapAmountOutRoute{{PoolId: 1, TokenInDenom: "denom1"}} - spotPrice, _, err := k.CalcOutRouteSpotPrice(ctx, tokenOut, routes) + spotPrice, _, _, _, _, err := k.CalcOutRouteSpotPrice(ctx, tokenOut, routes, sdk.ZeroDec()) require.NoError(t, err) require.NotZero(t, spotPrice) accountedPoolKeeper.AssertExpectations(t) @@ -33,17 +33,17 @@ func TestCalcOutRouteSpotPrice(t *testing.T) { {PoolId: 3, TokenInDenom: "baseCurrency"}, {PoolId: 2, TokenInDenom: "denom1"}, } - spotPrice, _, err = k.CalcOutRouteSpotPrice(ctx, tokenOut, routes) + spotPrice, _, _, _, _, err = k.CalcOutRouteSpotPrice(ctx, tokenOut, routes, sdk.ZeroDec()) require.NoError(t, err) require.NotZero(t, spotPrice) accountedPoolKeeper.AssertExpectations(t) // Test no routes - _, _, err = k.CalcOutRouteSpotPrice(ctx, tokenOut, nil) + _, _, _, _, _, err = k.CalcOutRouteSpotPrice(ctx, tokenOut, nil, sdk.ZeroDec()) require.Error(t, err) // Test invalid pool routes = []*types.SwapAmountOutRoute{{PoolId: 9999, TokenInDenom: "denom2"}} - _, _, err = k.CalcOutRouteSpotPrice(ctx, tokenOut, routes) + _, _, _, _, _, err = k.CalcOutRouteSpotPrice(ctx, tokenOut, routes, sdk.ZeroDec()) require.Error(t, err) } diff --git a/x/amm/keeper/calc_swap_estimation_by_denom.go b/x/amm/keeper/calc_swap_estimation_by_denom.go index cfd4e8968..8b21f01d5 100644 --- a/x/amm/keeper/calc_swap_estimation_by_denom.go +++ b/x/amm/keeper/calc_swap_estimation_by_denom.go @@ -12,39 +12,43 @@ func (k Keeper) CalcSwapEstimationByDenom( denomIn string, denomOut string, baseCurrency string, + discount sdk.Dec, ) ( inRoute []*types.SwapAmountInRoute, outRoute []*types.SwapAmountOutRoute, outAmount sdk.Coin, spotPrice sdk.Dec, + swapFee sdk.Dec, + discountOut sdk.Dec, + availableLiquidity sdk.Coin, err error, ) { // if amount denom is equal to denomIn, calculate swap estimation by denomIn if amount.Denom == denomIn { inRoute, err := k.CalcInRouteByDenom(ctx, denomIn, denomOut, baseCurrency) if err != nil { - return nil, nil, sdk.Coin{}, sdk.ZeroDec(), err + return nil, nil, sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err } - spotPrice, tokenOut, err := k.CalcInRouteSpotPrice(ctx, amount, inRoute) + spotPrice, tokenOut, swapFee, _, availableLiquidity, err := k.CalcInRouteSpotPrice(ctx, amount, inRoute, discount) if err != nil { - return nil, nil, sdk.Coin{}, sdk.ZeroDec(), err + return nil, nil, sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err } - return inRoute, nil, tokenOut, spotPrice, nil + return inRoute, nil, tokenOut, spotPrice, swapFee, discount, availableLiquidity, nil } // if amount denom is equal to denomOut, calculate swap estimation by denomOut if amount.Denom == denomOut { outRoute, err := k.CalcOutRouteByDenom(ctx, denomIn, denomOut, baseCurrency) if err != nil { - return nil, nil, sdk.Coin{}, sdk.ZeroDec(), err + return nil, nil, sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err } - spotPrice, tokenIn, err := k.CalcOutRouteSpotPrice(ctx, amount, outRoute) + spotPrice, tokenIn, swapFee, _, availableLiquidity, err := k.CalcOutRouteSpotPrice(ctx, amount, outRoute, discount) if err != nil { - return nil, nil, sdk.Coin{}, sdk.ZeroDec(), err + return nil, nil, sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err } - return nil, outRoute, tokenIn, spotPrice, nil + return nil, outRoute, tokenIn, spotPrice, swapFee, discount, availableLiquidity, nil } // if amount denom is neither equal to denomIn nor denomOut, return error - return nil, nil, sdk.Coin{}, sdk.ZeroDec(), types.ErrInvalidDenom + return nil, nil, sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, types.ErrInvalidDenom } diff --git a/x/amm/keeper/calc_swap_estimation_by_denom_test.go b/x/amm/keeper/calc_swap_estimation_by_denom_test.go index 8875a7e74..885486ad1 100644 --- a/x/amm/keeper/calc_swap_estimation_by_denom_test.go +++ b/x/amm/keeper/calc_swap_estimation_by_denom_test.go @@ -16,7 +16,7 @@ func TestCalcSwapEstimationByDenom(t *testing.T) { amount := sdk.NewCoin("denom1", sdk.NewInt(100)) accountedPoolKeeper.On("GetAccountedBalance", ctx, uint64(1), "denom1").Return(sdk.NewInt(1000)) accountedPoolKeeper.On("GetAccountedBalance", ctx, uint64(1), "denom2").Return(sdk.NewInt(1000)) - inRoute, outRoute, tokenOut, spotPrice, err := k.CalcSwapEstimationByDenom(ctx, amount, "denom1", "denom2", "baseCurrency") + inRoute, outRoute, tokenOut, spotPrice, _, _, _, err := k.CalcSwapEstimationByDenom(ctx, amount, "denom1", "denom2", "baseCurrency", sdk.ZeroDec()) require.NoError(t, err) require.NotNil(t, inRoute) require.Nil(t, outRoute) @@ -27,7 +27,7 @@ func TestCalcSwapEstimationByDenom(t *testing.T) { amount = sdk.NewCoin("denom2", sdk.NewInt(100)) accountedPoolKeeper.On("GetAccountedBalance", ctx, uint64(1), "denom2").Return(sdk.NewInt(1000)) accountedPoolKeeper.On("GetAccountedBalance", ctx, uint64(1), "denom1").Return(sdk.NewInt(1000)) - inRoute, outRoute, tokenOut, spotPrice, err = k.CalcSwapEstimationByDenom(ctx, amount, "denom1", "denom2", "baseCurrency") + inRoute, outRoute, tokenOut, spotPrice, _, _, _, err = k.CalcSwapEstimationByDenom(ctx, amount, "denom1", "denom2", "baseCurrency", sdk.ZeroDec()) require.NoError(t, err) require.Nil(t, inRoute) require.NotNil(t, outRoute) @@ -36,6 +36,6 @@ func TestCalcSwapEstimationByDenom(t *testing.T) { // Test with invalid amount denom amount = sdk.NewCoin("invalid", sdk.NewInt(1000)) - _, _, _, _, err = k.CalcSwapEstimationByDenom(ctx, amount, "denom1", "denom2", "baseCurrency") + _, _, _, _, _, _, _, err = k.CalcSwapEstimationByDenom(ctx, amount, "denom1", "denom2", "baseCurrency", sdk.ZeroDec()) require.Error(t, err) } diff --git a/x/amm/keeper/fee.go b/x/amm/keeper/fee.go index dd5bce4b1..42e1423a1 100644 --- a/x/amm/keeper/fee.go +++ b/x/amm/keeper/fee.go @@ -61,7 +61,7 @@ func (k Keeper) SwapFeesToRevenueToken(ctx sdk.Context, pool types.Pool, fee sdk // Settles balances between the tx sender and the pool to match the swap that was executed earlier. // Also emits a swap event and updates related liquidity metrics. - err, _ = k.UpdatePoolForSwap(ctx, pool, poolRevenueAddress, tokenIn, tokenOutCoin, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + err, _ = k.UpdatePoolForSwap(ctx, pool, poolRevenueAddress, poolRevenueAddress, tokenIn, tokenOutCoin, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) if err != nil { return err } diff --git a/x/amm/keeper/keeper_swap_exact_amount_in.go b/x/amm/keeper/keeper_swap_exact_amount_in.go index b44dd9c76..b078924c1 100644 --- a/x/amm/keeper/keeper_swap_exact_amount_in.go +++ b/x/amm/keeper/keeper_swap_exact_amount_in.go @@ -19,6 +19,7 @@ import ( func (k Keeper) SwapExactAmountIn( ctx sdk.Context, sender sdk.AccAddress, + recipient sdk.AccAddress, pool types.Pool, tokenIn sdk.Coin, tokenOutDenom string, @@ -61,7 +62,7 @@ func (k Keeper) SwapExactAmountIn( // Settles balances between the tx sender and the pool to match the swap that was executed earlier. // Also emits a swap event and updates related liquidity metrics. - err, swapOutFee := k.UpdatePoolForSwap(ctx, pool, sender, tokenIn, tokenOutCoin, sdk.ZeroDec(), swapFee, weightBalanceBonus) + err, swapOutFee := k.UpdatePoolForSwap(ctx, pool, sender, recipient, tokenIn, tokenOutCoin, sdk.ZeroDec(), swapFee, weightBalanceBonus) if err != nil { return math.Int{}, err } diff --git a/x/amm/keeper/keeper_swap_exact_amount_in_test.go b/x/amm/keeper/keeper_swap_exact_amount_in_test.go index f1d6595b7..951b1b294 100644 --- a/x/amm/keeper/keeper_swap_exact_amount_in_test.go +++ b/x/amm/keeper/keeper_swap_exact_amount_in_test.go @@ -21,7 +21,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { tokenOut sdk.Coin weightBalanceBonus sdk.Dec isOraclePool bool + useNewRecipient bool expSenderBalance sdk.Coins + expRecipientBalance sdk.Coins expPoolBalance sdk.Coins expTreasuryBalance sdk.Coins expPass bool @@ -38,7 +40,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 10000), weightBalanceBonus: sdk.ZeroDec(), isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{}, expTreasuryBalance: sdk.Coins{}, expPass: false, @@ -55,7 +59,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 10000), weightBalanceBonus: sdk.ZeroDec(), isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{}, expTreasuryBalance: sdk.Coins{}, expPass: false, @@ -72,7 +78,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 9704), weightBalanceBonus: sdk.ZeroDec(), isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 990000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1009704)}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010000), sdk.NewInt64Coin(ptypes.BaseCurrency, 990198)}, expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000010)}, expPass: true, @@ -89,7 +97,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 9900), weightBalanceBonus: sdk.ZeroDec(), isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 990000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1009900)}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010000), sdk.NewInt64Coin(ptypes.BaseCurrency, 990100)}, expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, expPass: true, @@ -106,7 +116,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 9975), weightBalanceBonus: sdk.ZeroDec(), isOraclePool: true, + useNewRecipient: false, expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 990000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1009975)}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010000), sdk.NewInt64Coin(ptypes.BaseCurrency, 990025)}, expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, expPass: true, @@ -123,7 +135,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 9900), weightBalanceBonus: sdk.NewDecWithPrec(3, 1), // 30% bonus isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 990000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1009900)}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010000), sdk.NewInt64Coin(ptypes.BaseCurrency, 990100)}, expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, expPass: true, @@ -140,7 +154,28 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 9900), weightBalanceBonus: sdk.NewDecWithPrec(3, 1), // 30% bonus isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 990000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1009900)}, + expRecipientBalance: sdk.Coins{}, + expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010000), sdk.NewInt64Coin(ptypes.BaseCurrency, 990100)}, + expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 100)}, + expPass: true, + }, + { + desc: "new recipient address", + senderInitBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, + poolInitBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, + treasuryInitBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 100)}, + swapFeeIn: sdk.ZeroDec(), + swapFeeOut: sdk.ZeroDec(), + tokenIn: sdk.NewInt64Coin("uusda", 10000), + tokenOutMin: sdk.ZeroInt(), + tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 9900), + weightBalanceBonus: sdk.NewDecWithPrec(3, 1), // 30% bonus + isOraclePool: false, + useNewRecipient: true, + expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 990000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, + expRecipientBalance: sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 9900)}, expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010000), sdk.NewInt64Coin(ptypes.BaseCurrency, 990100)}, expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 100)}, expPass: true, @@ -152,8 +187,12 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { // bootstrap accounts sender := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + recipient := sender poolAddr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) treasuryAddr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + if tc.useNewRecipient { + recipient = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + } // bootstrap balances err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, tc.senderInitBalance) @@ -205,7 +244,7 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { TotalWeight: sdk.ZeroInt(), } - tokenOut, err := suite.app.AmmKeeper.SwapExactAmountIn(suite.ctx, sender, pool, tc.tokenIn, tc.tokenOut.Denom, tc.tokenOutMin, tc.swapFeeIn) + tokenOut, err := suite.app.AmmKeeper.SwapExactAmountIn(suite.ctx, sender, recipient, pool, tc.tokenIn, tc.tokenOut.Denom, tc.tokenOutMin, tc.swapFeeIn) if !tc.expPass { suite.Require().Error(err) } else { @@ -220,6 +259,12 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() { balances = suite.app.BankKeeper.GetAllBalances(suite.ctx, sender) suite.Require().Equal(balances.String(), tc.expSenderBalance.String()) + if tc.useNewRecipient { + // check balance change on recipient + balances = suite.app.BankKeeper.GetAllBalances(suite.ctx, recipient) + suite.Require().Equal(balances.String(), tc.expRecipientBalance.String()) + } + // check balance change on treasury balances = suite.app.BankKeeper.GetAllBalances(suite.ctx, treasuryAddr) suite.Require().Equal(balances.String(), tc.expTreasuryBalance.String()) diff --git a/x/amm/keeper/keeper_swap_exact_amount_out.go b/x/amm/keeper/keeper_swap_exact_amount_out.go index 86620f5f7..525f92a47 100644 --- a/x/amm/keeper/keeper_swap_exact_amount_out.go +++ b/x/amm/keeper/keeper_swap_exact_amount_out.go @@ -17,6 +17,7 @@ import ( func (k Keeper) SwapExactAmountOut( ctx sdk.Context, sender sdk.AccAddress, + recipient sdk.AccAddress, pool types.Pool, tokenInDenom string, tokenInMaxAmount math.Int, @@ -54,7 +55,7 @@ func (k Keeper) SwapExactAmountOut( return math.Int{}, sdkerrors.Wrapf(types.ErrLimitMaxAmount, "swap requires %s, which is greater than the amount %s", tokenIn, tokenInMaxAmount) } - err, _ = k.UpdatePoolForSwap(ctx, pool, sender, tokenIn, tokenOut, swapFee, sdk.ZeroDec(), weightBalanceBonus) + err, _ = k.UpdatePoolForSwap(ctx, pool, sender, recipient, tokenIn, tokenOut, swapFee, sdk.ZeroDec(), weightBalanceBonus) if err != nil { return math.Int{}, err } diff --git a/x/amm/keeper/keeper_swap_exact_amount_out_test.go b/x/amm/keeper/keeper_swap_exact_amount_out_test.go index b6dfc718d..86f33bef7 100644 --- a/x/amm/keeper/keeper_swap_exact_amount_out_test.go +++ b/x/amm/keeper/keeper_swap_exact_amount_out_test.go @@ -20,7 +20,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { tokenOut sdk.Coin weightBalanceBonus sdk.Dec isOraclePool bool + useNewRecipient bool expSenderBalance sdk.Coins + expRecipientBalance sdk.Coins expPoolBalance sdk.Coins expTreasuryBalance sdk.Coins expPass bool @@ -36,7 +38,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 10000), weightBalanceBonus: sdk.ZeroDec(), isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{}, expTreasuryBalance: sdk.Coins{}, expPass: false, @@ -52,7 +56,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 10000), weightBalanceBonus: sdk.ZeroDec(), isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{}, expTreasuryBalance: sdk.Coins{}, expPass: false, @@ -68,7 +74,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 10000), weightBalanceBonus: sdk.ZeroDec(), isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 989796), sdk.NewInt64Coin(ptypes.BaseCurrency, 1010000)}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010194), sdk.NewInt64Coin(ptypes.BaseCurrency, 989910)}, expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000010), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, expPass: true, @@ -84,7 +92,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 10000), weightBalanceBonus: sdk.ZeroDec(), isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 989898), sdk.NewInt64Coin(ptypes.BaseCurrency, 1010000)}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010102), sdk.NewInt64Coin(ptypes.BaseCurrency, 990000)}, expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, expPass: true, @@ -100,7 +110,9 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 200000), weightBalanceBonus: sdk.ZeroDec(), isOraclePool: true, + useNewRecipient: false, expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 788888), sdk.NewInt64Coin(ptypes.BaseCurrency, 1200000)}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1211112), sdk.NewInt64Coin(ptypes.BaseCurrency, 800000)}, expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, expPass: true, @@ -115,8 +127,10 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { tokenInMax: sdk.NewInt(10000000), tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 10000), isOraclePool: false, + useNewRecipient: false, weightBalanceBonus: sdk.NewDecWithPrec(3, 1), // 30% bonus expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 989898), sdk.NewInt64Coin(ptypes.BaseCurrency, 1010000)}, + expRecipientBalance: sdk.Coins{}, expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010102), sdk.NewInt64Coin(ptypes.BaseCurrency, 990000)}, expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, expPass: true, @@ -132,7 +146,27 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 10000), weightBalanceBonus: sdk.NewDecWithPrec(3, 1), // 30% bonus isOraclePool: false, + useNewRecipient: false, expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 989898), sdk.NewInt64Coin(ptypes.BaseCurrency, 1010000)}, + expRecipientBalance: sdk.Coins{}, + expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010102), sdk.NewInt64Coin(ptypes.BaseCurrency, 990000)}, + expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 100)}, + expPass: true, + }, + { + desc: "new recipient address", + senderInitBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, + poolInitBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, + treasuryInitBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 100)}, + swapFeeOut: sdk.ZeroDec(), + tokenIn: sdk.NewInt64Coin("uusda", 10102), + tokenInMax: sdk.NewInt(10000000), + tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 10000), + weightBalanceBonus: sdk.NewDecWithPrec(3, 1), // 30% bonus + isOraclePool: false, + useNewRecipient: true, + expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 989898), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)}, + expRecipientBalance: sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 10000)}, expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010102), sdk.NewInt64Coin(ptypes.BaseCurrency, 990000)}, expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 100)}, expPass: true, @@ -144,8 +178,12 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { // bootstrap accounts sender := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + recipient := sender poolAddr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) treasuryAddr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + if tc.useNewRecipient { + recipient = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + } // bootstrap balances err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, tc.senderInitBalance) @@ -197,7 +235,7 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { TotalWeight: sdk.ZeroInt(), } - tokenInAmount, err := suite.app.AmmKeeper.SwapExactAmountOut(suite.ctx, sender, pool, tc.tokenIn.Denom, tc.tokenInMax, tc.tokenOut, tc.swapFeeOut) + tokenInAmount, err := suite.app.AmmKeeper.SwapExactAmountOut(suite.ctx, sender, recipient, pool, tc.tokenIn.Denom, tc.tokenInMax, tc.tokenOut, tc.swapFeeOut) if !tc.expPass { suite.Require().Error(err) } else { @@ -212,6 +250,12 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() { balances = suite.app.BankKeeper.GetAllBalances(suite.ctx, sender) suite.Require().Equal(balances.String(), tc.expSenderBalance.String()) + if tc.useNewRecipient { + // check balance change on recipient + balances = suite.app.BankKeeper.GetAllBalances(suite.ctx, recipient) + suite.Require().Equal(balances.String(), tc.expRecipientBalance.String()) + } + // check balance change on treasury balances = suite.app.BankKeeper.GetAllBalances(suite.ctx, treasuryAddr) suite.Require().Equal(balances.String(), tc.expTreasuryBalance.String()) diff --git a/x/amm/keeper/keeper_test.go b/x/amm/keeper/keeper_test.go index 9d3902af7..f363a7da6 100644 --- a/x/amm/keeper/keeper_test.go +++ b/x/amm/keeper/keeper_test.go @@ -97,8 +97,8 @@ func SetupMockPools(k *keeper.Keeper, ctx sdk.Context) { { PoolId: 2, PoolAssets: []types.PoolAsset{ - {Token: sdk.NewCoin("denom1", sdk.NewInt(1000)), Weight: sdk.OneInt()}, {Token: sdk.NewCoin("baseCurrency", sdk.NewInt(1000)), Weight: sdk.OneInt()}, + {Token: sdk.NewCoin("denom1", sdk.NewInt(1000)), Weight: sdk.OneInt()}, }, TotalWeight: sdk.NewInt(2), PoolParams: types.PoolParams{ diff --git a/x/amm/keeper/msg_server_swap_by_denom.go b/x/amm/keeper/msg_server_swap_by_denom.go index 35960fda2..bfb595a18 100644 --- a/x/amm/keeper/msg_server_swap_by_denom.go +++ b/x/amm/keeper/msg_server_swap_by_denom.go @@ -24,7 +24,7 @@ func (k msgServer) SwapByDenom(goCtx context.Context, msg *types.MsgSwapByDenom) } baseCurrency := entry.Denom - inRoute, outRoute, _, spotPrice, err := k.CalcSwapEstimationByDenom(ctx, msg.Amount, msg.DenomIn, msg.DenomOut, baseCurrency) + inRoute, outRoute, _, spotPrice, _, _, _, err := k.CalcSwapEstimationByDenom(ctx, msg.Amount, msg.DenomIn, msg.DenomOut, baseCurrency, msg.Discount) if err != nil { return nil, err } @@ -43,9 +43,10 @@ func (k msgServer) SwapByDenom(goCtx context.Context, msg *types.MsgSwapByDenom) } res, err := k.SwapExactAmountIn( - ctx, + sdk.WrapSDKContext(ctx), &types.MsgSwapExactAmountIn{ Sender: msg.Sender, + Recipient: msg.Recipient, Routes: route, TokenIn: msg.Amount, TokenOutMinAmount: msg.MinAmount.Amount, @@ -61,7 +62,9 @@ func (k msgServer) SwapByDenom(goCtx context.Context, msg *types.MsgSwapByDenom) InRoute: inRoute, OutRoute: nil, SpotPrice: spotPrice, - Discount: msg.Discount, + SwapFee: res.SwapFee, + Discount: res.Discount, + Recipient: res.Recipient, }, nil } @@ -79,7 +82,7 @@ func (k msgServer) SwapByDenom(goCtx context.Context, msg *types.MsgSwapByDenom) } res, err := k.SwapExactAmountOut( - ctx, + sdk.WrapSDKContext(ctx), &types.MsgSwapExactAmountOut{ Sender: msg.Sender, Routes: route, @@ -97,7 +100,9 @@ func (k msgServer) SwapByDenom(goCtx context.Context, msg *types.MsgSwapByDenom) InRoute: nil, OutRoute: outRoute, SpotPrice: spotPrice, - Discount: msg.Discount, + SwapFee: res.SwapFee, + Discount: res.Discount, + Recipient: res.Recipient, }, nil } diff --git a/x/amm/keeper/msg_server_swap_exact_amount_in.go b/x/amm/keeper/msg_server_swap_exact_amount_in.go index 48bf4d733..da35ac3d7 100644 --- a/x/amm/keeper/msg_server_swap_exact_amount_in.go +++ b/x/amm/keeper/msg_server_swap_exact_amount_in.go @@ -17,9 +17,13 @@ func (k msgServer) SwapExactAmountIn(goCtx context.Context, msg *types.MsgSwapEx return nil, err } + recipient, err := sdk.AccAddressFromBech32(msg.Recipient) + if err != nil { + recipient = sender + } // Try executing the tx on cached context environment, to filter invalid transactions out cacheCtx, _ := ctx.CacheContext() - tokenOutAmount, err := k.RouteExactAmountIn(cacheCtx, sender, msg.Routes, msg.TokenIn, math.Int(msg.TokenOutMinAmount), msg.Discount) + tokenOutAmount, swapFee, discount, err := k.RouteExactAmountIn(cacheCtx, sender, recipient, msg.Routes, msg.TokenIn, math.Int(msg.TokenOutMinAmount), msg.Discount) if err != nil { return nil, err } @@ -37,5 +41,10 @@ func (k msgServer) SwapExactAmountIn(goCtx context.Context, msg *types.MsgSwapEx ), }) - return &types.MsgSwapExactAmountInResponse{TokenOutAmount: tokenOutAmount}, nil + return &types.MsgSwapExactAmountInResponse{ + TokenOutAmount: tokenOutAmount, + SwapFee: swapFee, + Discount: discount, + Recipient: recipient.String(), + }, nil } diff --git a/x/amm/keeper/msg_server_swap_exact_amount_out.go b/x/amm/keeper/msg_server_swap_exact_amount_out.go index e2ab0e9de..c96884932 100644 --- a/x/amm/keeper/msg_server_swap_exact_amount_out.go +++ b/x/amm/keeper/msg_server_swap_exact_amount_out.go @@ -14,10 +14,13 @@ func (k msgServer) SwapExactAmountOut(goCtx context.Context, msg *types.MsgSwapE if err != nil { return nil, err } - + recipient, err := sdk.AccAddressFromBech32(msg.Recipient) + if err != nil { + recipient = sender + } // Try executing the tx on cached context environment, to filter invalid transactions out cacheCtx, _ := ctx.CacheContext() - tokenInAmount, err := k.RouteExactAmountOut(cacheCtx, sender, msg.Routes, msg.TokenInMaxAmount, msg.TokenOut, msg.Discount) + tokenInAmount, swapFee, discount, err := k.RouteExactAmountOut(cacheCtx, sender, recipient, msg.Routes, msg.TokenInMaxAmount, msg.TokenOut, msg.Discount) if err != nil { return nil, err } @@ -35,5 +38,10 @@ func (k msgServer) SwapExactAmountOut(goCtx context.Context, msg *types.MsgSwapE ), }) - return &types.MsgSwapExactAmountOutResponse{TokenInAmount: tokenInAmount}, nil + return &types.MsgSwapExactAmountOutResponse{ + TokenInAmount: tokenInAmount, + SwapFee: swapFee, + Discount: discount, + Recipient: recipient.String(), + }, nil } diff --git a/x/amm/keeper/query_swap_estimation.go b/x/amm/keeper/query_swap_estimation.go index 0893d7594..5737e5ce7 100644 --- a/x/amm/keeper/query_swap_estimation.go +++ b/x/amm/keeper/query_swap_estimation.go @@ -16,13 +16,16 @@ func (k Keeper) SwapEstimation(goCtx context.Context, req *types.QuerySwapEstima ctx := sdk.UnwrapSDKContext(goCtx) - spotPrice, tokenOut, err := k.CalcInRouteSpotPrice(ctx, req.TokenIn, req.Routes) + spotPrice, tokenOut, swapFee, discount, availableLiquidity, err := k.CalcInRouteSpotPrice(ctx, req.TokenIn, req.Routes, req.Discount) if err != nil { return nil, err } return &types.QuerySwapEstimationResponse{ - SpotPrice: spotPrice, - TokenOut: tokenOut, + SpotPrice: spotPrice, + TokenOut: tokenOut, + SwapFee: swapFee, + Discount: discount, + AvailableLiquidity: availableLiquidity, }, nil } diff --git a/x/amm/keeper/query_swap_estimation_by_denom.go b/x/amm/keeper/query_swap_estimation_by_denom.go index bf797a898..7b4600e5b 100644 --- a/x/amm/keeper/query_swap_estimation_by_denom.go +++ b/x/amm/keeper/query_swap_estimation_by_denom.go @@ -27,15 +27,18 @@ func (k Keeper) SwapEstimationByDenom(goCtx context.Context, req *types.QuerySwa _ = baseCurrency - inRoute, outRoute, amount, spotPrice, err := k.CalcSwapEstimationByDenom(ctx, req.Amount, req.DenomIn, req.DenomOut, baseCurrency) + inRoute, outRoute, amount, spotPrice, swapFee, discount, availableLiquidity, err := k.CalcSwapEstimationByDenom(ctx, req.Amount, req.DenomIn, req.DenomOut, baseCurrency, req.Discount) if err != nil { return nil, err } return &types.QuerySwapEstimationByDenomResponse{ - InRoute: inRoute, - OutRoute: outRoute, - Amount: amount, - SpotPrice: spotPrice, + InRoute: inRoute, + OutRoute: outRoute, + Amount: amount, + SpotPrice: spotPrice, + SwapFee: swapFee, + Discount: discount, + AvailableLiquidity: availableLiquidity, }, nil } diff --git a/x/amm/keeper/route_exact_amount_in.go b/x/amm/keeper/route_exact_amount_in.go index 6a9166cfa..d002347a6 100644 --- a/x/amm/keeper/route_exact_amount_in.go +++ b/x/amm/keeper/route_exact_amount_in.go @@ -12,20 +12,16 @@ import ( func (k Keeper) RouteExactAmountIn( ctx sdk.Context, sender sdk.AccAddress, + recipient sdk.AccAddress, routes []types.SwapAmountInRoute, tokenIn sdk.Coin, tokenOutMinAmount math.Int, discount sdk.Dec, -) (tokenOutAmount math.Int, err error) { - var ( - isMultiHopRouted bool - routeSwapFee sdk.Dec - sumOfSwapFees sdk.Dec - ) - +) (tokenOutAmount math.Int, totalDiscountedSwapFee sdk.Dec, discountOut sdk.Dec, err error) { + isMultiHopRouted, routeSwapFee, sumOfSwapFees := false, sdk.Dec{}, sdk.Dec{} route := types.SwapAmountInRoutes(routes) if err := route.Validate(); err != nil { - return math.Int{}, err + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), err } // In this loop, we check if: @@ -42,10 +38,13 @@ func (k Keeper) RouteExactAmountIn( isMultiHopRouted = true routeSwapFee, sumOfSwapFees, err = k.getElysRoutedMultihopTotalSwapFee(ctx, route) if err != nil { - return math.Int{}, err + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), err } } + // Initialize the total discounted swap fee + totalDiscountedSwapFee = sdk.ZeroDec() + for i, route := range routes { // To prevent the multihop swap from being interrupted prematurely, we keep // the minimum expected output at a very low number until the last pool @@ -57,7 +56,7 @@ func (k Keeper) RouteExactAmountIn( // Execute the expected swap on the current routed pool pool, poolExists := k.GetPool(ctx, route.PoolId) if !poolExists { - return math.Int{}, types.ErrInvalidPoolId + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), types.ErrInvalidPoolId } // // check if pool is active, if not error @@ -74,19 +73,23 @@ func (k Keeper) RouteExactAmountIn( } // Apply discount to swap fee if applicable - swapFee, discount, err = k.ApplyDiscount(ctx, swapFee, discount, sender.String()) + swapFee, _, err = k.ApplyDiscount(ctx, swapFee, discount, sender.String()) if err != nil { - return math.Int{}, err + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), err } - tokenOutAmount, err = k.SwapExactAmountIn(ctx, sender, pool, tokenIn, route.TokenOutDenom, _outMinAmount, swapFee) + // Calculate the total discounted swap fee + totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) + + tokenOutAmount, err = k.SwapExactAmountIn(ctx, sender, recipient, pool, tokenIn, route.TokenOutDenom, _outMinAmount, swapFee) if err != nil { ctx.Logger().Error(err.Error()) - return math.Int{}, err + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), err } // Chain output of current pool as the input for the next routed pool tokenIn = sdk.NewCoin(route.TokenOutDenom, tokenOutAmount) } - return tokenOutAmount, nil + + return tokenOutAmount, totalDiscountedSwapFee, discount, nil } diff --git a/x/amm/keeper/route_exact_amount_in_test.go b/x/amm/keeper/route_exact_amount_in_test.go index 739a5d9e0..69324f9cd 100644 --- a/x/amm/keeper/route_exact_amount_in_test.go +++ b/x/amm/keeper/route_exact_amount_in_test.go @@ -177,9 +177,10 @@ func (suite *KeeperTestSuite) TestRouteExactAmountIn() { // TODO: add multiple route case // TODO: add invalid route case // TODO: add Elys token involved route case - tokenOut, err := suite.app.AmmKeeper.RouteExactAmountIn( + tokenOut, _, _, err := suite.app.AmmKeeper.RouteExactAmountIn( suite.ctx, sender, + sender, []types.SwapAmountInRoute{ { PoolId: 1, diff --git a/x/amm/keeper/route_exact_amount_out.go b/x/amm/keeper/route_exact_amount_out.go index a8b00c356..7c09808e4 100644 --- a/x/amm/keeper/route_exact_amount_out.go +++ b/x/amm/keeper/route_exact_amount_out.go @@ -14,15 +14,16 @@ import ( // Transaction succeeds if the calculated tokenInAmount of the first pool is less than the defined tokenInMaxAmount defined. func (k Keeper) RouteExactAmountOut(ctx sdk.Context, sender sdk.AccAddress, + recipient sdk.AccAddress, routes []types.SwapAmountOutRoute, tokenInMaxAmount math.Int, tokenOut sdk.Coin, discount sdk.Dec, -) (tokenInAmount math.Int, err error) { +) (tokenInAmount math.Int, totalDiscountedSwapFee sdk.Dec, discountOut sdk.Dec, err error) { isMultiHopRouted, routeSwapFee, sumOfSwapFees := false, sdk.Dec{}, sdk.Dec{} route := types.SwapAmountOutRoutes(routes) if err := route.Validate(); err != nil { - return math.Int{}, err + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), err } defer func() { @@ -44,10 +45,13 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, isMultiHopRouted = true routeSwapFee, sumOfSwapFees, err = k.getElysRoutedMultihopTotalSwapFee(ctx, route) if err != nil { - return math.Int{}, err + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), err } } + // Initialize the total discounted swap fee + totalDiscountedSwapFee = sdk.ZeroDec() + // Determine what the estimated input would be for each pool along the multi-hop route // if we determined the route is an osmo multi-hop and both routes are incentivized, // we utilize a separate function that calculates the discounted swap fees @@ -58,10 +62,10 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, insExpected, err = k.createMultihopExpectedSwapOuts(ctx, routes, tokenOut) } if err != nil { - return math.Int{}, err + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), err } if len(insExpected) == 0 { - return math.Int{}, nil + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), nil } insExpected[0] = tokenInMaxAmount @@ -81,7 +85,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, // Execute the expected swap on the current routed pool pool, poolExists := k.GetPool(ctx, route.PoolId) if !poolExists { - return math.Int{}, types.ErrInvalidPoolId + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), types.ErrInvalidPoolId } // // check if pool is active, if not error @@ -97,12 +101,15 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, // Apply discount to swap fee if applicable swapFee, discount, err = k.ApplyDiscount(ctx, swapFee, discount, sender.String()) if err != nil { - return math.Int{}, err + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), err } - _tokenInAmount, swapErr := k.SwapExactAmountOut(ctx, sender, pool, route.TokenInDenom, insExpected[i], _tokenOut, swapFee) + // Calculate the total discounted swap fee + totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) + + _tokenInAmount, swapErr := k.SwapExactAmountOut(ctx, sender, recipient, pool, route.TokenInDenom, insExpected[i], _tokenOut, swapFee) if swapErr != nil { - return math.Int{}, swapErr + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), swapErr } // Sets the final amount of tokens that need to be input into the first pool. Even though this is the final return value for the @@ -113,5 +120,5 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } } - return tokenInAmount, nil + return tokenInAmount, totalDiscountedSwapFee, discount, nil } diff --git a/x/amm/keeper/route_exact_amount_out_test.go b/x/amm/keeper/route_exact_amount_out_test.go index 4dc83d627..f85e62273 100644 --- a/x/amm/keeper/route_exact_amount_out_test.go +++ b/x/amm/keeper/route_exact_amount_out_test.go @@ -176,8 +176,8 @@ func (suite *KeeperTestSuite) TestRouteExactAmountOut() { // TODO: add multiple route case // TODO: add invalid route case // TODO: add Elys token involved route case - tokenInAmount, err := suite.app.AmmKeeper.RouteExactAmountOut( - suite.ctx, sender, []types.SwapAmountOutRoute{ + tokenInAmount, _, _, err := suite.app.AmmKeeper.RouteExactAmountOut( + suite.ctx, sender, sender, []types.SwapAmountOutRoute{ { PoolId: pool.PoolId, TokenInDenom: tc.tokenIn.Denom, diff --git a/x/amm/keeper/update_pool_for_swap.go b/x/amm/keeper/update_pool_for_swap.go index b36053cd7..7011fdd46 100644 --- a/x/amm/keeper/update_pool_for_swap.go +++ b/x/amm/keeper/update_pool_for_swap.go @@ -12,6 +12,7 @@ func (k Keeper) UpdatePoolForSwap( ctx sdk.Context, pool types.Pool, sender sdk.AccAddress, + recipient sdk.AccAddress, tokenIn sdk.Coin, tokenOut sdk.Coin, swapFeeIn sdk.Dec, @@ -50,7 +51,8 @@ func (k Keeper) UpdatePoolForSwap( } } - err = k.bankKeeper.SendCoins(ctx, poolAddr, sender, sdk.Coins{tokenOut}) + // Send coins to recipient + err = k.bankKeeper.SendCoins(ctx, poolAddr, recipient, sdk.Coins{tokenOut}) if err != nil { return err, sdk.ZeroInt() } @@ -62,7 +64,7 @@ func (k Keeper) UpdatePoolForSwap( } if swapFeeOutCoins.IsAllPositive() { rebalanceTreasury := sdk.MustAccAddressFromBech32(pool.GetRebalanceTreasury()) - err = k.bankKeeper.SendCoins(ctx, sender, rebalanceTreasury, swapFeeOutCoins) + err = k.bankKeeper.SendCoins(ctx, recipient, rebalanceTreasury, swapFeeOutCoins) if err != nil { return err, sdk.ZeroInt() } @@ -82,16 +84,16 @@ func (k Keeper) UpdatePoolForSwap( bonusTokenAmount = treasuryTokenAmount } - // send bonus tokens to sender if positive + // send bonus tokens to recipient if positive if weightBalanceBonus.IsPositive() && bonusTokenAmount.IsPositive() { bonusToken := sdk.NewCoin(tokenOut.Denom, bonusTokenAmount) - err = k.bankKeeper.SendCoins(ctx, rebalanceTreasuryAddr, sender, sdk.Coins{bonusToken}) + err = k.bankKeeper.SendCoins(ctx, rebalanceTreasuryAddr, recipient, sdk.Coins{bonusToken}) if err != nil { return err, sdk.ZeroInt() } } - types.EmitSwapEvent(ctx, sender, pool.GetPoolId(), tokensIn, tokensOut) + types.EmitSwapEvent(ctx, sender, recipient, pool.GetPoolId(), tokensIn, tokensOut) if k.hooks != nil { k.hooks.AfterSwap(ctx, sender, pool, tokensIn, tokensOut) } diff --git a/x/amm/keeper/update_pool_for_swap_test.go b/x/amm/keeper/update_pool_for_swap_test.go index 1e764ebc6..7fe29d157 100644 --- a/x/amm/keeper/update_pool_for_swap_test.go +++ b/x/amm/keeper/update_pool_for_swap_test.go @@ -173,7 +173,7 @@ func (suite *KeeperTestSuite) TestUpdatePoolForSwap() { }, TotalWeight: sdk.ZeroInt(), } - err, _ = suite.app.AmmKeeper.UpdatePoolForSwap(suite.ctx, pool, sender, tc.tokenIn, tc.tokenOut, tc.swapFeeIn, tc.swapFeeOut, tc.weightBalanceBonus) + err, _ = suite.app.AmmKeeper.UpdatePoolForSwap(suite.ctx, pool, sender, sender, tc.tokenIn, tc.tokenOut, tc.swapFeeIn, tc.swapFeeOut, tc.weightBalanceBonus) if !tc.expPass { suite.Require().Error(err) } else { diff --git a/x/amm/types/events.go b/x/amm/types/events.go index 627c535ac..59386c931 100644 --- a/x/amm/types/events.go +++ b/x/amm/types/events.go @@ -16,11 +16,12 @@ const ( AttributeKeyPoolId = "pool_id" AttributeKeyTokensIn = "tokens_in" AttributeKeyTokensOut = "tokens_out" + AttributeKeyRecipient = "recipient" ) -func EmitSwapEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) { +func EmitSwapEvent(ctx sdk.Context, sender, recipient sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) { ctx.EventManager().EmitEvents(sdk.Events{ - NewSwapEvent(sender, poolId, input, output), + NewSwapEvent(sender, recipient, poolId, input, output), }) } @@ -36,11 +37,12 @@ func EmitRemoveLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uin }) } -func NewSwapEvent(sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) sdk.Event { +func NewSwapEvent(sender, recipient sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) sdk.Event { return sdk.NewEvent( TypeEvtTokenSwapped, sdk.NewAttribute(sdk.AttributeKeyModule, AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(AttributeKeyRecipient, recipient.String()), sdk.NewAttribute(AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), sdk.NewAttribute(AttributeKeyTokensIn, input.String()), sdk.NewAttribute(AttributeKeyTokensOut, output.String()), diff --git a/x/amm/types/events_test.go b/x/amm/types/events_test.go index d3280bb65..fc06a591f 100644 --- a/x/amm/types/events_test.go +++ b/x/amm/types/events_test.go @@ -15,11 +15,12 @@ func TestEvents(t *testing.T) { input := sdk.NewCoins(sdk.NewInt64Coin("token1", 100)) output := sdk.NewCoins(sdk.NewInt64Coin("token2", 50)) - swapEvent := types.NewSwapEvent(sender, poolID, input, output) + swapEvent := types.NewSwapEvent(sender, sender, poolID, input, output) expectedSwapEvent := sdk.NewEvent( types.TypeEvtTokenSwapped, sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyRecipient, sender.String()), sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolID, 10)), sdk.NewAttribute(types.AttributeKeyTokensIn, input.String()), sdk.NewAttribute(types.AttributeKeyTokensOut, output.String()), diff --git a/x/amm/types/get_pool_asset_and_index_test.go b/x/amm/types/get_pool_asset_and_index_test.go index f9e68ae95..3214408c3 100644 --- a/x/amm/types/get_pool_asset_and_index_test.go +++ b/x/amm/types/get_pool_asset_and_index_test.go @@ -32,6 +32,12 @@ func TestPool_GetPoolAssetAndIndex(t *testing.T) { require.Equal(t, 0, index) require.Equal(t, poolAssets[0], poolAsset) + // Test case 1b: Existing PoolAsset + index, poolAsset, err = pool.GetPoolAssetAndIndex("token2") + require.NoError(t, err) + require.Equal(t, 1, index) + require.Equal(t, poolAssets[1], poolAsset) + // Test case 2: Non-existing PoolAsset nonExistingDenom := "nonExistingToken" _, _, err = pool.GetPoolAssetAndIndex(nonExistingDenom) diff --git a/x/amm/types/message_swap_by_denom.go b/x/amm/types/message_swap_by_denom.go index 8e3188587..7cd5fb1be 100644 --- a/x/amm/types/message_swap_by_denom.go +++ b/x/amm/types/message_swap_by_denom.go @@ -9,9 +9,10 @@ const TypeMsgSwapByDenom = "swap_by_denom" var _ sdk.Msg = &MsgSwapByDenom{} -func NewMsgSwapByDenom(sender string, amount sdk.Coin, minAmount sdk.Coin, maxAmount sdk.Coin, denomIn string, denomOut string, discount sdk.Dec) *MsgSwapByDenom { +func NewMsgSwapByDenom(sender, recipient string, amount sdk.Coin, minAmount sdk.Coin, maxAmount sdk.Coin, denomIn string, denomOut string, discount sdk.Dec) *MsgSwapByDenom { return &MsgSwapByDenom{ Sender: sender, + Recipient: recipient, Amount: amount, MinAmount: minAmount, MaxAmount: maxAmount, diff --git a/x/amm/types/message_swap_exact_amount_in.go b/x/amm/types/message_swap_exact_amount_in.go index 759286946..73f5fa3fc 100644 --- a/x/amm/types/message_swap_exact_amount_in.go +++ b/x/amm/types/message_swap_exact_amount_in.go @@ -10,7 +10,7 @@ const TypeMsgSwapExactAmountIn = "swap_exact_amount_in" var _ sdk.Msg = &MsgSwapExactAmountIn{} -func NewMsgSwapExactAmountIn(sender string, tokenIn sdk.Coin, tokenOutMinAmount math.Int, swapRoutePoolIds []uint64, swapRouteDenoms []string, discount sdk.Dec) *MsgSwapExactAmountIn { +func NewMsgSwapExactAmountIn(sender, recipient string, tokenIn sdk.Coin, tokenOutMinAmount math.Int, swapRoutePoolIds []uint64, swapRouteDenoms []string, discount sdk.Dec) *MsgSwapExactAmountIn { if len(swapRoutePoolIds) != len(swapRouteDenoms) { return nil // or raise an error as the input lists should have the same length } @@ -26,6 +26,7 @@ func NewMsgSwapExactAmountIn(sender string, tokenIn sdk.Coin, tokenOutMinAmount return &MsgSwapExactAmountIn{ Sender: sender, + Recipient: recipient, Routes: routes, TokenIn: tokenIn, TokenOutMinAmount: tokenOutMinAmount, diff --git a/x/amm/types/message_swap_exact_amount_out.go b/x/amm/types/message_swap_exact_amount_out.go index 84eb5889c..c4dec4279 100644 --- a/x/amm/types/message_swap_exact_amount_out.go +++ b/x/amm/types/message_swap_exact_amount_out.go @@ -10,7 +10,7 @@ const TypeMsgSwapExactAmountOut = "swap_exact_amount_out" var _ sdk.Msg = &MsgSwapExactAmountOut{} -func NewMsgSwapExactAmountOut(sender string, tokenOut sdk.Coin, tokenInMaxAmount math.Int, swapRoutePoolIds []uint64, swapRouteDenoms []string, discount sdk.Dec) *MsgSwapExactAmountOut { +func NewMsgSwapExactAmountOut(sender, recipient string, tokenOut sdk.Coin, tokenInMaxAmount math.Int, swapRoutePoolIds []uint64, swapRouteDenoms []string, discount sdk.Dec) *MsgSwapExactAmountOut { if len(swapRoutePoolIds) != len(swapRouteDenoms) { return nil // or raise an error as the input lists should have the same length } @@ -26,6 +26,7 @@ func NewMsgSwapExactAmountOut(sender string, tokenOut sdk.Coin, tokenInMaxAmount return &MsgSwapExactAmountOut{ Sender: sender, + Recipient: recipient, Routes: routes, TokenOut: tokenOut, TokenInMaxAmount: tokenInMaxAmount, diff --git a/x/amm/types/query.pb.go b/x/amm/types/query.pb.go index 3af38f9b5..a5d4bbe73 100644 --- a/x/amm/types/query.pb.go +++ b/x/amm/types/query.pb.go @@ -484,8 +484,9 @@ func (m *QueryAllDenomLiquidityResponse) GetPagination() *query.PageResponse { } type QuerySwapEstimationRequest struct { - Routes []*SwapAmountInRoute `protobuf:"bytes,1,rep,name=routes,proto3" json:"routes,omitempty"` - TokenIn types.Coin `protobuf:"bytes,2,opt,name=token_in,json=tokenIn,proto3" json:"token_in"` + Routes []*SwapAmountInRoute `protobuf:"bytes,1,rep,name=routes,proto3" json:"routes,omitempty"` + TokenIn types.Coin `protobuf:"bytes,2,opt,name=token_in,json=tokenIn,proto3" json:"token_in"` + Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` } func (m *QuerySwapEstimationRequest) Reset() { *m = QuerySwapEstimationRequest{} } @@ -536,8 +537,11 @@ func (m *QuerySwapEstimationRequest) GetTokenIn() types.Coin { } type QuerySwapEstimationResponse struct { - SpotPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=spot_price,json=spotPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"spot_price"` - TokenOut types.Coin `protobuf:"bytes,2,opt,name=token_out,json=tokenOut,proto3" json:"token_out"` + SpotPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=spot_price,json=spotPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"spot_price"` + TokenOut types.Coin `protobuf:"bytes,2,opt,name=token_out,json=tokenOut,proto3" json:"token_out"` + SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swapFee"` + Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + AvailableLiquidity types.Coin `protobuf:"bytes,5,opt,name=available_liquidity,json=availableLiquidity,proto3" json:"available_liquidity"` } func (m *QuerySwapEstimationResponse) Reset() { *m = QuerySwapEstimationResponse{} } @@ -580,6 +584,13 @@ func (m *QuerySwapEstimationResponse) GetTokenOut() types.Coin { return types.Coin{} } +func (m *QuerySwapEstimationResponse) GetAvailableLiquidity() types.Coin { + if m != nil { + return m.AvailableLiquidity + } + return types.Coin{} +} + type QuerySlippageTrackRequest struct { PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` } @@ -1037,9 +1048,10 @@ func (m *QueryOutRouteByDenomResponse) GetOutRoute() []*SwapAmountOutRoute { } type QuerySwapEstimationByDenomRequest struct { - Amount types.Coin `protobuf:"bytes,1,opt,name=amount,proto3" json:"amount"` - DenomIn string `protobuf:"bytes,2,opt,name=denom_in,json=denomIn,proto3" json:"denom_in,omitempty"` - DenomOut string `protobuf:"bytes,3,opt,name=denom_out,json=denomOut,proto3" json:"denom_out,omitempty"` + Amount types.Coin `protobuf:"bytes,1,opt,name=amount,proto3" json:"amount"` + DenomIn string `protobuf:"bytes,2,opt,name=denom_in,json=denomIn,proto3" json:"denom_in,omitempty"` + DenomOut string `protobuf:"bytes,3,opt,name=denom_out,json=denomOut,proto3" json:"denom_out,omitempty"` + Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` } func (m *QuerySwapEstimationByDenomRequest) Reset() { *m = QuerySwapEstimationByDenomRequest{} } @@ -1097,10 +1109,13 @@ func (m *QuerySwapEstimationByDenomRequest) GetDenomOut() string { } type QuerySwapEstimationByDenomResponse struct { - InRoute []*SwapAmountInRoute `protobuf:"bytes,1,rep,name=in_route,json=inRoute,proto3" json:"in_route,omitempty"` - OutRoute []*SwapAmountOutRoute `protobuf:"bytes,2,rep,name=out_route,json=outRoute,proto3" json:"out_route,omitempty"` - SpotPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=spot_price,json=spotPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"spot_price"` - Amount types.Coin `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount"` + InRoute []*SwapAmountInRoute `protobuf:"bytes,1,rep,name=in_route,json=inRoute,proto3" json:"in_route,omitempty"` + OutRoute []*SwapAmountOutRoute `protobuf:"bytes,2,rep,name=out_route,json=outRoute,proto3" json:"out_route,omitempty"` + SpotPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=spot_price,json=spotPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"spot_price"` + Amount types.Coin `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount"` + SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swapFee"` + Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + AvailableLiquidity types.Coin `protobuf:"bytes,7,opt,name=available_liquidity,json=availableLiquidity,proto3" json:"available_liquidity"` } func (m *QuerySwapEstimationByDenomResponse) Reset() { *m = QuerySwapEstimationByDenomResponse{} } @@ -1157,8 +1172,16 @@ func (m *QuerySwapEstimationByDenomResponse) GetAmount() types.Coin { return types.Coin{} } +func (m *QuerySwapEstimationByDenomResponse) GetAvailableLiquidity() types.Coin { + if m != nil { + return m.AvailableLiquidity + } + return types.Coin{} +} + type QueryAMMPriceRequest struct { - TokenIn types.Coin `protobuf:"bytes,1,opt,name=token_in,json=tokenIn,proto3" json:"token_in"` + TokenIn types.Coin `protobuf:"bytes,1,opt,name=token_in,json=tokenIn,proto3" json:"token_in"` + Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` } func (m *QueryAMMPriceRequest) Reset() { *m = QueryAMMPriceRequest{} } @@ -1232,90 +1255,96 @@ func init() { func init() { proto.RegisterFile("elys/amm/query.proto", fileDescriptor_763da04a7298bbac) } var fileDescriptor_763da04a7298bbac = []byte{ - // 1323 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x98, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0xc0, 0xb3, 0x4e, 0x62, 0xc7, 0x0f, 0x35, 0x2d, 0xd3, 0x54, 0x24, 0x4e, 0xe2, 0xd0, 0x6d, - 0xf3, 0x21, 0x20, 0xbb, 0x4d, 0x0a, 0x2d, 0x20, 0x50, 0x6b, 0xd3, 0x12, 0x22, 0x11, 0x25, 0x35, - 0xe5, 0x00, 0x08, 0x99, 0xb5, 0xbd, 0x32, 0xab, 0xac, 0x77, 0x36, 0xde, 0x31, 0xc1, 0x8a, 0x72, - 0xe9, 0x8d, 0x43, 0x25, 0xa4, 0x20, 0x2e, 0x1c, 0xb8, 0x71, 0x28, 0x37, 0xfe, 0x8a, 0x1e, 0x2b, - 0x21, 0x21, 0xc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 0x55, 0xdd, 0x1f, 0xda, 0x5f, 0xbe, 0x92, 0x19, 0x57, 0xb5, 0x30, 0xc0, 0x0f, - 0x61, 0x92, 0x85, 0x0b, 0x58, 0x88, 0x57, 0xbb, 0x09, 0xdf, 0x6d, 0x5a, 0x55, 0xd7, 0x0e, 0xaf, - 0xb2, 0xa2, 0x89, 0x54, 0x42, 0x4b, 0xcf, 0xc3, 0x42, 0xdc, 0x78, 0xc1, 0x95, 0x3d, 0x48, 0xff, - 0x06, 0x6f, 0x43, 0x7c, 0x1f, 0xfd, 0xdf, 0x81, 0x34, 0xb7, 0x24, 0x4f, 0x7c, 0x64, 0x00, 0x54, - 0xeb, 0x74, 0xed, 0xa2, 0xe5, 0x5a, 0x5e, 0x55, 0xde, 0x14, 0x32, 0x0b, 0x19, 0xab, 0x56, 0x6b, - 0xda, 0x41, 0x80, 0x9d, 0x40, 0x7e, 0x76, 0x3b, 0x44, 0xaa, 0xb7, 0x43, 0x3c, 0xc0, 0x1e, 0xd7, - 0x31, 0x83, 0x7c, 0xef, 0x41, 0xa6, 0x22, 0x96, 0x30, 0x43, 0xc3, 0x6b, 0x0b, 0xe5, 0xf5, 0x87, - 0x98, 0x78, 0xac, 0xd7, 0x62, 0x9b, 0x5f, 0x35, 0x09, 0x38, 0x07, 0x53, 0xe2, 0x6e, 0x3a, 0x9e, - 0x24, 0xe4, 0xdf, 0xdb, 0x1e, 0x99, 0x87, 0xac, 0xd8, 0x92, 0x55, 0x92, 0x2d, 0x09, 0xd9, 0xb0, - 0x08, 0x3e, 0xc7, 0x82, 0x8d, 0x5a, 0x45, 0xde, 0x5b, 0x30, 0xe5, 0x78, 0xe2, 0xb1, 0x1b, 0xe5, - 0x0e, 0x65, 0x1c, 0xf1, 0xa3, 0x63, 0x76, 0xb7, 0xc5, 0x92, 0x68, 0x15, 0x24, 0x4d, 0x45, 0x52, - 0x42, 0x49, 0x29, 0xa1, 0xe8, 0x5f, 0x60, 0x7d, 0xc4, 0xcc, 0x76, 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15, 0x50, 0xe2, 0x6c, 0x11, 0x2b, 0xa0, 0xe4, 0x59, 0x41, 0xdf, - 0xe2, 0x64, 0x05, 0x72, 0xa7, 0x0f, 0x99, 0x7c, 0xa0, 0xca, 0x95, 0x76, 0x99, 0x23, 0x21, 0x59, - 0xd9, 0xf1, 0x24, 0x64, 0xf8, 0x04, 0x1e, 0x93, 0x27, 0x1a, 0x5c, 0x8c, 0xbc, 0xf0, 0x24, 0xca, - 0x90, 0x3c, 0x58, 0xe4, 0x56, 0x86, 0x89, 0x21, 0xeb, 0x27, 0x9c, 0xb5, 0x48, 0xee, 0xf6, 0x61, - 0xed, 0x3c, 0x8a, 0x31, 0xd8, 0x90, 0xb0, 0x07, 0x9c, 0xfc, 0xae, 0xc1, 0x95, 0xc4, 0xb7, 0x99, - 0xbc, 0x39, 0xf0, 0xde, 0x45, 0xc0, 0xdf, 0x1a, 0x4d, 0x78, 0xd4, 0xeb, 0xa1, 0xde, 0xd5, 0x4e, - 0x10, 0xc5, 0xe2, 0xd3, 0xd3, 0xbc, 0xf6, 0xec, 0x34, 0xaf, 0xfd, 0x7b, 0x9a, 0xd7, 0x7e, 0x3c, - 0xcb, 0x8f, 0x3d, 0x3b, 0xcb, 0x8f, 0xfd, 0x7d, 0x96, 0x1f, 0xfb, 0x72, 0xad, 0xe7, 0xc9, 0x8e, - 0x1b, 0xfd, 0x9e, 0x9b, 0xe5, 0x0f, 0x77, 0x25, 0xcd, 0xff, 0xea, 0x71, 0xf3, 0xff, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x04, 0xed, 0xfd, 0x19, 0x35, 0x12, 0x00, 0x00, + // 1411 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x98, 0xdd, 0x6f, 0xdb, 0x54, + 0x14, 0xc0, 0xeb, 0x24, 0xcd, 0xc7, 0x41, 0xeb, 0xc6, 0x5d, 0x27, 0xda, 0x74, 0x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59, + 0x36, 0xe9, 0xe5, 0x65, 0x35, 0x19, 0xf8, 0x74, 0x80, 0x23, 0x3f, 0x01, 0x54, 0x4d, 0x00, 0xae, + 0x91, 0x95, 0xe9, 0x00, 0xc9, 0x77, 0x0a, 0xcc, 0xc9, 0x9d, 0x93, 0x9c, 0x8e, 0x39, 0x4b, 0x1d, + 0xdd, 0xcb, 0x67, 0x26, 0x48, 0x4d, 0xc9, 0x23, 0xbe, 0xd5, 0xd9, 0xd0, 0xf9, 0x23, 0x05, 0x0e, + 0x49, 0xa3, 0x0c, 0x39, 0x15, 0x77, 0x94, 0x32, 0xd9, 0x95, 0x4f, 0x8f, 0x17, 0x42, 0x98, 0xcb, + 0x02, 0xe6, 0x3c, 0xd1, 0x47, 0xc1, 0xa0, 0x56, 0x43, 0xcc, 0x4d, 0x91, 0x5a, 0x7e, 0xa4, 0xc0, + 0x91, 0xf8, 0x78, 0x46, 0x56, 0xc6, 0xf9, 0x1c, 0xce, 0x77, 0xe5, 0xd5, 0x89, 0x72, 0xd3, 0xe6, + 0x4a, 0xc2, 0x73, 0xc8, 0x43, 0x05, 0x0a, 0x38, 0x8b, 0x25, 0xae, 0x98, 0x3c, 0xea, 0x25, 0xae, + 0x58, 0x6c, 0x84, 0x53, 0xdf, 0x16, 0xae, 0x2f, 0x90, 0x73, 0x23, 0x5c, 0xe3, 0xbc, 0xa6, 0x3f, + 0xc0, 0x09, 0x71, 0x27, 0xac, 0xec, 0x5f, 0x14, 0x98, 0x93, 0xe7, 0xac, 0x44, 0x01, 0xa5, 0x0e, + 0x77, 0x89, 0x02, 0x4a, 0x1f, 0xd6, 0xd4, 0x75, 0x41, 0x56, 0x25, 0x57, 0x46, 0x90, 0x05, 0x6f, + 0xf5, 0x46, 0x73, 0xd0, 0x10, 0x48, 0x48, 0xd6, 0x30, 0xac, 0x00, 0xd2, 0x9b, 0x41, 0x76, 0xc8, + 0xaf, 0x0a, 0x1c, 0x8e, 0x8d, 0x58, 0x24, 0xce, 0x90, 0x3e, 0xd9, 0x95, 0x57, 0x26, 0x89, 0x21, + 0xeb, 0x4d, 0xc1, 0x5a, 0x23, 0x57, 0x47, 0xb0, 0x86, 0x93, 0x44, 0x02, 0xd6, 0x23, 0x8c, 0x80, + 0x93, 0xdf, 0x14, 0x38, 0x96, 0x3a, 0xd0, 0x90, 0xd7, 0xc7, 0xde, 0xbb, 0x18, 0xf8, 0x1b, 0xd3, + 0x09, 0x4f, 0x7b, 0x3d, 0xe4, 0xbb, 0x1a, 0x06, 0x51, 0xab, 0x3d, 0x7e, 0x5e, 0x51, 0x9e, 0x3c, + 0xaf, 0x28, 0xcf, 0x9e, 0x57, 0x94, 0xef, 0x77, 0x2b, 0x33, 0x4f, 0x76, 0x2b, 0x33, 0x7f, 0xed, + 0x56, 0x66, 0x3e, 0x5b, 0x8b, 0xbc, 0x24, 0x93, 0x46, 0xbf, 0x16, 0x66, 0xc5, 0xab, 0xb2, 0x99, + 0x17, 0xff, 0xaa, 0xbb, 0xf8, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x15, 0x37, 0x46, 0xea, + 0x14, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2182,6 +2211,16 @@ func (m *QuerySwapEstimationRequest) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l + { + size := m.Discount.Size() + i -= size + if _, err := m.Discount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a { size, err := m.TokenIn.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -2229,6 +2268,36 @@ func (m *QuerySwapEstimationResponse) MarshalToSizedBuffer(dAtA []byte) (int, er _ = i var l int _ = l + { + size, err := m.AvailableLiquidity.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.Discount.Size() + i -= size + if _, err := m.Discount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.SwapFee.Size() + i -= size + if _, err := m.SwapFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a { size, err := m.TokenOut.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -2611,6 +2680,16 @@ func (m *QuerySwapEstimationByDenomRequest) MarshalToSizedBuffer(dAtA []byte) (i _ = i var l int _ = l + { + size := m.Discount.Size() + i -= size + if _, err := m.Discount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 if len(m.DenomOut) > 0 { i -= len(m.DenomOut) copy(dAtA[i:], m.DenomOut) @@ -2658,6 +2737,36 @@ func (m *QuerySwapEstimationByDenomResponse) MarshalToSizedBuffer(dAtA []byte) ( _ = i var l int _ = l + { + size, err := m.AvailableLiquidity.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size := m.Discount.Size() + i -= size + if _, err := m.Discount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.SwapFee.Size() + i -= size + if _, err := m.SwapFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a { size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -2729,6 +2838,16 @@ func (m *QueryAMMPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.Discount.Size() + i -= size + if _, err := m.Discount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 { size, err := m.TokenIn.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -2898,6 +3017,8 @@ func (m *QuerySwapEstimationRequest) Size() (n int) { } l = m.TokenIn.Size() n += 1 + l + sovQuery(uint64(l)) + l = m.Discount.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -2911,6 +3032,12 @@ func (m *QuerySwapEstimationResponse) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) l = m.TokenOut.Size() n += 1 + l + sovQuery(uint64(l)) + l = m.SwapFee.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.Discount.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.AvailableLiquidity.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -3069,6 +3196,8 @@ func (m *QuerySwapEstimationByDenomRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = m.Discount.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -3094,6 +3223,12 @@ func (m *QuerySwapEstimationByDenomResponse) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) l = m.Amount.Size() n += 1 + l + sovQuery(uint64(l)) + l = m.SwapFee.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.Discount.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.AvailableLiquidity.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -3105,6 +3240,8 @@ func (m *QueryAMMPriceRequest) Size() (n int) { _ = l l = m.TokenIn.Size() n += 1 + l + sovQuery(uint64(l)) + l = m.Discount.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -4072,6 +4209,40 @@ func (m *QuerySwapEstimationRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Discount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Discount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4189,6 +4360,107 @@ func (m *QuerySwapEstimationResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SwapFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Discount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Discount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AvailableLiquidity", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AvailableLiquidity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5215,6 +5487,40 @@ func (m *QuerySwapEstimationByDenomRequest) Unmarshal(dAtA []byte) error { } m.DenomOut = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Discount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Discount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5400,6 +5706,107 @@ func (m *QuerySwapEstimationByDenomResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SwapFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Discount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Discount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AvailableLiquidity", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AvailableLiquidity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5483,6 +5890,40 @@ func (m *QueryAMMPriceRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Discount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Discount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/amm/types/tx.pb.go b/x/amm/types/tx.pb.go index bb6d309a6..dea312070 100644 --- a/x/amm/types/tx.pb.go +++ b/x/amm/types/tx.pb.go @@ -367,6 +367,7 @@ type MsgSwapExactAmountIn struct { TokenIn types.Coin `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in"` TokenOutMinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_min_amount"` Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + Recipient string `protobuf:"bytes,6,opt,name=recipient,proto3" json:"recipient,omitempty"` } func (m *MsgSwapExactAmountIn) Reset() { *m = MsgSwapExactAmountIn{} } @@ -423,9 +424,18 @@ func (m *MsgSwapExactAmountIn) GetTokenIn() types.Coin { return types.Coin{} } +func (m *MsgSwapExactAmountIn) GetRecipient() string { + if m != nil { + return m.Recipient + } + return "" +} + type MsgSwapExactAmountInResponse struct { TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount"` - Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + Recipient string `protobuf:"bytes,4,opt,name=recipient,proto3" json:"recipient,omitempty"` } func (m *MsgSwapExactAmountInResponse) Reset() { *m = MsgSwapExactAmountInResponse{} } @@ -461,12 +471,20 @@ func (m *MsgSwapExactAmountInResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSwapExactAmountInResponse proto.InternalMessageInfo +func (m *MsgSwapExactAmountInResponse) GetRecipient() string { + if m != nil { + return m.Recipient + } + return "" +} + type MsgSwapExactAmountOut struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` Routes []SwapAmountOutRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` TokenOut types.Coin `protobuf:"bytes,3,opt,name=token_out,json=tokenOut,proto3" json:"token_out"` TokenInMaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_max_amount"` Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + Recipient string `protobuf:"bytes,6,opt,name=recipient,proto3" json:"recipient,omitempty"` } func (m *MsgSwapExactAmountOut) Reset() { *m = MsgSwapExactAmountOut{} } @@ -523,9 +541,18 @@ func (m *MsgSwapExactAmountOut) GetTokenOut() types.Coin { return types.Coin{} } +func (m *MsgSwapExactAmountOut) GetRecipient() string { + if m != nil { + return m.Recipient + } + return "" +} + type MsgSwapExactAmountOutResponse struct { TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount"` - Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + Recipient string `protobuf:"bytes,4,opt,name=recipient,proto3" json:"recipient,omitempty"` } func (m *MsgSwapExactAmountOutResponse) Reset() { *m = MsgSwapExactAmountOutResponse{} } @@ -561,6 +588,13 @@ func (m *MsgSwapExactAmountOutResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSwapExactAmountOutResponse proto.InternalMessageInfo +func (m *MsgSwapExactAmountOutResponse) GetRecipient() string { + if m != nil { + return m.Recipient + } + return "" +} + type MsgFeedMultipleExternalLiquidity struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` Liquidity []ExternalLiquidity `protobuf:"bytes,2,rep,name=liquidity,proto3" json:"liquidity"` @@ -758,6 +792,7 @@ type MsgSwapByDenom struct { DenomIn string `protobuf:"bytes,5,opt,name=denom_in,json=denomIn,proto3" json:"denom_in,omitempty"` DenomOut string `protobuf:"bytes,6,opt,name=denom_out,json=denomOut,proto3" json:"denom_out,omitempty"` Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + Recipient string `protobuf:"bytes,8,opt,name=recipient,proto3" json:"recipient,omitempty"` } func (m *MsgSwapByDenom) Reset() { *m = MsgSwapByDenom{} } @@ -835,12 +870,21 @@ func (m *MsgSwapByDenom) GetDenomOut() string { return "" } +func (m *MsgSwapByDenom) GetRecipient() string { + if m != nil { + return m.Recipient + } + return "" +} + type MsgSwapByDenomResponse struct { Amount types.Coin `protobuf:"bytes,1,opt,name=amount,proto3" json:"amount"` InRoute []*SwapAmountInRoute `protobuf:"bytes,2,rep,name=in_route,json=inRoute,proto3" json:"in_route,omitempty"` OutRoute []*SwapAmountOutRoute `protobuf:"bytes,3,rep,name=out_route,json=outRoute,proto3" json:"out_route,omitempty"` SpotPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=spot_price,json=spotPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"spot_price"` - Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + Discount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=discount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"discount"` + Recipient string `protobuf:"bytes,7,opt,name=recipient,proto3" json:"recipient,omitempty"` } func (m *MsgSwapByDenomResponse) Reset() { *m = MsgSwapByDenomResponse{} } @@ -897,6 +941,13 @@ func (m *MsgSwapByDenomResponse) GetOutRoute() []*SwapAmountOutRoute { return nil } +func (m *MsgSwapByDenomResponse) GetRecipient() string { + if m != nil { + return m.Recipient + } + return "" +} + func init() { proto.RegisterType((*MsgCreatePool)(nil), "elys.amm.MsgCreatePool") proto.RegisterType((*MsgCreatePoolResponse)(nil), "elys.amm.MsgCreatePoolResponse") @@ -919,82 +970,85 @@ func init() { func init() { proto.RegisterFile("elys/amm/tx.proto", fileDescriptor_ed7ddafd861f6b7f) } var fileDescriptor_ed7ddafd861f6b7f = []byte{ - // 1191 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0x41, 0x4f, 0x1b, 0xc7, - 0x17, 0x67, 0x0d, 0x18, 0xfb, 0x39, 0x84, 0xb0, 0x40, 0x30, 0x4e, 0x30, 0xfe, 0xef, 0x5f, 0xa2, - 0x56, 0xa4, 0xac, 0x15, 0xaa, 0xb6, 0x0a, 0x8a, 0xda, 0xc6, 0x01, 0x2a, 0x47, 0xb1, 0x40, 0x1b, - 0x29, 0xaa, 0x5a, 0xb5, 0xab, 0xc5, 0x9e, 0x98, 0x15, 0xde, 0x99, 0xad, 0x67, 0xb6, 0x98, 0xf6, - 0x50, 0xa9, 0x97, 0x5e, 0x7b, 0xee, 0x57, 0xe8, 0xbd, 0x5f, 0xa0, 0x3d, 0xe4, 0x18, 0x55, 0x3d, - 0x54, 0x39, 0xd0, 0x0a, 0xd4, 0xef, 0x51, 0xcd, 0xec, 0xec, 0xac, 0x17, 0xdb, 0x60, 0x1c, 0x7a, - 0xc2, 0xfb, 0xde, 0xbc, 0xdf, 0xce, 0xfb, 0xbd, 0xdf, 0xbc, 0x37, 0x0b, 0xcc, 0xa3, 0xf6, 0x31, - 0xad, 0x38, 0x9e, 0x57, 0x61, 0x5d, 0xd3, 0xef, 0x10, 0x46, 0xf4, 0x0c, 0x37, 0x99, 0x8e, 0xe7, - 0x15, 0x16, 0x5b, 0xa4, 0x45, 0x84, 0xb1, 0xc2, 0x7f, 0x85, 0xfe, 0x42, 0xb1, 0x41, 0xa8, 0x47, - 0x68, 0x65, 0xdf, 0xa1, 0xa8, 0xf2, 0xf5, 0x83, 0x7d, 0xc4, 0x9c, 0x07, 0x95, 0x06, 0x71, 0xb1, - 0xf4, 0x2f, 0x29, 0x48, 0xdf, 0xe9, 0x38, 0x1e, 0x95, 0xe6, 0x15, 0x65, 0xa6, 0x47, 0x8e, 0x6f, - 0x77, 0x48, 0xc0, 0x90, 0x74, 0x15, 0xe2, 0x08, 0x42, 0xda, 0xf6, 0x90, 0x30, 0xe1, 0x73, 0x28, - 0x45, 0x2c, 0x74, 0x19, 0x3f, 0x69, 0x30, 0x5b, 0xa7, 0xad, 0x27, 0x1d, 0xe4, 0x30, 0xb4, 0x47, - 0x48, 0x5b, 0xbf, 0x0d, 0x69, 0x8a, 0x70, 0x13, 0x75, 0xf2, 0x5a, 0x49, 0x2b, 0x67, 0x2d, 0xf9, - 0xa4, 0xbf, 0x07, 0xb9, 0x1e, 0xe4, 0x7c, 0xaa, 0xa4, 0x95, 0x73, 0x1b, 0x8b, 0x66, 0x94, 0xa8, - 0xc9, 0x83, 0xf7, 0x84, 0xcf, 0x02, 0x5f, 0xfd, 0xd6, 0x37, 0x65, 0x98, 0x78, 0x29, 0xcd, 0x4f, - 0x96, 0x26, 0xcb, 0xb9, 0x8d, 0x85, 0x64, 0xd8, 0x63, 0xee, 0xab, 0x4e, 0xbd, 0x3a, 0x59, 0x9b, - 0x08, 0x63, 0x85, 0x81, 0x1a, 0x8f, 0x60, 0x29, 0xb1, 0x37, 0x0b, 0x51, 0x9f, 0x60, 0x8a, 0xf4, - 0xff, 0xc3, 0x8c, 0x00, 0x75, 0x9b, 0x62, 0x93, 0x53, 0x55, 0x38, 0x3d, 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x3e, 0x27, 0x0a, 0x6b, 0x43, 0x1c, 0xaa, 0x2c, 0x1f, 0x43, 0x46, 0x7d, 0x3e, 0x2c, 0x25, - 0x16, 0x47, 0xe6, 0xc2, 0xea, 0x40, 0x73, 0x2f, 0x82, 0xba, 0xcd, 0x26, 0x11, 0x22, 0xf3, 0x39, - 0x84, 0xbe, 0x2b, 0xdf, 0xe7, 0x30, 0xdf, 0x7f, 0x61, 0x2b, 0x26, 0x62, 0xfa, 0xfc, 0x85, 0xf5, - 0x8b, 0xfd, 0x0a, 0xfc, 0x4b, 0xd0, 0x07, 0x4c, 0xfc, 0xb5, 0x8b, 0xa2, 0x77, 0x03, 0x56, 0x78, - 0xe7, 0x92, 0x05, 0x0a, 0xbf, 0x06, 0xb9, 0xde, 0xb6, 0x92, 0xef, 0x8b, 0x93, 0x9e, 0x42, 0x69, - 0x98, 0x47, 0x41, 0x7d, 0x07, 0xab, 0x17, 0x0f, 0xa0, 0x7b, 0x09, 0x88, 0x0b, 0xd7, 0x16, 0x36, - 0x46, 0x5f, 0x1b, 0x6d, 0xa0, 0x5a, 0x7d, 0x75, 0x5a, 0xd4, 0x5e, 0x9f, 0x16, 0xb5, 0xbf, 0x4f, - 0x8b, 0xda, 0x8f, 0x67, 0xc5, 0x89, 0xd7, 0x67, 0xc5, 0x89, 0x3f, 0xcf, 0x8a, 0x13, 0x9f, 0x95, - 0x7b, 0x84, 0xca, 0x71, 0xef, 0x63, 0xc4, 0x8e, 0x48, 0xe7, 0x50, 0x3c, 0x54, 0xba, 0xe1, 0xbf, - 0x06, 0xb8, 0x5c, 0xf7, 0xd3, 0xe2, 0xab, 0xfb, 0xdd, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xb8, - 0x24, 0x05, 0x69, 0x33, 0x10, 0x00, 0x00, + // 1242 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcb, 0x6e, 0x23, 0x45, + 0x17, 0x4e, 0xdb, 0x8e, 0x2f, 0xc7, 0x93, 0x5b, 0x27, 0x99, 0x38, 0x9e, 0xc4, 0xf1, 0xdf, 0xbf, + 0x14, 0xac, 0x91, 0xc6, 0xd6, 0x04, 0x01, 0x9a, 0x68, 0x04, 0x8c, 0x27, 0x09, 0xf2, 0x68, 0xac, + 0x44, 0x3d, 0xd2, 0x08, 0x81, 0xc0, 0xea, 0xd8, 0x15, 0xa7, 0x14, 0x77, 0x55, 0xe3, 0x2a, 0x13, + 0x07, 0x16, 0x48, 0xb0, 0x60, 0xcb, 0x9a, 0x57, 0x00, 0xb6, 0x3c, 0x43, 0x96, 0xb3, 0x44, 0xb3, + 0x88, 0x50, 0xf2, 0x02, 0x88, 0x27, 0x40, 0x55, 0x5d, 0xdd, 0xed, 0xf6, 0x25, 0x71, 0xac, 0x08, + 0x89, 0x95, 0xbb, 0xcf, 0xa9, 0x73, 0xba, 0xce, 0xf7, 0x9d, 0x4b, 0x95, 0x61, 0x01, 0xb5, 0xce, + 0x58, 0xc9, 0xb2, 0xed, 0x12, 0xef, 0x16, 0x9d, 0x36, 0xe5, 0x54, 0x4f, 0x0a, 0x51, 0xd1, 0xb2, + 0xed, 0xec, 0x52, 0x93, 0x36, 0xa9, 0x14, 0x96, 0xc4, 0x93, 0xab, 0xcf, 0xe6, 0xea, 0x94, 0xd9, + 0x94, 0x95, 0x0e, 0x2d, 0x86, 0x4a, 0x5f, 0x3f, 0x3e, 0x44, 0xdc, 0x7a, 0x5c, 0xaa, 0x53, 0x4c, + 0x94, 0x7e, 0xd9, 0x77, 0xe9, 0x58, 0x6d, 0xcb, 0x66, 0x4a, 0xbc, 0xea, 0x8b, 0xd9, 0xa9, 0xe5, + 0xd4, 0xda, 0xb4, 0xc3, 0x91, 0x52, 0x65, 0x03, 0x0b, 0x4a, 0x5b, 0xb5, 0x11, 0x66, 0x52, 0x67, + 0x31, 0x86, 0xb8, 0xab, 0x32, 0x7e, 0xd6,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0x39, 0x2c, 0x0c, 0x9e, 0xa2, 0x73, 0x21, 0x9b, 0x01, 0x7d, + 0x76, 0xf3, 0x7a, 0xbd, 0xef, 0xfc, 0x4b, 0xd0, 0x87, 0x9c, 0x7f, 0x36, 0xae, 0xb3, 0xde, 0xef, + 0xf0, 0xec, 0x3b, 0x37, 0x2c, 0xf0, 0xfd, 0x57, 0x20, 0xdd, 0xdb, 0xdd, 0x32, 0x03, 0x76, 0x4a, + 0x93, 0xcd, 0x8f, 0xd2, 0xf8, 0xae, 0xbe, 0x83, 0xf5, 0xeb, 0xe7, 0xe0, 0xc3, 0x90, 0x8b, 0x6b, + 0xd7, 0x66, 0xb7, 0xc6, 0x5f, 0xeb, 0x6d, 0xa0, 0x5c, 0x3e, 0xbf, 0xcc, 0x69, 0x6f, 0x2e, 0x73, + 0xda, 0x9f, 0x97, 0x39, 0xed, 0xa7, 0xab, 0xdc, 0xd4, 0x9b, 0xab, 0xdc, 0xd4, 0x1f, 0x57, 0xb9, + 0xa9, 0xcf, 0x0a, 0x3d, 0x69, 0x2c, 0xfc, 0x3e, 0x22, 0x88, 0x9f, 0xd2, 0xf6, 0x89, 0x7c, 0x29, + 0x75, 0xdd, 0xff, 0x6b, 0x44, 0x32, 0x1f, 0xc6, 0xe5, 0x5f, 0x21, 0xef, 0xfe, 0x13, 0x00, 0x00, + 0xff, 0xff, 0xd6, 0x71, 0x06, 0x82, 0xc8, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1616,6 +1670,13 @@ func (m *MsgSwapExactAmountIn) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x32 + } { size := m.Discount.Size() i -= size @@ -1690,6 +1751,13 @@ func (m *MsgSwapExactAmountInResponse) MarshalToSizedBuffer(dAtA []byte) (int, e _ = i var l int _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x22 + } { size := m.Discount.Size() i -= size @@ -1699,6 +1767,16 @@ func (m *MsgSwapExactAmountInResponse) MarshalToSizedBuffer(dAtA []byte) (int, e i = encodeVarintTx(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x1a + { + size := m.SwapFee.Size() + i -= size + if _, err := m.SwapFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- dAtA[i] = 0x12 { size := m.TokenOutAmount.Size() @@ -1733,6 +1811,13 @@ func (m *MsgSwapExactAmountOut) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x32 + } { size := m.Discount.Size() i -= size @@ -1807,6 +1892,13 @@ func (m *MsgSwapExactAmountOutResponse) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x22 + } { size := m.Discount.Size() i -= size @@ -1816,6 +1908,16 @@ func (m *MsgSwapExactAmountOutResponse) MarshalToSizedBuffer(dAtA []byte) (int, i = encodeVarintTx(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x1a + { + size := m.SwapFee.Size() + i -= size + if _, err := m.SwapFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- dAtA[i] = 0x12 { size := m.TokenInAmount.Size() @@ -2009,6 +2111,13 @@ func (m *MsgSwapByDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x42 + } { size := m.Discount.Size() i -= size @@ -2093,6 +2202,13 @@ func (m *MsgSwapByDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x3a + } { size := m.Discount.Size() i -= size @@ -2102,6 +2218,16 @@ func (m *MsgSwapByDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x32 + { + size := m.SwapFee.Size() + i -= size + if _, err := m.SwapFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- dAtA[i] = 0x2a { size := m.SpotPrice.Size() @@ -2309,6 +2435,10 @@ func (m *MsgSwapExactAmountIn) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.Discount.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -2320,8 +2450,14 @@ func (m *MsgSwapExactAmountInResponse) Size() (n int) { _ = l l = m.TokenOutAmount.Size() n += 1 + l + sovTx(uint64(l)) + l = m.SwapFee.Size() + n += 1 + l + sovTx(uint64(l)) l = m.Discount.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -2347,6 +2483,10 @@ func (m *MsgSwapExactAmountOut) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.Discount.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -2358,8 +2498,14 @@ func (m *MsgSwapExactAmountOutResponse) Size() (n int) { _ = l l = m.TokenInAmount.Size() n += 1 + l + sovTx(uint64(l)) + l = m.SwapFee.Size() + n += 1 + l + sovTx(uint64(l)) l = m.Discount.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -2452,6 +2598,10 @@ func (m *MsgSwapByDenom) Size() (n int) { } l = m.Discount.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -2477,8 +2627,14 @@ func (m *MsgSwapByDenomResponse) Size() (n int) { } l = m.SpotPrice.Size() n += 1 + l + sovTx(uint64(l)) + l = m.SwapFee.Size() + n += 1 + l + sovTx(uint64(l)) l = m.Discount.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -3497,6 +3653,38 @@ func (m *MsgSwapExactAmountIn) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3582,6 +3770,40 @@ func (m *MsgSwapExactAmountInResponse) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SwapFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Discount", wireType) } @@ -3615,6 +3837,38 @@ func (m *MsgSwapExactAmountInResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3832,6 +4086,38 @@ func (m *MsgSwapExactAmountOut) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3917,6 +4203,40 @@ func (m *MsgSwapExactAmountOutResponse) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SwapFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Discount", wireType) } @@ -3950,6 +4270,38 @@ func (m *MsgSwapExactAmountOutResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4648,6 +5000,38 @@ func (m *MsgSwapByDenom) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4834,6 +5218,40 @@ func (m *MsgSwapByDenomResponse) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SwapFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Discount", wireType) } @@ -4867,6 +5285,38 @@ func (m *MsgSwapByDenomResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/incentive/keeper/keeper_fees.go b/x/incentive/keeper/keeper_fees.go index 72f64b6fa..24c50a280 100644 --- a/x/incentive/keeper/keeper_fees.go +++ b/x/incentive/keeper/keeper_fees.go @@ -86,7 +86,7 @@ func (k Keeper) CollectGasFeesToIncentiveModule(ctx sdk.Context, baseCurrency st // Settles balances between the tx sender and the pool to match the swap that was executed earlier. // Also emits a swap event and updates related liquidity metrics. - err, _ = k.amm.UpdatePoolForSwap(ctx, pool, feeCollector.GetAddress(), tokenIn, tokenOutCoin, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + err, _ = k.amm.UpdatePoolForSwap(ctx, pool, feeCollector.GetAddress(), feeCollector.GetAddress(), tokenIn, tokenOutCoin, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) if err != nil { continue } diff --git a/x/incentive/types/expected_keepers.go b/x/incentive/types/expected_keepers.go index e4f2edb52..33a214595 100644 --- a/x/incentive/types/expected_keepers.go +++ b/x/incentive/types/expected_keepers.go @@ -84,6 +84,7 @@ type AmmKeeper interface { ctx sdk.Context, pool ammtypes.Pool, sender sdk.AccAddress, + recipient sdk.AccAddress, tokenIn sdk.Coin, tokenOut sdk.Coin, swapFeeIn sdk.Dec,