8000 GitHub - banteg/yearn-fees: a quest for accurate fee accounting
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

banteg/yearn-fees

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yearn fees

a quest for accurate accounting

👀 click to see screenshots

$ yearn-fees index

yearn-fees index

$ yearn-fees layout

yearn-fees layout

what is this

a set of tools to extract accurate management/performance/strategist fees from yearn harvests.

why it's needed

none of v2 vault releases emit a log with said fees, but their composition is useful and should be available for analysis.

how it works

you can read a detailed explanation in this blog post.

installation

note: this project uses some aspirational apis, so it's recommended to run in a separate virtual environment.

  1. install pyenv
  2. install python
  3. install poetry
  4. create a virtualenv
  5. install this project
    gh repo clone banteg/yearn-fees
    cd yearn-fees
    poetry install
  6. install ape patches
    gh repo clone banteg/ape
    cd ape
    git checkout bunny-patch
    pip install -e .
  7. if you plan to index the data, install postgres and create a db
    createdb yearn-fees

usage

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>

module walkthrough

  • 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 and ast 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 where dask 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 contains AsofDict 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

About

a quest for accurate fee accounting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0