Skip to main content

OptimisticRewarderTest

OptimisticRewarderTest#

Functions#

constructor(string _name, string _symbol, string _baseUri, uint256 _liveness, contract IERC20 _bondToken, uint256 _bond, bytes32 _identifier, bytes _customAncillaryData, contract FinderInterface _finder, address _timerAddress) (public)
getCurrentTime() โ†’ uint256 (public)
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.
mintNextToken(address recipient) โ†’ uint256 (public)

Used to mint the next ERC721 tokenId.

Parameters:#

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

Used to check the owner of the token.

this override is a formality required by solidity. It forwards the call to the internal ERC721 immplentation.

Parameters:#

  • tokenId: the tokenId to check the owner of.
_baseURI() โ†’ string (internal)
supportsInterface(bytes4 interfaceId) โ†’ bool (public)

See {IERC165-supportsInterface}.

balanceOf(address owner) โ†’ uint256 (public)

See {IERC721-balanceOf}.

name() โ†’ string (public)

See {IERC721Metadata-name}.

symbol() โ†’ string (public)

See {IERC721Metadata-symbol}.

tokenURI(uint256 tokenId) โ†’ string (public)

See {IERC721Metadata-tokenURI}.

approve(address to, uint256 tokenId) (public)

See {IERC721-approve}.

getApproved(uint256 tokenId) โ†’ address (public)

See {IERC721-getApproved}.

setApprovalForAll(address operator, bool approved) (public)

See {IERC721-setApprovalForAll}.

isApprovedForAll(address owner, address operator) โ†’ bool (public)

See {IERC721-isApprovedForAll}.

transferFrom(address from, address to, uint256 tokenId) (public)

See {IERC721-transferFrom}.

safeTransferFrom(address from, address to, uint256 tokenId) (public)

See {IERC721-safeTransferFrom}.

safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) (public)

See {IERC721-safeTransferFrom}.

_safeTransfer(address from, address to, uint256 tokenId, bytes _data) (internal)

Safely transfers tokenId token from from to to, checking first that contract recipients are aware of the ERC721 protocol to prevent tokens from being forever locked. _data is additional data, it has no specified format and it is sent in call to to. This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. implement alternative mechanisms to perform token transfer, such as signature-based. Requirements:

  • from cannot be the zero address.
  • to cannot be the zero address.
  • tokenId token must exist and be owned by from.
  • If to refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event.
_exists(uint256 tokenId) โ†’ bool (internal)

Returns whether tokenId exists. Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. Tokens start existing when they are minted (_mint), and stop existing when they are burned (_burn).

_isApprovedOrOwner(address spender, uint256 tokenId) โ†’ bool (internal)

Returns whether spender is allowed to manage tokenId. Requirements:

  • tokenId must exist.
_safeMint(address to, uint256 tokenId) (internal)

Safely mints tokenId and transfers it to to. Requirements:

  • tokenId must not exist.
  • If to refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event.
_safeMint(address to, uint256 tokenId, bytes _data) (internal)

Same as {xref-ERC721-_safeMint-address-uint256-}[_safeMint], with an additional data parameter which is forwarded in {IERC721Receiver-onERC721Received} to contract recipients.

_mint(address to, uint256 tokenId) (internal)

Mints tokenId and transfers it to to. WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible Requirements:

  • tokenId must not exist.
  • to cannot be the zero address. Emits a {Transfer} event.
_burn(uint256 tokenId) (internal)

Destroys tokenId. The approval is cleared when the token is burned. Requirements:

  • tokenId must exist. Emits a {Transfer} event.
_transfer(address from, address to, uint256 tokenId) (internal)

Transfers tokenId from from to to. As opposed to {transferFrom}, this imposes no restrictions on msg.sender. Requirements:

  • to cannot be the zero address.
  • tokenId token must be owned by from. Emits a {Transfer} event.
_approve(address to, uint256 tokenId) (internal)

Approve to to operate on tokenId Emits a {Approval} event.

_setApprovalForAll(address owner, address operator, bool approved) (internal)

Approve operator to operate on all of owner tokens Emits a {ApprovalForAll} event.

_beforeTokenTransfer(address from, address to, uint256 tokenId) (internal)

Hook that is called before any token transfer. This includes minting and burning. Calling conditions:

  • When from and to are both non-zero, from's tokenId will be transferred to to.
  • When from is zero, tokenId will be minted for to.
  • When to is zero, from's tokenId will be burned.
  • from and to are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
_msgSender() โ†’ address (internal)
_msgData() โ†’ bytes (internal)
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 timestamp. cumulative redemptions that are too low should be considered to be valid.
dispute(uint256 tokenId, struct OptimisticRewarderBase.RedemptionAmount[] cumulativeRedemptions) (public)

Disputes a redemption request.

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.

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#

Transfer(address from, address to, uint256 tokenId)

Emitted when tokenId token is transferred from from to to.

Approval(address owner, address approved, uint256 tokenId)

Emitted when owner enables approved to manage the tokenId token.

ApprovalForAll(address owner, address operator, bool approved)

Emitted when owner enables or disables (approved) operator to manage all of its assets.

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#

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.