Skip to main content

OptimisticStaker

OptimisticStaker#

An example use case of the OptimisticRewarder in use by a contract that allows users to stake an ERC20 to earn rewards.

Functions#

constructor(contract OptimisticRewarderBase _optimisticRewarder, contract IERC20 _stakedToken) (public)

Constructor.

Parameters:#

  • _optimisticRewarder: Optimistic rewarder contract used to pay out user rewards.
  • _stakedToken: staked ERC20 token.
depositNew(uint256 amount) → uint256 tokenId (public)

Deposit the staked token into the contract and mint a fresh token to manage the position.

Parameters:#

  • amount: the amount of the ERC20 to deposit.
deposit(uint256 tokenId, uint256 amount) (public)

Deposit the staked token into the contract.

Parameters:#

  • tokenId: the tokenId that will own this liquidity. User must be the owner of this tokenId.
  • amount: the amount of the ERC20 to deposit.
depositFor(uint256 tokenId, uint256 amount) (public)

Deposit staked tokens on behalf of a tokenId that the user may not control.

Parameters:#

  • tokenId: the tokenId that will own this liquidity.
  • amount: the amount of the ERC20 to deposit.
withdraw(uint256 tokenId, uint256 amount) (public)

Withdraw the staked tokens.

Parameters:#

  • tokenId: the tokenId that owns this liquidity. User must own this tokenId.
  • amount: the amount of the ERC20 to withdraw.
_depositFor(uint256 tokenId, uint256 amount) (internal)
multicall(bytes[] data) → bytes[] results (external)
_preEntranceCheck() (internal)
_preEntranceSet() (internal)
_postEntranceReset() (internal)

Events#

Deposit(uint256 tokenId, uint256 amount)
Withdraw(uint256 tokenId, uint256 amount)

Modifiers#

onlyTokenOwner(uint256 tokenId)
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.