Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Bad Result in outputAmount of Trade TOKEN for TOKEN #74

Open
alvarheras opened this issue Jul 30, 2021 · 0 comments
Open

Bad Result in outputAmount of Trade TOKEN for TOKEN #74

alvarheras opened this issue Jul 30, 2021 · 0 comments

Comments

@alvarheras
Copy link

alvarheras commented Jul 30, 2021

When I exchange in TOKEN for WETH or WHET for a TOKEN, the result obtained with trade.outputAmount always gives me the same result as in the uniswap UI.

But when I go to obtain the output price in a TOKEN TRADE for another TOKEN erc-20 I get a different result. Always lower than the one offered by the uniswap UI at the same time.

My code

        const TOKENP = new Token(ChainId.MAINNET, tokenw.hash, tokenw.decimals);
        const TOKEN_M = new Token(ChainId.MAINNET, tokenm.hash, tokenm.decimals); //
        const pair3 = await Fetcher.fetchPairData(TOKEN_M ,TOKEN_P);
        const route3 = new Route([pair3], TOKEN_P);
        let qtyToken = Math.pow(10, 18)*1;
        const tradeM = new Trade(route3, new TokenAmount( TOKEN_P, qtyToken ), TradeType.EXACT_INPUT)
        return tradeM.outputAmount.toSignificant(6); 

Shouldn't this code give me the exact data from the uniswap UI just like it happens to me when I trade with ETH?
This difference increases when the amount of the input token increases. In this case this 1 unit.

nhnhnhnhnhnhnh
nhhnnhnhnhnhnh

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

No branches or pull requests

2 participants
@alvarheras and others