Skip to content

Commit a303a32

Browse files
jflatowmaxwolffhayesgm
authored
Pre-release branch for Flywheel (compound-finance#40)
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 <maxcwolff@gmail.com> Co-authored-by: Geoffrey Hayes <hayesgm@gmail.com>
1 parent a79cda9 commit a303a32

31 files changed

+3649
-296
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ jobs:
115115
- run:
116116
shell: /bin/bash -eox pipefail -O globstar
117117
name: yarn test
118+
no_output_timeout: 30m
118119
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
119120
- save_cache:
120121
paths:

.soliumrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
],
1616
"security/no-block-members": "off",
1717
"security/no-inline-assembly": "off",
18-
"security/no-low-level-calls": "off"
18+
"security/no-low-level-calls": "off",
19+
"security/no-tx-origin": "off",
20+
"imports-on-top": "off"
1921
}
2022
}

contracts/Comptroller.sol

Lines changed: 334 additions & 63 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)