Qilin Protocol
Search
K
Comment on page

QilinV2Router

QILINV2Router

Peripheral contract, for unified contract operation entry

createPoolFromUni

Create a trading pool on Qilin (based on uniswap)
function createPoolFromUni(
address tradeToken,
address poolToken,
uint24 fee,
bool reverse
) external;
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
fee
uint24
This fee is the fee in the uniswap v3 pool, which uniquely determines a uniswap price feed source together with the trading pair. When this parameter is 0, a pool is built based on uniswap v2
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed

createPoolFromSushi

Create a trading pool on Qilin (based on sushiswap)
function createPoolFromUni(
address tradeToken,
address poolToken,
bool reverse
) external;
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed

getLsBalance

Get balance of user's LS token (pools based on uniswap)
function getLsBalance(
address tradeToken,
address poolToken,
uint24 fee,
bool reverse,
address user
) external view returns (uint256);
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
fee
uint24
This fee is the fee in the uniswap v3 pool, which uniquely determines a uniswap price feed source together with the trading pair. When this parameter is 0, a pool is built based on uniswap v2
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed
user
address
Address of user

getLsBalance2

Get balance of user's LS token (pools based on sushiswap)
function getLsBalance2(
address tradeToken,
address poolToken,
bool reverse,
address user
) external view returns (uint256);
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed
user
address
Address of user

getLsPrice

Get price of user's LS token (pools based on uniswap)
function getLsPrice(
address tradeToken,
address poolToken,
uint24 fee,
bool reverse
) external view returns (uint256);
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
fee
uint24
This fee is the fee in the uniswap v3 pool, which uniquely determines a uniswap price feed source together with the trading pair. When this parameter is 0, a pool is built based on uniswap v2
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed

getLsPrice2

Get price of user's LS token (pools based on sushiswap)
function getLsPrice2(
address tradeToken,
address poolToken,
bool reverse
) external view returns (uint256);
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed

addLiquidity

Add liquidity (pools based on uniswap)
function addLiquidity(
address tradeToken,
address poolToken,
uint24 fee,
bool reverse,
uint256 amount
) external payable;
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
fee
uint24
This fee is the fee in the uniswap v3 pool, which uniquely determines a uniswap price feed source together with the trading pair. When this parameter is 0, a pool is built based on uniswap v2
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed
amount
uint256
Amount of added liquidity (measured in pool tokens)

addLiquidity2

Add liquidity (pools based on sushiswap)
function addLiquidity2(
address tradeToken,
address poolToken,
bool reverse,
uint256 amount
) external payable;
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed
amount
uint256
Amount of added liquidity (measured in pool tokens)

removeLiquidity

Remove liquidity (pools based on uniswap)
function removeLiquidity(
address tradeToken,
address poolToken,
uint24 fee,
bool reverse,
uint256 lsAmount,
uint256 bondsAmount,
address receipt
) external;
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
fee
uint24
This fee is the fee in the uniswap v3 pool, which uniquely determines a uniswap price feed source together with the trading pair. When this parameter is 0, a pool is built based on uniswap v2
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed
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

removeLiquidity2

Remove liquidity (pools based on sushiswap)
function removeLiquidity2(
address tradeToken,
address poolToken,
bool reverse,
uint256 lsAmount,
uint256 bondsAmount,
address receipt
) external;
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed
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

openPosition

Open position (pools based on uniswap)
function openPosition(
address tradeToken,
address poolToken,
uint24 fee,
bool reverse,
uint8 direction,
uint16 leverage,
uint256 position
) external payable;
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
fee
uint24
This fee is the fee in the uniswap v3 pool, which uniquely determines a uniswap price feed source together with the trading pair. When this parameter is 0, a pool is built based on uniswap v2
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed
direction
uint8
Trading direction,1: buy long,2: buy short
leverage
uint16
Leverage
position
uint256
Initial margin size of position

openPosition2

Open position (pools based on sushiswap)
function openPosition2(
address tradeToken,
address poolToken,
bool reverse,
uint8 direction,
uint16 leverage,
uint256 position
) external payable;
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed
direction
uint8
Trading direction,1: buy long,2: buy short
leverage
uint16
Leverage
position
uint256
Initial margin size of position

addMargin

Add margin
function addMargin(uint32 tokenId, uint256 margin) external payable;
parameters:
name
type
description
tokenId
uint32
Used to map this position to a router
margin
uint256
Amount of margin added

closePosition

Close position
function closePosition(uint32 tokenId, address receipt) external;
parameters:
name
type
description
tokenId
uint32
Used to map this position to a router
receipt
address
Address of token receiver

liquidate

liquidate
function liquidate(uint32 tokenId, address receipt) external;
parameters:
name
type
description
tokenId
uint32
Used to map this position to a router
receipt
address
Address of token receiver

liquiditebyPool

Liquidate by a specified pool
function liquidateByPool(address poolAddress, uint32 positionId, address receipt) external;
parameters:
name
type
description
poolAddress
address
Address of pool
positionId
uint32
Position ID
receipt
address
Address of token receiver

withdrawERC20

Withdraw the erc20 token from the router contract
function withdrawERC20(address poolToken) external;
parameters:
name
type
description
poolToken
address
Token address to be withdrawed

withdrawETH

Withdraw the eth token from the router contract
function withdrawETH() external;

repayLoan

Repay loan (pools based on uniswap)
function repayLoan(
address tradeToken,
address poolToken,
uint24 fee,
bool reverse,
uint256 amount,
address receipt
) external payable;
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
fee
uint24
This fee is the fee in the uniswap v3 pool, which uniquely determines a uniswap price feed source together with the trading pair. When this parameter is 0, a pool is built based on uniswap v2
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed
amount
uint256
Amount of repaid token
receipt
address
Address of token receiver

repayLoan2

Repay loan (pools based on sushiswap)
function repayLoan2(
address tradeToken,
address poolToken,
bool reverse,
uint256 amount,
address receipt
) external payable;
parameters:
name
type
description
tradeToken
address
Trading assets, not used for actual transaction payment, together with the pool assets constitute a trading pair
poolToken
address
Pool assets, that is, the assets that traders actually use to pay for tradings
reverse
bool
Whether it is reversed or not, it is used to identify whether the price of this trading pool is reversed
amount
uint256
Amount of repaid token
receipt
address
Address of token receiver