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

call revert exception - method="getAmountsOut(uint256,address[]) #13

Open
lucashenning opened this issue Sep 24, 2020 · 8 comments
Open

Comments

@lucashenning
Copy link

First off, thanks for this great helper library! It saves a ton of time and effort when it comes to interacting with the uniswap sdk. I'm trying to swap from USDC to DAI on ropsten and everything is working fine when I submit the transaction manually, however, I'm getting a contract call error from the getAmountsOut() function in the uniswap contract.

swapTokens(
        signer, // ethers signer
        inputAddr, // input token address
        outputAddr, // output token address
        amount, // ammount to buy or sell with decimals
        true, // true if amount is input token, false if amount is output token
        {
          //recipient: '', // optional recipient address (default to signer)
          //maxSlippage: 100, // optional frontrunning tolerance (default to 100 basis points)
          //maxDelay: 60 * 2, // optional max settlement time in seconds (default to 2 minutes)
        },
    )

Here are the addresses that I'm using:

const USDC = '0x0D9C8723B343A8368BebE0B5E89273fF8D712e3C'; // USDC Address
const DAI = '0xad6d458402f60fd3bd25163575031acdce07538d';
const amount = '1.0';

This is the error:

Error: call revert exception (method="getAmountsOut(uint256,address[])", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.5)
    at Logger.makeError (/Users/lucas/Desktop/SukuLab/twilio-suku/node_modules/@ethersproject/logger/lib/index.js:179:21)
    at Logger.throwError (/Users/lucas/Desktop/SukuLab/twilio-suku/node_modules/@ethersproject/logger/lib/index.js:188:20)
    at Interface.decodeFunctionResult (/Users/lucas/Desktop/SukuLab/twilio-suku/node_modules/@ethersproject/abi/lib/interface.js:286:23)
    at Contract.<anonymous> (/Users/lucas/Desktop/SukuLab/twilio-suku/node_modules/@ethersproject/contracts/lib/index.js:300:56)
    at step (/Users/lucas/Desktop/SukuLab/twilio-suku/node_modules/@ethersproject/contracts/lib/index.js:46:23)
    at Object.next (/Users/lucas/Desktop/SukuLab/twilio-suku/node_modules/@ethersproject/contracts/lib/index.js:27:53)
    at fulfilled (/Users/lucas/Desktop/SukuLab/twilio-suku/node_modules/@ethersproject/contracts/lib/index.js:18:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Seems like the getAmountsOut() function in the uniswap contract is throwing. Any idea what might be causing this issue?

@thegostep
Copy link
Owner

Here are the addresses that I'm using:

@lucashenning which network are you targeting?

Here are the mainnet addresses for the tokens you mentioned:

@lucashenning
Copy link
Author

Hi @thegostep,

Sorry I forgot to mention I'm using ropsten. The swap works in the uniswap UI (on ropsten with the addresses that I posted).

@thegostep
Copy link
Owner

@lucashenning

ah - there is no uniswap pair contract deployed for USDC-DAI on ropsten

you can see here: https://ropsten.etherscan.io/address/0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f#readContract

you will need to deploy the pair and add liquidity for the the system to work

lmk if you have any other qs

@lucashenning
Copy link
Author

Hm, interesting... I see what you mean, getPair() returns 0x00000...

The two addresses that I posted do work in the UI, though. Here's a successful ropsten tx using those addresses: https://ropsten.etherscan.io/tx/0xb77126b28ca32855f467a086b54818c35fa21859dad8b7a33a49dcdd2dd540d4

I'm using these addresses (works in the UI but not in the code):

const uniSwapRouterAddress = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'; 
const USDC = '0x0D9C8723B343A8368BebE0B5E89273fF8D712e3C'; // USDC Address
const DAI = '0xad6d458402f60fd3bd25163575031acdce07538d';

I must be missing something. Any ideas?

@thegostep
Copy link
Owner

The package does not currently support routing through a third token

@lucashenning
Copy link
Author

Thank you! That makes a ton of sense!

Any plans on adding this feature?

@thegostep
Copy link
Owner

definitely - the hold up is that there is no easy way to calculate routes, it requires some kind of path finding algo using the liquidity in each pool - lots of calls!

@sentiasa
Copy link

@thegostep can you please explain your idea on the path finding algo? Why did you say "using liquidity in each pool" instead of just getting the price?

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

3 participants