๐ก 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.
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.
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:
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:
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)
Output values:
persistIndexAtMaturity
Persists the index value for a future at maturity. Can only be called by maturity couriers.
updateAndGetLastIndex
Updates and returns the last index for a market using provided oracle packages.
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.
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.
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.
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
collectProtocolFee
Allows the collection of protocol fees for a specific market.
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.
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.
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
MarginWithThreshold
Provides information about margin account state
Last updated