Fixed decimal issues with ADA, BNB and AVAX.

This commit is contained in:
Geoff Taylor 2021-12-15 18:15:26 +00:00
parent 76ba4b8c64
commit c6900afebf
3 changed files with 56 additions and 4 deletions

26
bin/show-group-prices Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python3
import argparse
import os
import os.path
import sys
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.dirname(__file__), "..")))
import mango # nopep8
parser = argparse.ArgumentParser(description="Shows the on-chain data of a Mango Markets Group.")
mango.ContextBuilder.add_command_line_parameters(parser)
args: argparse.Namespace = mango.parse_args(parser)
context = mango.ContextBuilder.from_command_line_parameters(args)
group = mango.Group.load(context)
cache = group.fetch_cache(context)
mango.output("Group cached oracle prices:")
for slot in group.slots:
if slot.base_instrument is not None:
price = group.token_price_from_cache(cache, slot.base_instrument)
price_formatted = f"{price.value:,.8f}"
mango.output(f"{slot.base_instrument.symbol:<6}: {price_formatted:>18} {group.shared_quote_token.symbol}")

View File

@ -24,6 +24,32 @@
"coingeckoId": "cardano",
"website": "https://cardano.org/"
}
},
{
"chainId": 101,
"symbol": "AVAX",
"name": "Avalanche",
"decimals": 8,
"tags": [
"no-solana-coin"
],
"extensions": {
"coingeckoId": "avalanche",
"website": "https://avax.network/"
}
},
{
"chainId": 101,
"symbol": "BNB",
"name": "Binance Coin",
"decimals": 8,
"tags": [
"no-solana-coin"
],
"extensions": {
"coingeckoId": "binance-coin",
"website": "https://www.binance.com/"
}
}
],
"version": {

View File

@ -267,8 +267,8 @@ class ContextBuilder:
instrument_lookup = CompoundInstrumentLookup([
ids_json_token_lookup,
mainnet_overrides_token_lookup,
mainnet_spl_token_lookup,
mainnet_non_spl_instrument_lookup])
mainnet_non_spl_instrument_lookup,
mainnet_spl_token_lookup])
elif actual_cluster == "devnet":
devnet_overrides_token_lookup: InstrumentLookup = SPLTokenLookup.load(devnet_overrides_filename)
devnet_token_filename = token_filename.rsplit('.', 1)[0] + ".devnet.json"
@ -278,8 +278,8 @@ class ContextBuilder:
instrument_lookup = CompoundInstrumentLookup([
ids_json_token_lookup,
devnet_overrides_token_lookup,
devnet_spl_token_lookup,
devnet_non_spl_instrument_lookup])
devnet_non_spl_instrument_lookup,
devnet_spl_token_lookup])
ids_json_market_lookup: MarketLookup = IdsJsonMarketLookup(actual_cluster, instrument_lookup)
all_market_lookup = ids_json_market_lookup