API
A state transition on a Derion pool is done by calling the swap
function on the pool contract. The same function can also be statically called to perform input and output estimation.
Sides
There are 3 sides in a pool:
SIDE_LONG = 0x10
SIDE_SHORT = 0x20
SIDE_LP = 0x30
sideIn
and sideOut
represent the state transistion types:
opening Long/Short/LP position will have
sideIn
= 0closing Long/Short/LP position will have
sideOut
= 0
Helper
helper: Helper contract address
payload: data will be passed to
Helper.swapToState
contract call internally by theswap
function.amountIn: is the maximum amount of sideIn token that will be spent in the swap transaction
Note: sideIn
and sideOut
must be passed twice: first in the Param
, and another time packed in Helper's payload
.
Payment
recipient
is the target account that the token output will be transfered to.
See Derivative Tokens for ERC-1155 position token and id specification.
There are 2 methods of payments:
Direct Token Approval
If payer
is an empty bytes, the utr
param will be ignored, and swap
require a direct approval from msg.sender
to transfer the sideIn
token in. This mode is recommended for inter-contract interaction only.
ERC-6120
If payer
is the 20 bytes address of the paying account, the swap
call is expected to be invoked over an ERC-6120
's execution by that payer
account.
Last updated
Was this helpful?