a quest for accurate accounting
a set of tools to extract accurate management/performance/strategist fees from yearn harvests.
none of v2 vault releases emit a log with said fees, but their composition is useful and should be available for analysis.
you can read a detailed explanation in this blog post.
note: this project uses some aspirational apis, so it's recommended to run in a separate virtual environment.
- install
pyenv
- install python
- install poetry
- create a virtualenv
- install this project
gh repo clone banteg/yearn-fees cd yearn-fees poetry install
- install ape patches
gh repo clone banteg/ape cd ape git checkout bunny-patch pip install -e .
- if you plan to index the data, install postgres and create a db
createdb yearn-fees
index everything into postgres
yearn-fees index
show a memory layout
yearn-fees layout <version>
yearn-fees layout <tx>
compare if the two methods return the same data
yearn-fees compare <version>
yearn-fees compare <tx>
find positions when a non-memory value was seen on the stack
yearn-fees find-durations <version>
yearn-fees find-durations <tx>
- assess.py reimplements the
_assessFees
function for all vault versions 0.3.0…0.4.3. - cache.py implements a pickled + gzipped file cache as a
diskcache.Disk
. - cli.py is the
click
entrypoint to cli commands. - compare.py laces the two methods together and shows a comparison between them.
- compile_sources.py checks out all version tags from the yearn-vaults repo, compiles them with
vvm
and saves the metadata as well as versioned sources for further reference. - find_program_counters.py reads
source_map
andast
output from vyper compiler and finds the jumps occuring the function. - indexer.py loads the reports enriched with the fee split data into postgres. it also implements several interesting things like a global
rich
console running in the main process wheredask
workers can log from another process. the indexer runs in strict mode, meaning it won't save reports where the two methods don't reconcile. - memory_layout.py holds the extracted memory layout and program counters for each version, as well as provides a memory viewer tool which helps to find the program counters where certain values appear.
- models.py contains database models.
- scanner.py can search for values appearing across stack and memory, as well as show a highlighted memory layout.
- traces.py can split traces of transactions containing multiple harvests and can extract the fee values from the trace.
- types.py contains
pydantic
models for fees, fee history and minimal models for traces. it also containsAsofDict
utility which simlifies reading the fee configuration from fee history. - utils.py contains most of blockchain interacting functions, as well as opmized and cached methods to get all vaults, all reports, sample harvests, vault fee config history, and getting reports from blocks and txs.
- this gist contains a vyper patch to print memory layout