Hi,
I try to do a Swap by making a correct MsgSwapExactAmountIn,
then using swapExactAmountIn, imported with const { swapExactAmountIn } = osmosis.gamm.v1beta1.MessageComposer.withTypeUrl.
MsgSwapExactAmountIn requires a parameter tokenOutMinAmount.
I suppose this is the amount with slippage, as mentionned here : https://www.npmjs.com/package/@cosmology/core :
const tokenOutMinAmount = calculateAmountWithSlippage( buy.amount, slippage );
So, I send a tokenIn.amount"171925", and a tokenOutMinAmount "163329" (Slippage 5%).
BUT I got the error :
"failed to execute message; message index: 0: ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 token is lesser than min amount: calculated amount is lesser than min amount".
(Same if I set slippage like 90%)
My tokenIn is TORI, and my tokenOut is ATOM. So I use multihop pattern ti display the correct data to the user. The 2 correct pools are used, the fee are correctly calculated. I just have some difference token dust regarding https://frontier.osmosis.zone/. But it's likely the same expected amounts.
Independently of the point just above, I hope the SwapAmountInRoute[] given to my MsgSwapExactAmountIn are found correctly.
I make SwapAmountInRoute[] with lookupRoutesForTrade, using a Trade made from my two currencies and two amounts.
Hi, I try to do a Swap by making a correct
MsgSwapExactAmountIn
, then usingswapExactAmountIn
, imported withconst { swapExactAmountIn } = osmosis.gamm.v1beta1.MessageComposer.withTypeUrl
.MsgSwapExactAmountIn
requires a parametertokenOutMinAmount
. I suppose this is the amount with slippage, as mentionned here : https://www.npmjs.com/package/@cosmology/core :const tokenOutMinAmount = calculateAmountWithSlippage( buy.amount, slippage );
So, I send a
tokenIn.amount
"171925"
, and atokenOutMinAmount
"163329
" (Slippage 5%). BUT I got the error :"failed to execute message; message index: 0: ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 token is lesser than min amount: calculated amount is lesser than min amount"
. (Same if I set slippage like 90%)My tokenIn is TORI, and my tokenOut is ATOM. So I use multihop pattern ti display the correct data to the user. The 2 correct pools are used, the fee are correctly calculated. I just have some difference token dust regarding
https://frontier.osmosis.zone/
. But it's likely the same expected amounts.Independently of the point just above, I hope the
SwapAmountInRoute[]
given to myMsgSwapExactAmountIn
are found correctly. I makeSwapAmountInRoute[]
withlookupRoutesForTrade
, using aTrade
made from my two currencies and two amounts.No issue with direct route like OSMO->ATOM.
Why ?
Here is
MsgSwapExactAmountIn
: https://github.com/osmosis-labs/osmojs/blob/main/packages/osmojs/src/codegen/osmosis/gamm/v1beta1/tx.ts#L68 Here isswapExactAmountIn
: https://github.com/osmosis-labs/osmojs/blob/main/packages/osmojs/types/codegen/osmosis/bundle.d.ts#L188 Here islookupRoutesForTrade
:https://github.com/cosmology-tech/cosmology/blob/main/packages/core/src/utils/osmo/utils.ts#L725
Here isTrade
: https://github.com/cosmology-tech/cosmology/blob/main/packages/core/src/types.ts#L140Wdyt ? Thank you for your repo and your time.