Increase slippage. For me it showed correctly with slippage 10
Hi Yomoo,
Can you please paste the request here, which you are trying at your end?
async function inch() {
await Moralis.initPlugins();
const swap = await Moralis.Plugins.oneInch.swap({
chain: "bsc", // The blockchain you want to use (eth/bsc/polygon)
fromTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // The token you want to swap
toTokenAddress: "0x43a0c5eb1763a211aa3c05849a617f2ee0452767", // The token you want to receive
amount: 100000000000000,
fromAddress: "0xCE8B75302AB72FC366B62557cFcbB43f3d4bd40F", // Your wallet address
slippage: 10
});
}
In fromAddress
was my address and it popped up metamask
Hi Yomoo,
Above request is working fine with my wallet address but when I am trying for inverse option i.e. trying to swap 200 PDX to BNB it is throwing 500 error.
here is the request:
{
"chain": "bsc",
"fromTokenAddress": "0x43a0c5eb1763a211aa3c05849a617f2ee0452767",
"toTokenAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"amount": 200000000000,
"fromAddress": "omitted",
"slippage": 20,
"_ApplicationId": "C0x6JlYQmzWQ1AO9Lnr2kCDyJGVApfyUJErEGrT9",
"_ClientVersion": "js0.0.68",
"_InstallationId": "1f2476fd-514c-4f11-bc5d-86ce541dae48"
}
Also for this endpoint oneInch.hasAllowance is not behaving correctly. although I have approved the token it is giving false and sometimes true
I checked your logs. You have called hasAllowance
for different token_addresses and wallet_addresses
Iāve tried to figure out the problemā¦ but without any success. If you try to get this data from 1inch swagger you will recieve the same error, so the problem is on 1inch side. We canāt really help you with it
But it will work correctly for wbnb. I guess the problem is because of wrapping the bnb
Most likely, the 1inch wraps your bnb in one direction, but does not unwrap it:
It works for swap bnb => token because:
bnb => wbnb => token
But doesnāt work for token=> bnb because it doesnāt unwrap WBNB
So, what is the fix for above issue?
you can try to swap token to WBNB, or token to USDT to see if it works that way, usually a conversion requires more conversions in background as most of the time that liquidity pool with that specific combination of tokens may not exist.
Hi,
With slippage < 8 it is giving me below error.
{"statusCode":400,"error":"Bad Request","description":"cannot estimate","meta":[],"requestId":"69f7cb58-7f67-4d1c-9ba5-f49d16032a4c"}
With slippage 8 it is working fine.
But with other platform I am able to trade with slippage 4.5 and above.
Can you please help?
I donāt know how can I help you, you say that it works with slippage > 8, and on another platform it works with slippage 4.5, I guess that you can not try to see if the conversion cost would be really lower on one platform vs the other. Maybe the conversion cost would be similar even if the slippage would be different.
Our Plugin is using 1inch API in the backend so we canāt answer all questions how it works unfortunately
I would try joining 1inch community and ask them
Wish we could help more but itās a bit outside of Moralis, itās third party tech
Hi Ivan,
Any update?