🦊
OCP
  • Interfaces
    • IOCPBridge
    • IOCPOmniTokenManager
    • IOCPool
    • IOCPoolFactory
    • IOCPReceiver
    • IOCPRouter
    • IOmniToken
    • IWETH
  • Libraries
    • Structs
    • Types
  • Entity
    • OCPool
    • OmniToken
  • OCPBridge
  • OCPOmniTokenManager
  • OCPoolFactory
  • OCPRouter
  • Example
    • ExampleDerivatives
    • ExampleDEX
    • ExampleOUSD
    • ExampleStaking
    • References
      • Vault
    • Mock
      • LZEndpoint
      • Token
      • MockUniswap
        • MockFactory
        • MockPair
        • MockToken
        • UQ112x112
  • Testnet Addresses
Powered by GitBook
On this page
  • ExampleStaking
  • router
  • depositToken
  • remoteChainId
  • constructor
  • stakingDepositCall
  • withdraw
  • claimRewards
  1. Example

ExampleStaking

ExampleStaking

_ExampleStaking is used to show how to use the IOCPRouter.

ExampleStaking will set the router, remoteChainId, and depositToken variables in the constructor. And these variables will be immutable. Staking will use the router to mint and redeem OmniTokens for the depositToken. Staking will use the remoteChainId to mint and redeem OmniTokens on the remote chain.

The stakingDepositCall function is used to deposit tokens into the pool. The stakingDepositCall function will call the omniMint function on the router.

The withdraw function is used to withdraw tokens from the pool. The withdraw function will call the omniRedeem function on the router.

The claimRewards function is used to claim rewards from the pool. The claimRewards function will call the omniRedeem function on the router. The claimRewards function will call the omniMint function on the router for the rewards.

The IOCPRouter is used to mint and redeem OmniTokens. OmniTokens are minted when tokens are deposited into the pool. OmniTokens are redeemed when tokens are withdrawn from the pool._

router

contract IOCPRouter router

depositToken

contract IERC20 depositToken

remoteChainId

uint16 remoteChainId

constructor

constructor(address _router, uint16 _remoteChainId, address _depositToken) public

_constructor is used to set the router, remoteChainId, and depositToken variables.

The router variable is the address of the OCP Router. The remoteChainId variable is the chainId of the remote chain. The depositToken variable is the address of the token to deposit. The router, remoteChainId, and depositToken variables are immutable._

Parameters

Name
Type
Description

_router

address

The address of the OCP Router.

_remoteChainId

uint16

The chainId of the remote chain.

_depositToken

address

The address of the token to deposit.

stakingDepositCall

function stakingDepositCall(uint256 _amountIn) external

_stakingDepositCall is used to deposit tokens into the pool.

The stakingDepositCall function will call the omniMint function on the router. The omniMint function will mint OmniTokens for the depositToken to the address specified in the omniMint function. The omniMint function will mint OmniTokens for the depositToken using the convertRate function._

Parameters

Name
Type
Description

_amountIn

uint256

The amount of tokens to deposit.

withdraw

function withdraw(uint256 _amountIn) external

_withdraw is used to withdraw tokens from the pool.

The withdraw function will call the omniRedeem function on the router. The omniRedeem function will redeem OmniTokens for the depositToken to the address specified in the omniRedeem function._

Parameters

Name
Type
Description

_amountIn

uint256

The amount of tokens to withdraw.

claimRewards

function claimRewards() external

_claimRewards is used to claim rewards from the pool.

The claimRewards function will call the omniRedeem function on the router. The omniRedeem function will redeem OmniTokens for the depositToken to the address specified in the omniRedeem function. The claimRewards function will call the omniMint function on the router for the rewards._

PreviousExampleOUSDNextReferences

Last updated 1 year ago