Skip to content

Commit

Permalink
Pre-release branch for Flywheel (compound-finance#40)
Browse files Browse the repository at this point in the history
This patch adds a COMP distribution mechanism to the Comptroller nicknamed the 'flywheel'. Whenever a user interacts with the protocol, the *Allowed hooks now trigger tracking of a COMP supply and borrow index, and a distribution of COMP to user's whose supply or borrow balances may have changed, proportional to the fraction of total protocol interest they have accumulated.

Tracking interest between markets is accomplished via COMP 'speeds', which are a fraction of a total COMP rate being distributed, proportional to that market's share of total borrow interest (per block, at the time of recalculation). Anyone may trigger a recalculation of speeds at any time.

Tracking interest for a user is accomplished via per-market indices which track the amount of COMP that should have been distributed to the market, given the COMP speeds, the total COMP rate, and the number of blocks that have elapsed since the last update.

This patch also adds a Dripper, which distributes Comp (or any token) to a target (Comptroller) at some fixed rate. The goal of Dripper is to be simple and immutable. Anyone can poke the Dripper at any time to move Comp to the Comptroller as per the scheduled rate. If there is not enough Comp in the Dripper, we drip as much as we can and will try to drip the complete expected sum next time.

Co-authored-by: Max Wolff <[email protected]>
Co-authored-by: Geoffrey Hayes <[email protected]>
  • Loading branch information
3 people authored May 8, 2020
1 parent a79cda9 commit a303a32
Show file tree
Hide file tree
Showing 31 changed files with 3,649 additions and 296 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ jobs:
- run:
shell: /bin/bash -eox pipefail -O globstar
name: yarn test
no_output_timeout: 30m
command: JEST_JUNIT_OUTPUT_DIR=~/junit JEST_JUNIT_OUTPUT_NAME=test-results.xml script/coverage $(circleci tests glob 'tests/**/**Test.js' | circleci tests split --split-by=timings) -- --maxWorkers=4
- save_cache:
paths:
Expand Down
4 changes: 3 additions & 1 deletion .soliumrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
],
"security/no-block-members": "off",
"security/no-inline-assembly": "off",
"security/no-low-level-calls": "off"
"security/no-low-level-calls": "off",
"security/no-tx-origin": "off",
"imports-on-top": "off"
}
}
397 changes: 334 additions & 63 deletions contracts/Comptroller.sol

Large diffs are not rendered by default.

Loading

0 comments on commit a303a32

Please sign in to comment.