Releases: GalloDaSballo/badger-onchain-rewards
V1.1 - Direct Emissions Release - Future Proof
Update for future compatibility as we work out how to deal with self-emitting vaults and such
Breaking Changes:
All "normal functions" are not for emitting vaults
Emitting functions are extra
reap
is now for non-emitting -> Default Cheap function
tear
is now for emitting vaults
Emitting Math Still Unfair, claim weekly ser or fall behind
V1 - Direct Emissions Release
RewardsManager V1 - Direct Emissions Only - Check Audit
The RewardsManager contract integrates with vaults to manage their users' rewards. Rewards can be added to the RewardsManager contract by anyone.
Those rewards can be claimed directly from the RewardsManager contract by the vault's depositors.
Rewards accumulate per epoch, each of which has a duration of one week.
Check the Audit before using this code into production.
Also fully read the readme below
Video Introduction
Notion / Overview
https://mint-salesman-909.notion.site/Badger-Rewards-Intro-58ce9b2026dc4c39a180a1c3bac47477
Miro Architecture
https://miro.com/app/board/uXjVOQU-Z8A=/?invite_link_id=120636167771
Allows to vest rewards based on time spent
Use case is deposits in a vault so that Badger Dao can move to fully onChain emissions
Code is generalized enough to allow to handle an unknown amount of rewards for an unknown amount of types of tokens
Run Tests
If you wish to run all tests use:
brownie test
For gas benchmarks:
brownie test --gas
For Coverage:
First, change DEPLOY_TIME
to be non-immutable (due to a bug from Brownie)
Then run:
brownie test --coverage
Previous Vulnerabilities
Commit: fb02070
Report: https://docs.google.com/document/d/1bO2XfwQ60wQWePihgJu6UsukimI5ygTmC1rBTMGGNp0/edit
Status: Vulnerabilities have been mitigated
Commit: 62a728
Report: https://www.hacknote.co/17c261f7d8fWbdml/17f3efe98b4HW20Y
Status: Vulnerabilities have been mitigated
Commit: 921ffa1
Report: https://docs.google.com/document/d/1l3sWKgKrp29syOj3_dX7tCozVtmpwYOIykBj1A-unVU/edit#
Status: Vulnerabilities have been mitigated
Additional Fixes:
Vault tokens being sent to this contract causes unfairness in claiming tokens as the rewards contract will receive a portion of the rewards
Solution:
Accrue the contract and calculate the totalSupply - thisContract Supply
Status: Mitigated
Potential Attack Vectors to Explore
- Can you cause the Points to be greater than TotalPoints, allowing to extract more than the rewards for one epoch for one vault?
Formatting
Install dependencies
yarn
Run Formatting Tool
yarn format
Notices
## Provably unfair math
The first release of this contract tries to handle self-emitting vaults (vaults that add themselves as rewards to depositors), however the math is provably unfair towards late claimers.
Make sure self-emitting vaults are not used (just auto-compound bruh), and if they are, make sure to claim every week.
Week is not a week
I kind of gave up on tracking a week across leap years, either way, the contract uses EPOCHS as: Set Amounts of time
, as such, while the "claiming day" will end up switching every 4 years, the time in between claims will be consistent (as it's tracked in seconds).
For those reasons, please don't send reports about the math not being once per week.
Epoch time
In a system that is lower yield, higher gas, more predictable (think fixed yield), you could re-use the contract with a SECONDS_PER_EPOCH set to a month or even more.
Negatives:
- Can claim less often
Positives:
- Each claim is "bigger" and as such the fixed cost of gas is less noticeable
B2.0-RC.0 - Post Audit Release Candidate
Features
Fair distribution of rewards
many to many rewards
Tracking of shares
Less than 700k per yearly claim (52 epochs) (500k best case)
B.2-pre.0 - Post Audit Major Mitigations - 0.2 Pre-release
TODO: Minor Mitigations (Expect a new release soonish)
B.1 - Audit Release
Release for Audit
Beta Release, with hardcoded rug function
Rug function in case we mess up.
Rest is audit code
Initial Release on FTM
Added Rug function to sweep all tokens by the Dev Multi
Ready for a test drive on Fantom
Deployed at: https://ftmscan.com/address/0xb9f9ac0ac2e21108c7335cd8751779522fc63979#code
rc.1
Better naming
Release Candidate
Allows handling of Vault emitting Vaults by removing the points the contract earned at time of claiming
Problem:
Vault tokens being sent to this contract causes unfairness in claiming tokens as the rewards contract will receive a portion of the rewards
Solution:
Accrue the contract and calculate the totalSupply - thisContract Supply
Request for Comments - 3 Post Care
Most of Care findings have been mitigated or acknowledged
https://docs.google.com/document/d/1l3sWKgKrp29syOj3_dX7tCozVtmpwYOIykBj1A-unVU/edit