📝 Contracts & Addresses
Below is a comprehensive summary of all QuickPerps contracts & addresses
Last updated
Below is a comprehensive summary of all QuickPerps contracts & addresses
Last updated
Store: 0x14c8FEA10fdc2d1357410f473e2CAa035a872517
Fundingtracker: 0xf8f7299C2A86C5Af7B01FC9B44CeFD8E29fa12de
Positionmanager: 0xc83A84d8dd7BC11A72A17D611D7c346E41f5aba1
QLP token contract address:
TokenManager:
OrderBook:
PositionManager:
PositionRouter:
Router:
PositionUtils:
Protocol own keepers / bots are running time-delayed and redundant (different clocking as well as RPC provider) in order to guarantee a smooth process and execution in case of failures or high network congestion.
There is no active bug bounty for the contracts.
Users who find bugs or exploits will be extensively reimbursed. Contact: sameep@quickswap.exchange
To execute a swap:
Approve the Router contract for the token and amount you would like to swap
Call Router.swap with parameters:
_path: [tokenIn, tokenOut]
_amountIn: amount of tokenIn to swap
_minOut: minimum expected output amount
_receiver: address of the receiver of tokenOut
The function will revert if the amount of tokenOut sent to the receiver is less than _minOut
To get swap amounts before execution:
Call Reader.getMaxAmountIn with parameters:
_vault: address of the vault
_tokenIn: address of token that will be given
_tokenOut: address of token to be received
The max amount of tokenIn that can be swapped will be returned
Call Reader.getAmountOut with parameters:
_vault: address of the vault
_tokenIn: address of token that will be given
_tokenOut: address of token to be received
_amountIn: amount of tokenIn to swap
Two values will be returned, the first is the amount out after fees, and the second is the fee amount
The fee amount will be in terms of tokenOut
The maximum sum of all position sizes is capped by the amount of tokens there are in the pool, for example, if the total sizes of all ETH long positions is 4,000,000 USD and the pool has 1000 ETH with 800 ETH reserved for the positions, then the maximum position size of a long position that can be opened would be 200 ETH worth.
Vault.poolAmounts(_token) can be used to retrieve the amount of tokens in the pool. Vault.reservedAmounts(_token) can be used to retrieve the reserved amount of tokens.
For shorts, the query would depend on the stablecoin token used to open the position.
To open or increase the size of an existing position:
Approve the Router contract for the token and amount you would deposit as collateral for the position
PositionManager.increasePosition can be called by partner contracts and will open the position in one transaction
Alternatively PositionRouter.createIncreasePosition can be used by any contract and will request the position to be opened, a keeper will then execute this request
PositionRouter.createIncreasePosition has the same input parameters but additionally has an executionFee value that can be set to PositionRouter.minExecutionFee. If the position cannot be opened at the specified "_price" value then the request will be cancelled and the funds sent back to the account that made the request
Call PositionManager.increasePosition with parameters:
_path: [tokenIn, collateralToken] or [tokenIn]
_indexToken: the address of the token you want to long or short
_amountIn: the amount of tokenIn you want to deposit as collateral
_minOut: the min amount of collateralToken to swap for
_sizeDelta: the USD value of the change in position size
_isLong: whether to long or short
_price: the USD value of the max (for longs) or min (for shorts) index price accepted when opening the position
_path allows swapping to the collateralToken if needed
For longs, the collateralToken must be the same as the indexToken
For shorts, the collateralToken can be any stablecoin token
_minOut can be zero if no swap is required
USD values for _sizeDelta and _price are multiplied by (10 ** 30), so for example to open a long position of size 1000 USD, the value 1000 * (10 ** 30) should be used
To close or decrease an existing position:
PositionManager.decreasePosition can be called by partner contracts and will close or decrease the position in one transaction
Alternatively PositionRouter.createDecreasePosition can be used by any contract and will request the position to be closed / decreased, a keeper will then execute this request.
PositionRouter.createDecreasePosition has the same input parameters but additionally has an executionFee value that can be set to PositionRouter.minExecutionFee. If the position cannot be opened at the specified "_price" value then the request will be cancelled
Call Router.decreasePosition with parameters:
_collateralToken: the collateral token used
_indexToken: the index token of the position
_collateralDelta: the amount of collateral in USD value to withdraw
_sizeDelta: the USD value of the change in position size
_isLong: whether the position is a long or short
_receiver: the address to receive the withdrawn tokens
_price: the USD value of the min (for shorts) or max (for longs) index price accepted when decreasing the position
If _sizeDelta is the same size as the position, the collateral after adding profits or deducting losses will be sent to the receiver address
A list of position details can be retrieved by calling Reader.getPositions
_vault: the vault contract address
_account: the account of the user
_collateralTokens: an array of collateralTokens
_indexTokens: an array of indexTokens
_isLong: an array of whether the position is a long position
The returned positions will be in the order of the query, for example, given the following inputs:
_collateralTokens: [WBTC.address, WETH.address, USDC.address]
_indexTokens: [WBTC.address, WETH.address, WBTC.address]
_isLong: [true, true, false]
The position details would be returned for
Long BTC position, positionIndex: 0
Long ETH position, positionIndex: 1
Short BTC position, positionIndex: 2
The returned array would be a list of values ordered by the positions:
size
position size in USD
value at: positionIndex * 9
collateral
position collateral in USD
value at: positionIndex * 9 + 1
averagePrice
average entry price of the position in USD
value at: positionIndex * 9 + 2
entryFundingRate
a snapshot of the cumulative funding rate at the time the position was entered
value at: positionIndex * 9 + 3
hasRealisedProfit
1 if the position has a positive realised profit, 0 otherwise
value at: positionIndex * 9 + 4
realisedPnl
the realised PnL for the position in USD
value at: positionIndex * 9 + 5
lastIncreasedTime
timestamp of the last time the position was increased
value at: positionIndex * 9 + 6
hasProfit
1 if the position is currently in profit, 0 otherwise
value at: positionIndex * 9 + 7
delta
amount of current profit or loss of the position in USD
value at: positionIndex * 9 + 8
Vault:
VaultErrorController:
VaultPriceFeed:
FastPriceEvents:
FastPriceFeed:
FastPriceFeedReader:
PriceFeedtimelock:
BatchSender:
ShortsTracker:
Timelock:
OrderBookReader:
Reader:
RewardReader:
ReferralReader:
ReferralStorage:
QLPManager:
RewardRouter:
StakedQLP:
StakedQLPTracker:
FeeQLPTracker:
USDQ:
StakedQLPDistributor:
FeeQLPDistributor:
Vault:
Router:
FastPricefeed Updater 1:
FastPricefeed Updater 2:
Fastpricefeed Updater 3:
Fastpricefeed Updater 4:
PositionKeeper 1:
Position Keeper 2:
LimitOrderKeeper 1:
LimitOrderKeeper 2:
Liquidator 1:
Liquidator 2: