This project is inspired by a project idea from Compound Grants:
Build a marketplace where delegates can offer rewards, or solicit payment, for representing COMP-holders in Compound Governance.
The project has two main features:
- The delegate deposits COMP into the Compensator contract
- The delegate sets a reward rate (in COMP/second)
- COMP holders can delegate their COMP to the delegatee's Compensator
- COMP delegator earn rewards in COMP in proportion to the reward rate and their share of the total COMP delegated to the Compensator
- Delegators can pay the delegate to vote for or against a proposal
- Delegators stake COMP for a specific option (for or against), the stake is escrowed
- After the delegate votes, the delegate earns the payment from the option they voted
- The delegators that payed for the losing option get their stake back
address[] public compensators
- a list of all Compensator contracts created by the factorymapping(address => address) public delegateeToCompensator
- a mapping of delegatees to their Compensator contracts
- Creates a Compensator contract for a delegatee
- Adds the Compensator contract to the list of compensators
- Adds the delegatee and Compensator contract to the delegateeToCompensator mapping
Proposal
- a structure representing a compound proposal, stores information related to pay for votebool active
- true if the proposal is active, false if it has been executed or defeateduint paymentFor
- the amount of COMP payed for voting for the proposaluint paymentAgainst
- the amount of COMP payed for voting against the proposaluint paymentAbstain
- the amount of COMP payed for abstaining from voting on the proposaluint outcome
- the outcome of the proposal, true if the delegatee votes for, false if against
address delegate
- the address of the delegateeuint256 rewardRate
- the reward rate in COMP/second`uint256 rewardIndex
- increases in propotion to the rewards rate and the total rewards claimeduint255 lastRewarded
- Tracks the time of the last reward claimmapping(uint => Proposal) proposals
- a mapping of proposal ids to proposals, key is a vaild COMP proposal IDmapping(address => uint) claimedRewards
- a mapping of delegators to the amount of rewards they've claimed in COMP
- Delegate deposits COMP into the Compensator contract for payment to delegators
- Delegate withdraws COMP from the Compensator contract
- Delegate sets the reward rate for delegators in COMP/second
- Register a proposal to be voted on by the delegatee
- Delegate votes on a COMP proposal
- Delegate claims their reward for voting on a proposal
- Delegator delegates COMP to the delegatee's Compensator contract
- COMP is deposited into the Compensator contract
- Delegator undelegates COMP from the delegatee's Compensator contract
- COMP is withdrawn from the Compensator contract
- Any COMP rewards are claimed on withdraw
- Delegator pays the delegatee to vote for/against a proposal
- Delegator claims their rewards in COMP
- Returns the amount of COMP rewards a delegator has earned but not claimed