Skip to main content

OptimisticRewarderBase

OptimisticRewarderBase#

The base rewarder contract. This manages depositing rewards and paying them out to tokenholders using values backed by the OptimisticOracle's dispute process.

Functions#

constructor(uint256 _liveness, contract IERC20 _bondToken, uint256 _bond, bytes32 _identifier, bytes _customAncillaryData, contract FinderInterface _finder) (internal)

Constructor.

Parameters:#

  • _liveness: liveness period between submission and verification of a reward.
  • _bondToken: ERC20 token that the bond is paid in.
  • _bond: size of the bond.
  • _identifier: identifier that should be passed to the optimistic oracle on dispute.
  • _customAncillaryData: custom ancillary data that should be sent to the optimistic oracle on dispute.
  • _finder: finder to look up UMA contract addresses.
depositRewards(contract IERC20 token, uint256 amount) (public)

Allows anyone to deposit reward tokens into the contract. Presumably, this would be the deployer or protocol that wishes to reward the users interacting with the system.

Once tokens are deposited, they cannot be withdrawn without claiming a reward. If a deployer wants an "escape hatch", they can create a special tokenId for this purpose.

Parameters:#

  • token: ERC20 token that is being deposited.
  • amount: amount of rewards to deposit.
mint(address receiver, bytes data) โ†’ uint256 tokenId (public)

Allows the caller to mint a token to the receiver and include a reward-relevant update event with it. This is intended to be used when the user first interacts with a reward-granting protocol.

if the user prefers to only mint a new token, they should call the mintNextToken function.

Parameters:#

  • receiver: user that will receive the newly minted token.
  • data: arbitrary caller-generated data that will be associated with this update.
updateToken(uint256 tokenId, bytes data) (public)

Applies a reward-relevant update to an existing token.

Parameters:#

  • tokenId: the existing tokenId that the update should be applied to.
  • data: arbitrary caller-generated data that will be associated with this update.
requestRedemption(uint256 tokenId, struct OptimisticRewarderBase.RedemptionAmount[] cumulativeRedemptions) โ†’ uint256 totalBond (public)

Requests a redemption for any tokenId. This can be called by anyone.

if called by someone who doesn't own the token, they are effectively gifting their bond to the owner.

Parameters:#

  • tokenId: the tokenId the redemption is for.
  • cumulativeRedemptions: the cumulative token addresses and amounts that this tokenId is eligible for at the current timestap. cumulative redemptions that are too low should be considered to be valid.
dispute(uint256 tokenId, struct OptimisticRewarderBase.RedemptionAmount[] cumulativeRedemptions) (public)

Disputes a redemption request.

this will cancel a request if the final fee changes or something causes the optimistic oracle proposal to fail.

Parameters:#

  • tokenId: the tokenId the redemption is for.
  • cumulativeRedemptions: the cumulative redemptions that were provided in the original request.
redeem(uint256 tokenId, struct OptimisticRewarderBase.RedemptionAmount[] cumulativeRedemptions) (public)

Redeem a redemption request that has passed liveness.

returns the bond that was paid with the initial proposal.

Parameters:#

  • tokenId: the tokenId the redemption is for.
  • cumulativeRedemptions: the cumulative redemptions that were provided in the original request.
sync() (public)

Syncs external addresses and parameters into the contract.

These are stored rather than read on each run to avoid expensive external calls in the happy-path.

getCurrentTime() โ†’ uint256 (public)

gets the current time. Can be overridden for testing.

mintNextToken(address recipient) โ†’ uint256 (public)

Abstract function that is called to mint the next ERC721 tokenId.

Parameters:#

  • recipient: the recipient of the newly minted token.
ownerOf(uint256 tokenId) โ†’ address (public)

Abstract function that is called to check the owner of the token.

this matches the ERC721 ownerOf interface.

Parameters:#

  • tokenId: the tokenId to check the owner of.
getRedemptionId(uint256 tokenId, struct OptimisticRewarderBase.RedemptionAmount[] cumulativeRedemptions) โ†’ bytes32 (public)

Generates a redemption id for the tokenId and the claim amounts.

Parameters:#

  • tokenId: the tokenId that the claim is for.
  • cumulativeRedemptions: the cumulative redemptions that were provided in the request.
_sync() (internal)
_getStore() โ†’ contract StoreInterface (internal)
_getOptimisticOracle() โ†’ contract SkinnyOptimisticOracleInterface (internal)
_getIdentifierWhitelist() โ†’ contract IdentifierWhitelistInterface (internal)
_getCollateralWhitelist() โ†’ contract AddressWhitelistInterface (internal)
_cancelRedemption(uint256 tokenId, bytes32 redemptionId) (internal)
multicall(bytes[] data) โ†’ bytes[] results (external)
_preEntranceCheck() (internal)
_preEntranceSet() (internal)
_postEntranceReset() (internal)

Events#

UpdateToken(uint256 tokenId, address caller, bytes data)
Deposited(address depositor, contract IERC20 token, uint256 amount)
Requested(uint256 tokenId, bytes32 redemptionId, struct OptimisticRewarderBase.RedemptionAmount[] cumulativeRedemptions, uint256 expiryTime)
Canceled(uint256 tokenId, bytes32 redemptionId, uint256 expiryTime)
Disputed(uint256 tokenId, bytes32 redemptionId, uint256 expiryTime)
Redeemed(uint256 tokenId, bytes32 redemptionId, uint256 expiryTime)

Modifiers#

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.