Skip to content

Reinis-FRP/defi-tracking

Repository files navigation

DeFi tracking scripts in Python

Install dependencies

Install virtual Python environment builder, e.g. on OpenBSD:

doas pkg_add git py3-virtualenv

Setup virtual environment:

cd defi-tracking/
virtualenv venv
. venv/bin/activate
pip install web3 python-dotenv

Configure API keys

Set ETHERSCAN_KEY and ETH_NODE_API variables in .env file

Scripts

twap.py calculates TWAP for Uniswap/Sushiswap pools. This requires access to Ethereum archive node (e.g. Alchemy)

compound_repay.py calculates expected Compound borrow balance in future. Useful when planning to repay only interest amount and keep principal balance fixed.

exit_pool.py estimates exit results from UMA LM pools on Balancer. User can provide expected price-id at expiration, synth price in the pool at exit, and relative size of pool at exit. If config_exit_pool.json is provided, expected settlement price is assumed the same as current price from Coingecko (if available for specific price-id). The script outputs expected results for user either

  • closing position before expiration and rebalancing excess/deficit synth tokens from the pool or
  • waiting for expiration, withdrawing both pairs from the pool and calling settleExpired on the EMP contract

track_uma.py fetches all deployed contracts and their parameters from UMA protocol on-chain data. Use -t option to fetch historical collateral and synths balances. The script uses cache.json file as a cache, thus need to set -o option to overwrite the cache and fetch correct balances. Also contracts.csv is saved in table format for human readability.

TODO:

  • optimize fetching all parameters from create transaction

block_timestamp.py converts timestamp to latest block number and vice versa.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages