Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unexpected Results for get_price_input?? #195

Unanswered
hueit-og asked this question in Q&A
Discussion options

Quick question - I noticed that when using get_price_input I get unexpected results for the token CHESS (BSC token).

For example, when I run the code I get the following results -

  • if the token amount is 1BNB the output amount is 186 CHESS tokens.
  • if the token amount is 10BNB the output amount is 727 CHESS tokens.

However, when I check via the PancakeSwap website I get the following results

  • 1BNB = 225 CHESS tokens
  • 10BNB = 2240 CHESS tokens

I'm not sure it's related to the code and could potentially be related to available liquidity. However I can't explain the difference between the get_price_input amounts and the PancakeSwap website.

I've only so far noticed this with CHESS, other BSC tokens I've tested are within tolerance (e.g. get_price_input is typically the very close to the PancakeSwap website).

Any insights appreciated.

You must be logged in to vote

Replies: 2 comments · 1 reply

Comment options

There's a difference between BNB (0x0) and WBNB (some address). In any case, the discrepancy is most likely due to the different routes (but check with a debugger). AFAIK the low level quote mechanism works as follows:

  1. Check the pair contract for reserves getReserves()
  2. Use the UniswapV2 (Pancake in this case) library's getAmountOut() with the reserves and input amount.
You must be logged in to vote
0 replies
Comment options

I guess that it's because the quote is produced by doing token0->BNB->token1:
https://github.com/uniswap-python/uniswap-python/blob/master/uniswap/uniswap.py#L263
When a direct pair exists, the route should be [token0, token1]
You can provide this route to the function and check the results.

You must be logged in to vote
1 reply
@hueit-og
Comment options

Hey Roman

Thanks for taking the time to review and reply. I must admit my initial thought was something along those lines too, however that line of code is never executed.

When using BSC, the self.get_weth_address() will actually resolve to WBNB and not weth, therefore the IF condition at L258 will be true and it will execute line 259 to get the token amount.

Eiterhway, I don't think that routing would explain why this only seems to be a problem with CHESS (at least with to the extent that I've tested it).

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.