A TRIBE tokenomic upgrade with multi-delegation, autocompounding rewards, and reward delegation
Platform: Code4rena
Start Date: 21/04/2022
End Date: 27/04/2022
Period: 7 days
Status: Completed
Pot Size: $75,000 USDC
Participants: 45
Reporter: liveactionllama
Judge: 0xean
Id: 111
League: ETH
Auditor per page
This contest is open for one week. Representatives from Tribe will be available in the Code Arena Discord to answer any questions during the contest period.
The focus for the contest is to try and find:
Wardens should assume that governance variables are set sensibly (unless they can find a way to change the value of a governance variable, and not counting social engineering approaches for this).
The xTRIBE tokenomics upgrade combines a few features into one new governance token:
https://tribe.fei.money/t/xtribe-tokenomics-upgrade/4038
Pulling in changes:
This will clone and pull in all the libs.
Libraries used:
source: lib/xTRIBE/src/xTRIBE.sol
LoC: 150
Description: The xTRIBE token is essentially a combination of ERC20Gauges, ERC20MultiVotes, and xERC4626 with a Multicall. An important security consideration is that it combines the TRIBE voting balance with xTRIBE balance. It should not be possible to double count votes.
source: lib/flywheel-v2/src/FlywheelCore.sol
LoC: 270
Description: FlywheelCore is an accounting layer for a rewards distribution of a single token to multiple reward strategies. See the Flywheel V2 README for more details.
source: lib/flywheel-v2/src/rewards/FlywheelGaugeRewards.sol
LoC: 250
Description: FlywheelGaugeRewards is a "rewards module" for flywheel core which reads in rewards balances from the ERC20Gauges contract. The rewards are batched into cycles, which can be queued all at once or paginated to support a large number of reward tokens.
This contract is the most complex piece of the system, as it integrates FlywheelCore and ERC20Gauges with state being held in all 3 locations.
If a gauge is deprecated, it should return 0 for all future cycles until re-added. If it is currently a part of a cycle, those rewards should distribute normally.
source: lib/flywheel-v2/src/token/ERC20Gauges.sol
LoC: 600
Description: ERC20Gauges allows liquid voting on a set of gauges. The weights are allocated pro-rata and can be used for any kind of resource allocation. The main use case is reward direction, such as in FlywheelGaugeRewards and similar to Curve finance or Tokemak.
source: lib/flywheel-v2/src/token/ERC20MultiVotes.sol
LoC: 400
Description: Similar to OpenZeppelin ERC20Votes, but uses a multi-delegation algorithm where users can partially delegate to multiple addresses.
source: lib/ERC4626/src/xERC4626.sol
LoC: 100
Description: an "xToken" which autocompounds single sided rewards. Should be completely price manipulation resistant due to internal balances being used.