QilinV2Router

QILINV2Router

Peripheral contract, for unified contract operation entry

createPoolFromUni

Create a trading pool on Qilin (based on uniswap)
1
function createPoolFromUni(
2
address tradeToken,
3
address poolToken,
4
uint24 fee,
5
bool reverse
6
) external;
Copied!
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)
1
function createPoolFromUni(
2
address tradeToken,
3
address poolToken,
4
bool reverse
5
) external;
Copied!
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)
1
function getLsBalance(
2
address tradeToken,
3
address poolToken,
4
uint24 fee,
5
bool reverse,
6
address user
7
) external view returns (uint256);
Copied!
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)
1
function getLsBalance2(
2
address tradeToken,
3
address poolToken,
4
bool reverse,
5
address user
6
) external view returns (uint256);
Copied!
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)
1
function getLsPrice(
2
address tradeToken,
3
address poolToken,
4
uint24 fee,
5
bool reverse
6
) external view returns (uint256);
Copied!
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)
1
function getLsPrice2(
2
address tradeToken,
3
address poolToken,
4
bool reverse
5
) external view returns (uint256);
Copied!
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)
1
function addLiquidity(
2
address tradeToken,
3
address poolToken,
4
uint24 fee,
5
bool reverse,
6
uint256 amount
7
) external payable;
Copied!
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)
1
function addLiquidity2(
2
address tradeToken,
3
address poolToken,
4
bool reverse,
5
uint256 amount
6
) external payable;
Copied!
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)
1
function removeLiquidity(
2
address tradeToken,
3
address poolToken,
4
uint24 fee,
5
bool reverse,
6
uint256 lsAmount,
7
uint256 bondsAmount,
8
address receipt
9
) external;
Copied!
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)
1
function removeLiquidity2(
2
address tradeToken,
3
address poolToken,
4
bool reverse,
5
uint256 lsAmount,
6
uint256 bondsAmount,
7
address receipt
8
) external;
Copied!
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)
1
function openPosition(
2
address tradeToken,
3
address poolToken,
4
uint24 fee,
5
bool reverse,
6
uint8 direction,
7
uint16 leverage,
8
uint256 position
9
) external payable;
Copied!
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)
1
function openPosition2(
2
address tradeToken,
3
address poolToken,
4
bool reverse,
5
uint8 direction,
6
uint16 leverage,
7
uint256 position
8
) external payable;
Copied!
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
1
function addMargin(uint32 tokenId, uint256 margin) external payable;
Copied!
parameters:
name
type
description
tokenId
uint32
Used to map this position to a router
margin
uint256
Amount of margin added

closePosition

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

liquidate

liquidate
1
function liquidate(uint32 tokenId, address receipt) external;
Copied!
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
1
function liquidateByPool(address poolAddress, uint32 positionId, address receipt) external;
Copied!
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
1
function withdrawERC20(address poolToken) external;
Copied!
parameters:
name
type
description
poolToken
address
Token address to be withdrawed

withdrawETH

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

repayLoan

Repay loan (pools based on uniswap)
1
function repayLoan(
2
address tradeToken,
3
address poolToken,
4
uint24 fee,
5
bool reverse,
6
uint256 amount,
7
address receipt
8
) external payable;
Copied!
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)
1
function repayLoan2(
2
address tradeToken,
3
address poolToken,
4
bool reverse,
5
uint256 amount,
6
address receipt
7
) external payable;
Copied!
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
Copy link