Request form
Cookbook may introduce a token in the future. Share and contribute to be eligible for future airdrops.
close icon
relevant tag icon
UMA Optimistic Reward Distributor
copy icon
UMA
• version 1.0.0
Rewards
Distributor
Merkle
Utility
Audited

UMA Optimistic Reward Distributor

Audited

Allows sponsors to distribute rewards through MerkleDistributor contract secured by UMA Optimistic Oracle.

*Visit desktop site to download or deploy

Version

1.0.0

Creator

UMA

Last Publish

11/5/2022
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
createReward(uint256,uint256,uint256,uint256,bytes32) :
This function creates a reward for a sponsor. It requires the sponsor to provide a maximum reward amount, an earliest proposal timestamp, an optimistic oracle proposer bond, an optimistic oracle liveness time, a price identifier, a reward token, and custom ancillary data. The function then checks that the provided parameters are valid and within the limits set by the contract. If the parameters are valid, the reward is created and stored in the rewards array. The reward token is then transferred from the sponsor to the contract. Finally, an event is emitted to notify the sponsor that the reward has been created. (autogenerated documentation)
increaseReward(uint256,uint256) :
This function increases the maximum reward amount for a given reward index. It requires that the reward index is valid and that the funding period has not ended. It then increases the maximum reward amount and emits an event to notify of the increase. Finally, it transfers the additional reward amount from the sender to the contract address. (autogenerated documentation)
proposeDistribution(uint256,bytes32,string) :
This function allows a user to propose a distribution of a reward token to a set of recipients. The function takes in three parameters: a reward index, a Merkle root, and an IPFS hash. It then checks that the reward index is valid, that the current timestamp is greater than the earliest proposal timestamp, that no blocking proposal is in progress, and that the reward has not already been distributed. It then appends the reward index to the custom ancillary data, calculates a proposal ID, and requests a price from the Optimistic Oracle. It then sets a custom liveness time and a proposer bond, and transfers the bond to the Optimistic Oracle. Finally, it proposes a price for the reward and stores the (autogenerated documentation)
executeDistribution(bytes32) :
This function is used to execute a distribution of a reward to participants in a Merkle tree. It takes a proposal ID as an argument and retrieves the associated proposal from the proposals mapping. It then retrieves the associated reward from the rewards mapping and checks to see if the reward has already been distributed. If not, it calls the optimisticOracle contract to settle the price of the reward and get the resolved price. If the resolved price is equal to 1e18, the reward is distributed to the participants in the Merkle tree using the merkleDistributor contract. Finally, an event is emitted to indicate that the reward has been distributed. (autogenerated documentation)
syncUmaEcosystemParams() :
This function is used to synchronize the UMA ecosystem parameters with the Optimistic Oracle. It does this by calling the _getOptimisticOracle() function to retrieve the Optimistic Oracle address, and then calling the ancillaryBytesLimit() function on the Optimistic Oracle to retrieve the ancillaryBytesLimit parameter. This parameter is then stored in the ancillaryBytesLimit variable. (autogenerated documentation)
_getOptimisticOracle() :
This function is an internal view function that returns an instance of the OptimisticOracleV2Interface. It does this by using the finder contract to get the address of the OptimisticOracleV2Interface and then returning an instance of it. (autogenerated documentation)
_getIdentifierWhitelist() :
This function is an internal view function that returns an instance of the IdentifierWhitelistInterface. It does this by using the finder contract to get the address of the IdentifierWhitelistInterface and then returning an instance of it. (autogenerated documentation)
_getCollateralWhitelist() :
This function is an internal view function that returns an AddressWhitelistInterface object. It does this by using the finder contract to get the address of the CollateralWhitelist contract, which implements the AddressWhitelistInterface interface. This allows the function to access the methods and properties of the CollateralWhitelist contract. (autogenerated documentation)
_appendRewardIndex(uint256) :
This function appends a reward index to a given set of custom ancillary data. It takes in a reward index (uint256) and a set of custom ancillary data (bytes memory) as parameters, and returns a set of ancillary data (bytes memory) with the reward index appended. It does this by using the AncillaryData.appendKeyValueUint() function, which takes in the custom ancillary data, a key (in this case "rewardIndex"), and a value (the reward index) as parameters, and returns the custom ancillary data with the key-value pair appended. (autogenerated documentation)
_ancillaryDataWithinLimits() :
This function checks whether the custom ancillary data provided by the user is within the ancillary bytes limit set by the contract. It does this by using the optimisticOracle.stampAncillaryData() function to calculate the length of the ancillary data and comparing it to the ancillaryBytesLimit. If the length of the ancillary data is less than or equal to the ancillaryBytesLimit, the function returns true, otherwise it returns false. (autogenerated documentation)
_getProposalId(bytes32,uint256) :
This function is used to generate a unique identifier for a proposal. It takes three parameters: a bytes32 identifier, a uint256 timestamp, and a bytes memory ancillaryData. It then uses the abi.encode function to combine these three parameters and returns the keccak256 hash of the encoded data as the proposal identifier. This ensures that the proposal identifier is unique and can be used to identify the proposal. (autogenerated documentation)
_noBlockingProposal(uint256) :
This function is used to check if a proposal is blocked by another proposal. It takes in a reward index and a reward as parameters and returns a boolean value. It first checks if the reward has a previous proposal timestamp, and if not, it returns true. It then creates a request using the reward index, the reward's price identifier, the reward's previous proposal timestamp, and the reward's custom ancillary data. Finally, it checks if the request has a disputer or a currency address of 0, and returns the result. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i uma-reward-distributor
copy icon

Last Publish

11/5/2022

Version

1.0.0

Creator

UMA

Cookbook is free.
Any contract you deploy is yours.
Your contract is owned and controlled by you.