Skip to content

Instantly share code, notes, and snippets.

@tgreiser
Last active January 30, 2022 21:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgreiser/8fb5758e45e1c98880c8e8ab8d5e5534 to your computer and use it in GitHub Desktop.
Save tgreiser/8fb5758e45e1c98880c8e8ab8d5e5534 to your computer and use it in GitHub Desktop.
Use pytezos to check the price of FA2 tokens at quipuswap
from pytezos import pytezos
pytezos = pytezos.using(shell='mainnet')
# Enter the tokens you are interested in from fa2_token_list.py
tokens = dict(
hDAO = ('KT1QxLqukyfohPV5kPkw97Rs6cw1DDDvYgbB', 6),
WRAP = ('KT1FG63hhFtMEEEtmBSX2vuFmP87t9E7Ab4t', 8),
bDAO = ('KT1DssMzoSr8fnUUq1WxeSuHfLG4gzS7pgge', 6),
STKR = ('KT1BMEEPX7MWzwwadW3NCSZe9XGmFJ7rs7Dr', 18),
FLAME = ('KT1Q93ftAUzvfMGPwC78nX8eouL1VzmHPd4d', 6)
)
def get_price(contract_address, decimals, block_id='head'):
global pytezos
contract = pytezos.contract(contract_address)
storage = contract.using(block_id=block_id).storage()['storage']
tez_pool = float(storage['tez_pool']) / 1000000
token_pool = float(storage['token_pool']) / (10**decimals)
t_to_h = tez_pool / token_pool
return t_to_h
for ticker in tokens:
price = get_price(tokens[ticker][0], decimals=tokens[ticker][1])
print("%s %0.6f XTZ" % (ticker, price) )
# Token list from: https://github.com/ztepler/quipuswap-tezos-analysis-colab/
# tokens dict contains:
# 1. QuipuSwap token address (note that this is address of the contract
# that used to trade, not the FA2/FA1.2 token address)
# 2. Decimals used in this token
tokens = dict(
hDAO = ('KT1QxLqukyfohPV5kPkw97Rs6cw1DDDvYgbB', 6),
WRAP = ('KT1FG63hhFtMEEEtmBSX2vuFmP87t9E7Ab4t', 8),
tCow = ('KT1XQZxsG4pMgcN7q7Nu3XFihsb9mEvqBmAT', 2),
bDAO = ('KT1DssMzoSr8fnUUq1WxeSuHfLG4gzS7pgge', 6),
sDAO = ('KT1WDe2vJCDqz5euKupppQsioPcakUd45Tfo', 0),
tCowLP = ('KT1UEfXGj5Ag73qCdZTk2534SZDT7cd7J8m8', 0),
STKR = ('KT1BMEEPX7MWzwwadW3NCSZe9XGmFJ7rs7Dr', 18),
GUTS = ('KT1WYQj3HEt3sxdsV4dMLA8RKzUnYAzXgguS', 0),
Tacoz = ('KT1VfiExduEkrpM4TbsnAw9QV1VURqaRFGKs', 18),
token42 = ('KT1M5H8qkJEzhdC3ZxZ78bSxgmcddrcusbry', 0),
tSpanish = ('KT1A834QfnWremTQ4tc63s8NKbHzLJVszgxc', 0),
DeanCoin = ('KT1BAPAVXMuYz63HrF9CGM9Gu8JVYTFpYqao', 6),
tezos10x = ('KT1A4Sj8TBg4pazMkj226bAAcH6A4iCNQno4', 0),
RSAL = ('KT1PrRTVNgxkRgyqqNQvwTiVhd55dqyxXJ6n', 0),
banana = ('KT1Sd8jvepChHEHo63owNfjnqgzJEkUWSj9q', 2),
SHTz = ('KT1G7Z14RJLKbfu96Hc22bwNL67aykunAGyH', 2),
sUSD = ('KT1KFszq8UFCcWxnXuhZPUyHT9FK3gjmSKm6', 6),
ETHtz = ('KT1Evsp2yA19Whm24khvFPcwimK6UaAJu8Zo', 18),
kUSD = ('KT1K4EwTpbvYN9agJdjpyJm4ZZdhpUNKB3F6', 18),
wUSDC = ('KT1U2hs5eNdeCpHouAvQXGMzGFGJowbhjqmo', 6),
wWETH = ('KT1DuYujxrmgepwSDHtADthhKBje9BosUs1w', 18),
RITA = ('KT1L98jqwZtKUZbcPNxb3pTY7b2WXUGEzn8G', 6),
MEL = ('KT1BsDKTXBiYck85fJnoDzedyKKNtMuC9B9h', 6),
BDoge = ('KT1Th57AbgJmiZWDny6Ewqd2sx5qSxJwu8ry', 4),
wMATIC = ('KT1RsfuBee5o7GtYrdB7bzQ1M6oVgyBnxY4S', 18),
FLAME = ('KT1Q93ftAUzvfMGPwC78nX8eouL1VzmHPd4d', 6)
)
I am attesting that this GitHub handle tgreiser is linked to the Tezos account tz1cTS1WwovU7SC783xgJxZrzr151mcshmNi for tzprofiles
sig:edsigtqiqfBiN1odHLV2Ncbqf7rAxLJVykmfQHF2WfiqRA485hqD2v8k6MdBctJGXe98yeQhrwL2YkZNSjNuhKFq4jwu9Y7CbBT
@cybernetix3d
Copy link

any documentation on how to use this for a now coder ? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment