Skip to content

Commit

Permalink
add print all dex function, add more example
Browse files Browse the repository at this point in the history
  • Loading branch information
ackness committed Apr 7, 2023
1 parent 34791a7 commit 8b8cc31
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Now we support dex:
- [1] [CherrySwap](https://www.cherryswap.net/)
- polygon:
- [1] [QuickSwap](https://quickswap.exchange/)
- optimism:
- [1] [Uniswap V3](https://app.uniswap.org/#/swap)

---

Expand Down Expand Up @@ -106,6 +108,14 @@ bsc = ma.chain(name="bsc")
bsc = ma.chain(chain_id=56)
print(bsc)

# use ['key'] or dot key name to access chain info
print(bsc['chain_id'])
# 56
print(bsc.name)
# Binance Smart Chain Mainnet
print(bsc.dex.pancake_v2.router_address)
# 0x10ED43C718714eb63d5aA57B78B54704E256024E

# to get some items from chain
eth_weth = ma.get('eth', 'weth')
print(eth_weth)
Expand Down
8 changes: 8 additions & 0 deletions examples/example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
bsc = ma.chain(chain_id=56)
print(bsc)

# use ['key'] or dot key name to access chain info
print(bsc['chain_id'])
# 56
print(bsc.name)
# Binance Smart Chain Mainnet
print(bsc.dex.pancake_v2.router_address)
# 0x10ED43C718714eb63d5aA57B78B54704E256024E

# to get some items from chain
eth_weth = ma.get('eth', 'weth')
print(eth_weth)
Expand Down
8 changes: 8 additions & 0 deletions many_abis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ def load_all_abis():
def load_chains():
fp = os.path.join(root_path, "utils", "chains.json")
return _load_json_file(fp)


def print_all_dex():
from .chains import CHAINS
for name, chain in CHAINS.items():
print(f"- {name}:")
for j, (d_name, dex) in enumerate(chain.dex.items()):
print(f" - [{j + 1}] [{dex.name}]({dex.website})")

0 comments on commit 8b8cc31

Please sign in to comment.