Comment on page
QilinV2Pool
Managing liquidity pools, LP tokens, positions
Add liquidity to a trading pool to obtain corresponding LP tokens
function addLiquidity(
address user,
uint256 amount
) external;
parameters:
name | type | description |
user | address | Address of whom actually adds liquidity, since Qilin's trading pool is called by Router, the actually signer address cannot be obtained through msg.sender |
amount | uint256 | Amount of added liquidity (measured in pool tokens) |
Remove the liquidity in a trading pool, destroy the corresponding LP token, and obtain the pool tokens
function removeLiquidity(
address user,
uint256 lsAmount,
uint256 bondsAmount,
address receipt
) external;
parameters:
name | type | description |
user | address | Address of whom actually removes liquidity |
lsAmount | uint256 | Amount of removed liquidity (measured in ls tokens) |
bondsAmount | uint256 | The amount of bond tokens used to offset debt when removing liquidity |
receipt | address | Receiver address after removing liquidity |
Open a position based on a certain trading pool
function openPosition(
address user,
uint8 direction,
uint16 leverage,
uint256 position
) external returns (uint32);
parameters:
name | type | description |
user | address | Actual trading address |
direction | uint8 | Trading direction,1: buy long,2: buy short |
leverage | uint16 | Leverage |
position | uint256 | Initial margin size of position |
returns:
name | type | description |
positionId | uint32 | Position ID |
Add margin to a specified position
function addMargin(
address user,
uint32 positionId,
uint256 margin
) external;
parameters:
name | type | description |
user | address | The address where the margin is actually added |
positionId | uint32 | Position ID |
margin | uint256 | Amount of margin added |
Close position, only when the remaining margin of the position is not lower than the margin*margin rate, the position can be closed
function closePosition(
address receipt,
uint32 positionId
) external;
parameters:
name | type | description |
receipt | address | Address to receive tokens |
positionId | uint32 | Position ID |
Liquidation, when the remaining margin of the position is lower than the margin * margin rate, you can use this interface to liquidate
function liquidate(
address user,
uint32 positionId,
address receipt
) external;
parameters:
name | type | description |
user | address | The address where the position is actually liquidated |
positionId | uint32 | Position ID |
receipt | address | Address to receive tokens |
Last modified 1yr ago