EatTheBlocks Forum

Uniswap JS SDK getInputAmount()

Hello everyone,
I’m trying to use the getInputAmount() pool method that is in the Uniswap JS SDK, but whenever I run this script it raises the below error:

const { ChainId, Token, WETH, Fetcher } = require('@uniswap/sdk')

const DAI = new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18)

const init = async () => {
    const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId])
    const amount = await pair.getInputAmount('1000000000000000000');

(node:128) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'equals' of undefined
    at Pair.involvesToken (/mnt/c/Users/Luka/node_modules/@uniswap/sdk/dist/sdk.cjs.development.js:790:18)
    at Pair.getInputAmount (/mnt/c/Users/Luka/node_modules/@uniswap/sdk/dist/sdk.cjs.development.js:837:11)
    at init (/mnt/c/Users/Luka/Desktop/testScripts/mainScript/TEST.js:7:31)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:128) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:128) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js 
process with a non-zero exit code.

I was able to query midPrice and executionPrice very easily with a similar script without any errors.
I would really really appreciate some help from you.

Luka, big fan! @jklepatch

If you think thats a bug of the sdk maybe better to raise on issue on their issue tracker on github