SimplePayout
A simple payout contract that works with a SimpleProjectRegistry and a MACI Tally contract
WETH
contract IWETH WETH
WETH address
projectRegistry
contract ISimpleProjectRegistry projectRegistry
the project registry
payoutToken
address payoutToken
the payout token
tally
contract ITally tally
the tally contract
paidProjects
mapping(uint256 => bool) paidProjects
keep track of which users have already been paid
totalAmount
uint256 totalAmount
the total amount of tokens available to be paid out
totalVoiceCreditsSpent
uint256 totalVoiceCreditsSpent
the total amount of voice credits spent
paid
uint256 paid
keep track of how many users have been paid
InvalidSpentVoiceCredits
error InvalidSpentVoiceCredits()
Custom errors
ProjectAlreadyPaid
error ProjectAlreadyPaid()
InvalidProof
error InvalidProof()
NotAllProjectsPaid
error NotAllProjectsPaid()
NotEnoughEther
error NotEnoughEther()
constructor
constructor(address _projectRegistry, address _token, address _tally, uint256 _totalAmount, uint256 _totalSpent, uint256 _totalSpentSalt, uint256 _resultCommitment, uint256 _perVOSpentVoiceCreditsHash, address _weth) public payable
Create a new instance of the payout contract
Parameters
Name | Type | Description |
---|---|---|
_projectRegistry | address | the address of the project registry |
_token | address | the address of the payout token |
_tally | address | the address of the tally contract |
_totalAmount | uint256 | the total amount of tokens available to be paid out |
_totalSpent | uint256 | the total amount of voice credits spent |
_totalSpentSalt | uint256 | the salt of the spent amount |
_resultCommitment | uint256 | the commitment of the results |
_perVOSpentVoiceCreditsHash | uint256 | the hash of the spent voice credits |
_weth | address |
deposit
function deposit() external payable
Deposit the amount of tokens to the contract
This function is only callable by the owner
payout
function payout(uint256 _voteOptionIndex, uint256 _spent, uint256[][] _proof, uint256 _spentSalt, uint256 _resultsCommitment, uint256 _spentVoiceCreditsCommitment, uint8 _voteOptionTreeDepth) external
Payout the amount of tokens to the projects
Parameters
Name | Type | Description |
---|---|---|
_voteOptionIndex | uint256 | the index of the vote option |
_spent | uint256 | the amount of voice credits spent |
_proof | uint256[][] | the proof of the spent amount |
_spentSalt | uint256 | the salt of the spent amount |
_resultsCommitment | uint256 | the commitment of the results |
_spentVoiceCreditsCommitment | uint256 | the commitment of the spent voice credits |
_voteOptionTreeDepth | uint8 | the depth of the vote option tree |
collectDust
function collectDust() external
A function to collect the dust left from round downs can only be called once all projects have been paid
_handleNativeTransfer
function _handleNativeTransfer(address _dest, uint256 _amount) internal
Handle native transfers
Parameters
Name | Type | Description |
---|---|---|
_dest | address | The destination address |
_amount | uint256 | The amount to transfer |