Created
September 19, 2020 22:14
-
-
Save ElementalBrian/d94ff1459b9afe3a36ca40f07fc33afd to your computer and use it in GitHub Desktop.
python code
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
#this uses the uniswap smart contract to find the exchange rate on uniswap from one token to another | |
import requests, logging, json, os, time, sys | |
from web3 import Web3 | |
inputToken = sys.argv[1] | |
outputToken = sys.argv[2] | |
inputAmount = sys.argv[3] | |
tokens = json.load(open('abi/kyber_currencies.json', 'r'))["data"] | |
tokenarray = {} | |
for i in tokens: tokenarray[i["symbol"].lower()] = (Web3.toChecksumAddress(i["address"]), i["decimals"]) | |
#print(tokenarray) | |
web3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/4766db13619a4175aa7cf834d3eeae42')) | |
erc20abi = json.load(open('abi/erc20.json', 'r')) | |
uniswapabi= json.load(open('abi/UniswapV2Router02.json', 'r')) | |
unis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment