ExampleDerivatives
ExampleDerivatives
_ExampleDerivatives is used to increase and decrease positions.
The pluginIncreasePosition
function will call the omniMint
function from the router. The pluginIncreasePosition
function will call the increasePosition
function from the vault.
The pluginIncreasePosition
function will deposit the tokens into the vault and mint the omniDepositTokens
. And the pluginIncreasePosition
function will mint the omniDepositTokens
to the account. And increase the position size by the amount of tokens deposited.
The pluginDecreasePosition
function will call the omniRedeem
function from the router. The pluginDecreasePosition
function will call the decreasePosition
function from the vault.
The pluginDecreasePosition
function will burn the omniDepositTokens
from the account and redeem the omniDepositTokens
from the vault. And the pluginDecreasePosition
function will withdraw the tokens from the vault. And decrease the position size by the amount of tokens withdrawn.
router
is the address of the OCP Router and is immutable.
remoteChainId
is the chainId of the remote chain and is immutable.
depositToken
is the address of the deposit token and is immutable.
vault
is the address of the vault and is immutable. vault
will be used to deposit and withdraw tokens. vault
will be used to increase and decrease positions. vault
will be used to get the position key and omniDepositToken will be deposited to the position key._
router
remoteChainId
depositToken
vault
constructor
_constructor is used to initialize the router, remote chain id, deposit token and vault.
The router is the address of the OCP Router.
The remote chain id is the chainId of the remote chain.
The deposit token is the address of the deposit token.
The vault is the address of the vault._
Parameters
_router
address
The address of the OCP Router.
_remoteChainId
uint16
The chainId of the remote chain.
_depositToken
address
The address of the deposit token.
_vault
address
The address of the vault.
pluginIncreasePosition
_pluginIncreasePosition is used to increase positions.
The pluginIncreasePosition
function will call the omniMint
function from the router. Deposit the token into the vault and mint the omniDepositTokens
. And the pluginIncreasePosition
function will mint the omniDepositTokens
to the account. And increase the position size by the amount of tokens deposited.
The pluginIncreasePosition
function will call the increasePosition
function from the vault. The increasePosition
function will increase the position size by the amount of tokens deposited._
Parameters
_account
address
The address of the account to increase the position for.
_collateralToken
address
The address of the collateral token to increase the position for.
_indexToken
address
The address of the index token to increase the position for.
_sizeDelta
uint256
The amount of tokens to increase the position size by.
_amountIn
uint256
The amount of tokens to deposit into the vault.
_isLong
bool
The direction of the position.
pluginDecreasePosition
_pluginDecreasePosition is used to decrease positions.
pluginDecreasePosition
function will call the omniRedeem
function from the router. Burn the omniDepositTokens
from the account and redeem the omniDepositTokens
from the vault. And the pluginDecreasePosition
function will withdraw the tokens from the vault. And decrease the position size by the amount of tokens withdrawn.
The pluginDecreasePosition
function will call the decreasePosition
function from the vault. The decreasePosition
function will decrease the position size by the amount of tokens withdrawn._
Parameters
_account
address
The address of the account to decrease the position for.
_collateralToken
address
The address of the collateral token to decrease the position for.
_indexToken
address
The address of the index token to decrease the position for.
_collateralDelta
uint256
The amount of tokens to withdraw from the vault.
_sizeDelta
uint256
The amount of tokens to decrease the position size by.
_amountIn
uint256
The amount of tokens to burn from the account.
_isLong
bool
The direction of the position.
_receiver
address
The address to withdraw the tokens to.
Last updated