-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Description
I'm following the sdk but it's impossible for me to make the software work.
Im using this code:
const priceRoute = await paraSwapMin.swap.getRate({
srcToken: USDT,
destToken: CAKE,
amount: srcAmount,
userAddress: wallet.address,
side: SwapSide.SELL,
options: {
otherExchangePrices: true,
}
});
console.log(priceRoute)
const { bestRoute, others } = priceRoute;
const swapExchange = bestRoute[0]?.swaps[0]?.swapExchanges[0];
console.log("Swap Exchange: " + swapExchange.exchange)
console.log("GAS USD: " + swapExchange.data.gasUSD)
const destAmountFixed = new BigNumber(priceRoute.destAmount).times(0.99).toFixed(0); //get a little lower.
const txParams = await paraSwapMin.swap.buildTx(
{
USDT,
CAKE,
srcAmount,
destAmountFixed,
priceRoute,
userAddress: wallet.address,
partner: 'sdk-test',
}
);
const transaction = {
...txParams,
gasPrice: '0x' + new BigNumber(txParams.gasPrice).toString(16),
gasLimit: '0x' + new BigNumber(5000000).toString(16),
value: '0x' + new BigNumber(txParams.value).toString(16),
};
const txResponse = await wallet.sendTransaction(transaction);
console.log(txResponse)
const receipt = await txResponse.wait()
and although it's exact like the manual (and the test) i get data: { error: 'Validation failed: "srcToken" is required' }
I tried to add the key names as well, and it bypasses this error but then later i get
reason: 'chainId address mismatch',
code: 'INVALID_ARGUMENT',
argument: 'transaction',
Don't know what is the problem.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels