1inch plugin issues

Hi Moralis team!

Me and my team are working on integrating the Moralis 1inch plugin inside our dapp.

We are using React and started with your boilerplate example. We are using the correct chains and the getQuote from 1inch is working - meaning it is giving us the correct price from one asset to the other. We can also correctly see the token list dropdown changing upon changing the selected chain (eth, polygon).

The problem comes in when we try to run the trySwap function (which approves and does the swap). The errors we are currently getting are the following:

{statusCode: 400, error: ‘Bad Request’, description: ‘insufficient liquidity’, meta: Array(1), requestId: ‘4abff805-f5ba-4cf7-895d-add2254e5890’} description: “insufficient liquidity” error: “Bad Request” meta: [{…}] requestId: “4abff805-f5ba-4cf7-895d-add2254e5890” statusCode: 400 [[Prototype]]: Object
[This first error we are getting it when trying to swap 1 Matic for 1 USDC on the Matic chain. Please note that we are testing on the MainNet and we have enough to pay the gas price]

  1. [10:59 PM]
    {statusCode: 400, error: ‘Bad Request’, description: ‘amount should be a number string’, meta: Array(1), requestId: ‘36c6d5ee-f169-4e3d-8562-db561f78ec85’} description: “amount should be a number string” error: “Bad Request” meta: [{…}] requestId: “36c6d5ee-f169-4e3d-8562-db561f78ec85” statusCode: 400 [[Prototype]]: Object
    [This second error we are getting when we are passing 0.3 Matic for the from token in the swap - meaning a float number]

Any guide/reading material or help will be appreciated. If needed i can copy paste the code here.
Thanks!! <3

Maybe you have to provide those numbers in WEI

Hi, thanks for your reply!

This is how we are getting the numbers.

const amount = Moralis.Units.Token(
fromAmount,
fromMulti.decimals
).toString();

what does that fromMulti.decimals do?

The code is copy from the Ethereum boilerplate done by Moralis. We only changed the fromToken to fromMulti. I’m guessing from the boilerplate that fromMulti.decimals (which in reality is fromToken.decimals) gets the decimals of the token ( in this case 18 as Matic has 18 decimals)

Thanks!

Hey mate, got anything on this?

Can you try to increase the slippage?