Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to make it work #148

Open
PHPCreed opened this issue Mar 10, 2023 · 0 comments
Open

Impossible to make it work #148

PHPCreed opened this issue Mar 10, 2023 · 0 comments

Comments

@PHPCreed
Copy link

PHPCreed commented Mar 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant