From 9b6c9d019317460efdd51f68c1900044149bbf14 Mon Sep 17 00:00:00 2001 From: DedicatedDev Date: Sun, 11 Feb 2024 19:14:35 +0200 Subject: [PATCH 1/2] feat: update slippage logic --- x/gmm/keeper/msg_server_swap.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x/gmm/keeper/msg_server_swap.go b/x/gmm/keeper/msg_server_swap.go index e9b5301e..58e830cd 100644 --- a/x/gmm/keeper/msg_server_swap.go +++ b/x/gmm/keeper/msg_server_swap.go @@ -30,8 +30,10 @@ func (k msgServer) Swap(goCtx context.Context, msg *types.MsgSwap) (*types.MsgSw return nil, err } // Calculate the absolute difference between the expected and actual token output amounts - differ := msg.TokenOut.Amount.Sub(out.Amount).Abs() - + differ := sdkmath.NewInt(0) + if out.Amount.LT(msg.TokenOut.Amount) { + differ = msg.TokenOut.Amount.Sub(out.Amount) + } // Calculate the expected slippage. Make sure msg.Slippage is in the correct unit (e.g., percentage). // Divide by 100 if msg.Slippage is a percentage. expectedDiffer := msg.TokenOut.Amount.Mul(msg.Slippage).Quo(sdkmath.NewInt(100)) From a8b5c4a726ade4433ac7c43c62a10c16d85446ff Mon Sep 17 00:00:00 2001 From: DedicatedDev Date: Sun, 11 Feb 2024 19:22:21 +0200 Subject: [PATCH 2/2] feat: fix lint issue of wasm binding module --- wasmbinding/bindings/query.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wasmbinding/bindings/query.go b/wasmbinding/bindings/query.go index 7982699a..b9990d6a 100644 --- a/wasmbinding/bindings/query.go +++ b/wasmbinding/bindings/query.go @@ -10,8 +10,7 @@ type SideQuery struct { // PoolId string `json:"pool_id"` // } -type Params struct { -} +type Params struct{} // type PoolResponse struct { // Admin string `json:"admin"`