1inch price quote questions - is it same as coingecko and pancakeswap?

When I swap USDT to BNB, if I pass amount = 10, 100, 1000, the result is correct, the next results are ~10x to the previous on. But when I pass amount = 1, it is not. I expect it’s 0.00226 but it’s 0.0018. What is wrong here?

const NATIVE_ADDRESS = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
    const USDT_ADDRESS = '0x55d398326f99059ff775485246999027b3197955';
    let quote = await dex.quote({
        chain: 'bsc', // The blockchain you want to use (eth/bsc/polygon)
        fromTokenAddress: USDT_ADDRESS, // The token you want to swap
        toTokenAddress: NATIVE_ADDRESS, // The token you want to receive
        amount: Moralis.Units.Token(100, 18).toString(),
    });
    console.log(quote.toTokenAmount / 10**18);
    // result: 0.22591146855243083
    quote = await dex.quote({
        chain: 'bsc', // The blockchain you want to use (eth/bsc/polygon)
        fromTokenAddress: USDT_ADDRESS, // The token you want to swap
        toTokenAddress: NATIVE_ADDRESS, // The token you want to receive
        amount: Moralis.Units.Token(10, 18).toString(),
    });
    console.log(quote.toTokenAmount / 10**18);
    // result: 0.022609721755199524
    quote = await dex.quote({
        chain: 'bsc', // The blockchain you want to use (eth/bsc/polygon)
        fromTokenAddress: USDT_ADDRESS, // The token you want to swap
        toTokenAddress: NATIVE_ADDRESS, // The token you want to receive
        amount: Moralis.Units.Token(1, 18).toString(),
    });
    console.log(quote.toTokenAmount / 10**18);
    // result: 0.0018
1 Like

Maybe 0.0018 is the correct response, as the price will be different when you swap more tokens because of slippage?

1 Like

@metylbk You need to understand that it doesn’t work like prices on CoinGecko. It shows you real prices. This is how DEXes work, they have slippage and token price really depends on amount

I found that if I pass protocol = PANCAKESWAP_V2 to 1inch api, the result seems fine.
But I don’t know where to find this option on our docs. Could you show me that?

1inch works best if you dont pass any paramters as it gets you the best price across all exchanges

There is no “correct price” - different marketplaces have slightly different prices and different liquidity

If you want to sell $1M of a coin on a low-liquidity exchange you get a bad price, if the liquidity is high - you get better price etc

1inch analyzes all exchanges and finds the best way to buy/sell the amount of coins you ask it considering the liquidity on all exchanges for that coin

When 1inch is giving you a price - it means that it can give you that price on the markets on at least one exchange therefore the price is real.

Finally - why is the price worse for 1USDT compared to 100 USDT?

1inch is also considering the transaction fees and slippage therefore when you swap just 1 USDT - you get worse BNB price per USDT as big percentage is gonna go to fees.

If you swap 100 USDT to BNB the fee is percentage-wise non-existant so the BNB you get for each dollar is on average higher.

1 Like

Yeah, I see.
I have a issue about convert token out amount to token in amount.
1 BNB -> 430 USDT for example.
but when user input 1 BNB in the token out amount, I want to show 430 usdt in the token in amount.
So my solution is, I request a quote with 1 usdt to get x BNB. then I calculate the number of usdt to get 1 BNB (= 1 * 10**18 / x.). But the result is 555 usdt, it’s very different from 430 usdt. The reason is the bnb price for 1 usdt is wrong. The solution need to be applied on other tokens as well not USDT, may be the price of them is much smaller usdt.

thats not a good idea
The prices are very different depending on amount
you need to ask 1inch to quote the specific amounts :raised_hands:

1 Like

could Moralis 1Inch api support protocol parameter like in the 1inch API? so I can pass PANCAKESWAP_V2 to the api. it’s working for quote api now.
Actually you see in the Pancake swap, poocoin, etc, they have a feature to swap to a number of token out . For example, I just want to get 1000 USDT from my BNB. it’s an essential feature.

Moralis 1inch plugin built on 1inch API. There is no way to specify the amount of to_recieve in their API.

I’ll let you know when it’ll be added :raised_hands:

1 Like

yes, I see. Just need to add protocol in Moralis 1inch api. Thanks

1 Like