Skip to main content

OptimisticDistributor

OptimisticDistributor#

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

Functions#

constructor(contract FinderInterface _finder, contract IERC20 _bondToken, address _timer, uint256 _maximumFundingPeriod, uint256 _maximumProposerBond) (public)

Constructor.

Parameters:#

  • _finder: Finder to look up UMA contract addresses.
  • _bondToken: ERC20 token that the bond is paid in.
  • _timer: Contract that stores the current time in a testing environment.
  • _maximumFundingPeriod: Maximum period for reward funding (proposals allowed only afterwards).
  • _maximumProposerBond: Maximum allowed Optimistic Oracle proposer bond amount.
createReward(uint256 maximumRewardAmount, uint256 earliestProposalTimestamp, uint256 optimisticOracleProposerBond, uint256 optimisticOracleLivenessTime, bytes32 priceIdentifier, contract IERC20 rewardToken, bytes customAncillaryData) (external)

Allows any caller to create a Reward struct and deposit tokens that are linked to these rewards.

The caller must approve this contract to transfer maximumRewardAmount amount of rewardToken.

Parameters:#

  • rewardToken: ERC20 token that the rewards will be paid in.
  • maximumRewardAmount: Maximum reward amount that the sponsor is posting for distribution.
  • earliestProposalTimestamp: Starting timestamp when proposals for distribution can be made.
  • priceIdentifier: Identifier that should be passed to the Optimistic Oracle on proposed distribution.
  • customAncillaryData: Custom ancillary data that should be sent to the Optimistic Oracle on proposed distribution.
  • optimisticOracleProposerBond: Amount of bondToken that should be posted in addition to final fee to the Optimistic Oracle on proposed distribution.
  • optimisticOracleLivenessTime: Liveness period in seconds during which proposed distribution can be disputed through Optimistic Oracle.
increaseReward(uint256 rewardIndex, uint256 additionalRewardAmount) (external)

Allows anyone to deposit additional rewards for distribution before earliestProposalTimestamp.

The caller must approve this contract to transfer additionalRewardAmount amount of rewardToken.

Parameters:#

  • rewardIndex: Index for identifying existing Reward struct that should receive additional funding.
  • additionalRewardAmount: Additional reward amount that the sponsor is posting for distribution.
proposeDistribution(uint256 rewardIndex, bytes32 merkleRoot, string ipfsHash) (external)

Allows any caller to propose distribution for funded reward starting from earliestProposalTimestamp. Only one undisputed proposal at a time is allowed.

The caller must approve this contract to transfer optimisticOracleProposerBond + final fee amount of bondToken.

Parameters:#

  • rewardIndex: Index for identifying existing Reward struct that should be proposed for distribution.
  • merkleRoot: Merkle root describing allocation of proposed rewards distribution.
  • ipfsHash: Hash of IPFS object, conveniently stored for clients to verify proposed distribution.
executeDistribution(bytes32 proposalId) (external)

Allows any caller to execute distribution that has been validated by the Optimistic Oracle.

Calling this for unresolved proposals will revert.

Parameters:#

  • proposalId: Hash for identifying existing rewards distribution proposal.
syncUmaEcosystemParams() (public)

Updates the address stored in this contract for the OptimisticOracle to the latest version set in the Finder.

There is no risk of leaving this function public for anyone to call as in all cases we want the address of OptimisticOracle in this contract to map to the latest version in the Finder.

_getOptimisticOracle() โ†’ contract OptimisticOracleInterface (internal)
_getIdentifierWhitelist() โ†’ contract IdentifierWhitelistInterface (internal)
_getCollateralWhitelist() โ†’ contract AddressWhitelistInterface (internal)
_appendRewardIndex(uint256 rewardIndex, bytes customAncillaryData) โ†’ bytes (internal)
_ancillaryDataWithinLimits(bytes customAncillaryData) โ†’ bool (internal)
_getProposalId(bytes32 identifier, uint256 timestamp, bytes ancillaryData) โ†’ bytes32 (internal)
_noBlockingProposal(uint256 rewardIndex, struct OptimisticDistributor.Reward reward) โ†’ bool (internal)
setCurrentTime(uint256 time) (external)

Sets the current time.

Will revert if not running in test mode.

Parameters:#

  • time: timestamp to set current Testable time to.
getCurrentTime() โ†’ uint256 (public)

Gets the current time. Will return the last time set in setCurrentTime if running in test mode. Otherwise, it will return the block timestamp.

multicall(bytes[] data) โ†’ bytes[] results (external)
_preEntranceCheck() (internal)
_preEntranceSet() (internal)
_postEntranceReset() (internal)
_startReentrantGuardDisabled() (internal)
_endReentrantGuardDisabled() (internal)

Events#

RewardCreated(address sponsor, contract IERC20 rewardToken, uint256 rewardIndex, uint256 maximumRewardAmount, uint256 earliestProposalTimestamp, uint256 optimisticOracleProposerBond, uint256 optimisticOracleLivenessTime, bytes32 priceIdentifier, bytes customAncillaryData)
RewardIncreased(uint256 rewardIndex, uint256 newMaximumRewardAmount)
ProposalCreated(address sponsor, contract IERC20 rewardToken, uint256 rewardIndex, uint256 proposalTimestamp, uint256 maximumRewardAmount, bytes32 proposalId, bytes32 merkleRoot, string ipfsHash)
RewardDistributed(address sponsor, contract IERC20 rewardToken, uint256 rewardIndex, uint256 maximumRewardAmount, bytes32 proposalId, bytes32 merkleRoot, string ipfsHash)
ProposalRejected(uint256 rewardIndex, bytes32 proposalId)

Modifiers#

onlyIfTest()

Reverts if not running in test mode.

nonReentrant()

Prevents a contract from calling itself, directly or indirectly. Calling a nonReentrant function from another nonReentrant function is not supported. It is possible to prevent this from happening by making the nonReentrant function external, and making it call a private function that does the actual state modification.

nonReentrantView()

Designed to prevent a view-only method from being re-entered during a call to a nonReentrant() state-changing method.