ExampleOUSD
ExampleOUSD
_ExampleOUSD is used to show how to use the IOCPRouter.
ExampleOUSD will set the router
, remoteChainId
, and swapToken
variables in the constructor. And these variables will be immutable. ExampleOUSD will use the router
to mint and redeem OmniTokens for the swapToken
. ExampleOUSD will use the remoteChainId
to mint and redeem OmniTokens on the remote chain.
The swapTokenToOUSD
function is used to swap tokens for OUSD. The swapTokenToOUSD
function will call the omniMint
function on the router.
The swapOUSDToToken
function is used to swap OUSD for tokens. The swapOUSDToToken
function will call the omniRedeem
function on the router._
router
swapToken
remoteChainId
constructor
_constructor is used to set the router
, remoteChainId
, and swapToken
variables.
The router
variable is the address of the OCP Router. The remoteChainId
variable is the chainId of the remote chain. The swapToken
variable is the address of the token to swap. The router
, remoteChainId
, and swapToken
variables are immutable._
Parameters
_router
address
The address of the OCP Router.
_remoteChainId
uint16
The chainId of the remote chain.
_swapToken
address
The address of the token to swap.
SwapTokenToOUSD
_swapTokenToOUSD is used to swap tokens for OUSD.
The swapTokenToOUSD
function will call the omniMint
function on the router._
Parameters
from
address
The address to swap tokens from.
to
address
The address to mint OUSD to.
amountIn
uint256
The amount of tokens to swap.
payload
bytes
The payload to send to the remote chain.
SwapOUSDToToken
_swapOUSDToToken is used to swap OUSD for tokens.
The swapOUSDToToken
function will call the omniRedeem
function on the router._
Parameters
from
address
The address to swap OUSD from.
to
address
The address to redeem the swapToken
to.
amountIn
uint256
The amount of OUSD to swap.
payload
bytes
The payload to send to the remote chain.
swapTokenToOUSD
_swapTokenToOUSD is used to swap tokens for OUSD.
The swapTokenToOUSD
function will call the omniMint
function on the router. The omniMint
function will mint OUSD for the swapToken
to the address specified in the omniMint
function. The omniMint
function will mint OUSD for the swapToken
using the convertRate
function. Will emit a SwapTokenToOUSD
event._
Parameters
_amountIn
uint256
The amount of tokens to swap.
_to
address
The address to mint OUSD to.
swapOUSDToToken
_swapOUSDToToken is used to swap OUSD for tokens.
The swapOUSDToToken
function will call the omniRedeem
function on the router. The omniRedeem
function will redeem OUSD for the swapToken
to the address specified in the omniRedeem
function. The omniRedeem
function will redeem OUSD for the swapToken
using the convertRate
function. Will emit a SwapOUSDToToken
event._
Parameters
_amountIn
uint256
The amount of OUSD to swap.
_to
address
The address to redeem the swapToken
to.
Last updated