Last active
March 25, 2019 06:52
-
-
Save BlinkyStitt/0c67352ac36626fc970f9b372bd2fbbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DAI: token_address: 0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359; | |
USDC: token_address: 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 | |
ETH/DAI via Kyber best of 1 Ask = 0.006995959027496193 | |
# 1 / 0.006995959027496193 = 142.939659319 | |
# the above price of 142 DAI for 1 ETH looks correct to me | |
ETH/USDC via Kyber best of 1 Bid = 130.40041255 | |
# the above price of 130 USDC for 1 ETH looks correct to me | |
DAI: uniswap #5: uniswap_exchange_address: 0x09cabec1ead1c0ba254b09efb3ee13841712be14 | |
USDC: uniswap #61: uniswap_exchange_address: 0x97dec872013f6b5fb443861090ad931542878126 | |
DAI: token supply: 995628438949779519084337; ether_balance: 7195281868364599647872 | |
USDC: token supply: 7074154552; ether_balance: 51888450543626933168 | |
# these balances match what I see on https://uniswap.info | |
# remember that USDC uses 6 decimals and most tokens use 18 | |
# I want to calculate the price for a trade of 0.01% of the pools liquidity. I picked that somewhat arbitratily. Is there a better number to use that won't shift the price too much? | |
DAI: 0x09cabec1ead1c0ba254b09efb3ee13841712be14.getTokenToEthOutputPrice(719528186836459964) -> 99872418430386621210 | |
# 719528186836459964/99872418430386621210 = 0.007204473449 | |
ETH/DAI via Uniswap best of 2 Ask = 0.0072044734486727945 | |
# 1 / 0.007204473449 = 138.8026490873 | |
# the above price of >138 DAI for 1 ETH looks correct to me | |
DAI: 0x09cabec1ead1c0ba254b09efb3ee13841712be14.getEthToTokenOutputPrice(99562843894977951908) -> 721765443180687141 | |
# 99562843894977951908/721765443180687141 = 137.9434895861 | |
ETH/DAI via Uniswap best of 1 Bid via Uniswap 137.94348958606668 | |
# the above price of <138 DAI for 1 ETH looks correct to me | |
USDC: 0x97dec872013f6b5fb443861090ad931542878126.getTokenToEthOutputPrice(5188845054362693) -> 709616 | |
# 5188845054362693 / 709616 = 7,312,187,231.35145 | |
# 1 / 7,312,187,231.35145 = 0.000000000136758 | |
# What is going on here? I expected a price like what https://uniswap.exchange is correctly showing of ~135 | |
ETH/USDC best of 1 Ask via Uniswap = 7312187231.351452 | |
USDC: 0x97dec872013f6b5fb443861090ad931542878126.getEthToTokenOutputPrice(707415) -> 5204975577966239 | |
# How am I supposed to turn 707415 and 5204975577966239 into 130.40041255? | |
ETH/USDC via Uniswap best of 2 Bid = 130.40041255 | |
# Here my program is somehow getting the expected price of 130.40 USDC for 1 ETH. I'm not sure how though. | |
ETH/DAI via Kyber best of 2 Bid = 137.94348958606668 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to fetch the prices of USDC and DAI from both Kyber and Uniswap. For uniswap, I am trying to have the price be for 0.01% of the available liquidity. Is there a number that would make more sense?
The price of DAI looks like it is working, but for some reason it is detecting the price of USDC as 7312187231.351452.
I'll post some more verbose logs and some code sometime tomorrow