๐ก Router contract
The main entry point of the Protocol that handles all incoming write transactions.
provideLiquidity
Function for providing liquidity to a particular future.
Facilitates the provision of notional
amount of liquidity for futureId
in range between lowerBound
and upperBound
rates.
Optionally a deposit
could be made alongside the trade by setting depositAmount
param for ERC20 tokens, msg.value
for native tokens or both for a double deposit. (Check deposit section for details)
The actual provided notional amount could differ from the requested due to rounding. The resulting value can be checked in LiquidityProvisionResult
return struct.
futureId
Future identifier.
notional
uint256
The maximum face amount for trades using the liquidity being provided
depositAmount
uint256
The amount of underlying ERC-20 to be deposited.
lowerBound
int256
Defines the lower point of the rate range. Format: fixed point signed 18-decimal number.
upperBound
int256
Defines the upper point of the rate range. Format: fixed point signed 18-decimal number.
deadline
uint256
Specifies a timestamp by which the transaction must be processed. Transactions mined after this timestamp will revert.
settleMaturedPositions
bool
Boolean that when true will trigger the internal optimisation mechanism, that lowers the gas consumption for further calls in case there is a matured Position in user's portfolio.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
removeLiquidity
Function for removing liquidity from a future.
Removes notional
amount of liquidity from given futureId
in range from lowerBound
to upperBound
.
Ensure that there is provided liquidity in selected range before calling the function.
futureId
Target Future identifier.
notional
uint256
Defines how much of the provided liquidity will be removed given the user's existing notional
lowerBound
int256
Defines the lower point of the rate range. Format: fixed point signed 18-decimal number.
upperBound
int256
Defines the upper point of the rate range. Format: fixed point signed 18-decimal number.
deadline
uint256
Specifies a timestamp by which the transaction must be processed. Transaction attempted after this timestamp will revert.
settleMaturedPositions
bool
Triggers the internal optimization mechanism, that lowers the gas consumption for further calls in case there is a matured Position in user's portfolio.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
deposit
Deposits funds for collateral from the caller into the cross-margin account of the recipient
for specific marketId
.
The function can be called in different ways:
ERC-20 token deposit An
amount
of the ERC-20 asset, defined as theunderlying
for a givenmarketId
, is being transferred from themsg.sender
to therecipient
's cross-margin account.Native token deposit (ETH) Is available only for Markets that use wrapped native assets (e.g: WETH) as
underlying
. The deposit amount is specified by the caller in form of a{value: amount_in_eth}
during the call. Deposited native tokens get wrapped into their ERC20 version.Hybrid โ ERC-20 & ETH deposit together An
amount
parameter can be used together with{value: amount_in_eth}
parameter of the same call. That allows to deposit two assets in a single call.
Before depositing ERC-20 assets make sure that the Router
contract has allowance()
to transfer funds on behalf of the caller for the Market's underlying asset.
Use ERC-20's standard approve()
for setting this allowance.
These 3 different ways to deposit are also supported on functions:
Input parameters:
marketId
Target Market identifier.
recipient
address
The address of the participant whose cross-margin account is to be updated.
amount
uint256
The amount of ERC-20 assets to be deposited.
settleMaturedPositions
bool
Triggers the internal optimisation mechanism, that lowers the gas consumption for further calls in case there is a matured Position in user's portfolio.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
withdraw
Function for the caller to reduce their collateral amount in the specified marketId
. Ensure you have sufficient collateral above the IMR threshold before calling this function.
Input parameters:
marketId
Target Market identifier.
unwrapNativeToken
bool
Determines wether the wrapped token should be unwrapped to native token upon withdrawal.
amount
uint256
The amount of ERC-20 assets to be withdrawn.
settleMaturedPositions
bool
Triggers the internal optimisation mechanism, that lowers the gas consumption for further calls in case there is a matured Position in user's portfolio.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
executeTrade
Executes an interest rate future trade for the specified futureId
with chosen risk direction
(either as a Payer or a Receiver) and notional
value.
Optionally a deposit
could be made alongside the trade by setting depositAmount
param for ERC20 tokens, msg.value
for native tokens or both for a double deposit. (Check deposit section for details)
futureId
Target Future identifier.
direction
Specifies trade's risk direction: Receiver or Payer
notional
uint256
The face value of the future trade.
futureRateLimit
int256
Sets the worst acceptable rate. For Payer it's the upper limit, for Receiver โ lower limit. Format: fixed point signed 18-decimal number.
depositAmount
uint256
The amount of ERC-20 assets to be deposited. If 0, no deposit will be made, so the user should have enough margin to cover this trade
deadline
uint256
Specifies a timestamp by which the transaction must be processed. If the transaction is mined after this timestamp, it will revert. Format: Unix timestamp in seconds
settleMaturedPositions
bool
Triggers the internal optimisation mechanism, that lowers the gas consumption for further calls in case there is a matured Position in user's portfolio.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
persistIndexAtMaturity
Persists the index value for a future at maturity. Can only be called by maturity couriers.
futureId
Target Future identifier.
oraclePackage
A package containing the latest known index for the market. Packages are provided by an Oracle service on demand.
updateAndGetLastIndex
Updates and returns the last index for a market using provided oracle packages.
marketId
Target Market identifier.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
int256
The updated last index value for the market
cancelProvisions
Cancels the liquidity provision positions for the maker
in specified marketId
when his margin is less than minimal required.
As a result the caller would get a reward
amount of underlying tokens as an incentive.
marketId
Target Market identifier.
maker
address
Address of the user, whose liquidity allocation is to be cancelled
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
uint256
Amount of reward obtained from the cancellation
liquidatePositions
Liquidate positions of the owner
, whose margin fell below the Liquidation Threshold in a specific Market. To determine whether a user's position could be liquidated use Quoter.isLiquidatable
call.
Liquidations are carried out against the liquidity that is provided by Makers to the Futures' pool.
The caller performs trades on behalf of positions owner
, but in the opposite direction, effectively lowering user's exposure to the risk. In return the liquidator gets a reward
that is deducted from owner
's margin account.
This function can only be called by users with LIQUIDATOR role.
marketId
Target Market identifier.
futureIds
Array of Futures that are targeted to be liquidated.
positionsPercentage
uint256[]
Array of percentages of the positions to be liquidated. Order of elements should correspond to order of futureIds
above.
Format: fixed point unsigned 18-decimal number, values from 0 to 1.
owner
address
Address of the user being liquidated
settleMaturedPositions
bool
Triggers the internal optimization mechanism, that lowers the gas consumption for further calls in case there is a matured Position in user's portfolio.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
TradeInfo
[]
โ an array containing information about each trade performed during the liquidationreward
โ Amount of an underlying asset that was transferred to caller's margin account as an incentive for the liquidation.
transferPositionsOwnership
Lets the caller to take over the ownership of owner
's positions in specified marketId
. Can be called when owner
's margin is below the Liquidation Threshold. To determine whether a user's position could be liquidated use Quoter.isLiquidatable
call.
As positions will be transferred to the caller, please ensure you have enough margin your account. Optionally, a deposit can also be performed along with this call.
marketId
Target Market identifier.
owner
address
Address of the user, whose positions are to be transferred
depositAmount
uint256
The amount of ERC-20 assets to be deposited.
settleMaturedPositions
bool
Triggers the internal optimization mechanism, that lowers the gas consumption for further calls in case there is a matured Position in user's portfolio.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
uint256
transferAmount โ amount of margin that was transferred from previous owner of the Position to the caller;uint256
depositAmount โ additional amount of collateral that was required on top of caller's margin and transferred amount.
settleMaturedFutures
Settles matured positions for the called in the specified market
marketId
Target Market identifier.
collectProtocolFee
Allows the collection of protocol fees for a specific market.
marketId
Target Market identifier.
recipient
address
Address that will receive the collected fee
amount
uint256
Amount of to be collected
emergencyERC20TokenTransfer
Allows the owner to make an emergency transfer of ERC20 tokens from the contract. This can be useful in situations to recover tokens accidentally sent to the contract.
tokenAddress
address
Address of the ERC20 token
to
address
Address to send the tokens to
amount
uint
Amount of tokens to be sent
emergencyERC20TokenTransfer
Allows the owner to make an emergency transfer of native tokens from the contract. This can be useful in situations to recover tokens accidentally sent to the contract.
to
address
Address to send the tokens to
amount
uint
Amount of tokens to be sent
getContractProvider
Returns ContractProvider contract
getAcm
Returns AccessControlManager contract
Structs
Documentation on all the structs mentioned in this page:
LiquidityProvisionResult
Result of a provide liquidity transaction
providedNotional
uint256
Notional amount of the liquidity provided
totalPoolNotional
uint256
Notional amount of allocated liquidity across all rate ranges for a future
MarginWithThreshold
Provides information about margin account state
currentMargin
Updated information about current P&L and deposited collateral
marginThreshold
int256
Minimal margin requirements after the trade
Last updated