📝 Contracts & Addresses

Below is a comprehensive summary of all QuickPerps contracts & addresses

Polygon zkEVM

V2

Store: 0x14c8FEA10fdc2d1357410f473e2CAa035a872517

Fundingtracker: 0xf8f7299C2A86C5Af7B01FC9B44CeFD8E29fa12de

Positionmanager: 0xc83A84d8dd7BC11A72A17D611D7c346E41f5aba1

Token contract:

QLP token contract address: 0xC8E48fD037D1C4232F294b635E74d33A0573265a

Core contracts:

TokenManager: 0x64486300799ee3c8a1391aBaaF112782A01dd6F1

OrderBook: 0x7e01238227213C513010F5fAbD0634fEBee93EE5

PositionManager: 0x2264d1c908C4347F75F8eB438a4f94f4caecF634

PositionRouter: 0x443Cf165B72e4b4331C0101A10553269972Ed4B8

Router: 0x1FE9fBA5955Af58C18057213F0151BBE893aB2c8

PositionUtils: 0x11e3657FcdE2053db4EC0e6327c3908aAf449c7b

Vault: 0x99B31498B0a1Dae01fc3433e3Cb60F095340935C

VaultErrorController: 0xc5616F35fD19935B8A6e6792519C2146aFceF38E

VaultPriceFeed: 0x5b1F500134bdD7f4359F5B2adC65f839737290f4

Oracle Contracts:

FastPriceEvents: 0x08bC8ef0b71238055f9Ee6BBc90869D8d0DBdCCa

FastPriceFeed: 0x73903fEc691a80Ec47bc830bf3F0baD127A06e30

FastPriceFeedReader: 0xc3fA1b049449760476d8D17681278afd32d5FD75

PriceFeedtimelock: 0x65Dc5D07eb9DB1162e52848e00380Dba559c6cc6

Peripheral Contracts

BatchSender: 0xEf3b113158A5D0b319DB044a707d7da3EF77726C

ShortsTracker: 0xE5041618b6de86A3AE68Db2283b92295a7B5aE6a

Timelock: 0x5cce4f2D88f809B17f08a36c97ac9087CEB18384

OrderBookReader: 0x0cdda294315412B1Ba25AeE84EdD1d2bB67a0076

Reader: 0xf1CFB75854DE535475B88Bb6FBad317eea98c0F9

RewardReader: 0x5f24Aa47Cd5E9d5BbFDd693F6eFc661C5A6fC7dA

Referral contracts:

ReferralReader: 0x29B3e948CE2Db1964006ea9f5eA072CE7D008a63

ReferralStorage: 0xD0357bae72A794A92c321C78A40a106d503527Be

Reward contracts

QLPManager: 0x87BcD3914eD3dcd5886BA1c0f0DA25150b56fE54

RewardRouter: 0x4141b44f0e8b53aDcAc97D87a3c524d70e5e23B7

Trackers:

StakedQLP: 0x973ae30Cb49986E1D3BdCAB4d40B96fEA5baBE84

StakedQLPTracker: 0x42d36bA59E1d3DCc96365948Df794e0054e5Fd4d

FeeQLPTracker: 0xd3Ee28CB8ed02a5641DFA02624dF399b01f1e131

USDQ: 0x48aC594dd00c4aAcF40f83337fc6dA31F9F439A7

Distributors:

StakedQLPDistributor: 0xDB1B5D7622b7E6a9E4fBD7658d1D5994174dcDcc

FeeQLPDistributor: 0xe6700443149490a784415B682A4772Cc42714b53

Source Code:

Vault: https://github.com/QuickSwap/perps/blob/main/contracts/core/Vault.sol

Router: https://github.com/QuickSwap/perps/blob/main/contracts/core/Router.sol

Protocol owned Bots:

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.

FastPricefeed Updater 1: 0x804F813bE88D36e2388B0EdF317a721067c656dC

FastPricefeed Updater 2: 0x1Ac344ee9bF132ddAbc53B5Ce2e7f1EC36f76b9a

Fastpricefeed Updater 3: 0x4dfCEdDa40FBd2FC691268cAbEA074D1F4fAcd6F

Fastpricefeed Updater 4: 0x0994F9C167be98c171efB0a5721DAF2F174E5D50

PositionKeeper 1: 0xB231b8a74973b4165371C854c5a6dc87c331679C

Position Keeper 2: 0xa318365147E2dCc346F9BD3f050C1355fB2d8734

LimitOrderKeeper 1: 0x9Dd15740F31899Ca4c4DB5E64fC4e12a7b5cfC25

LimitOrderKeeper 2: 0xa1305F64Bc8AfbeCAb8C8F0BdB866668B1CA5D34

Liquidator 1: 0xefD75A724F2671ED92475bbe836b70CEd38aB641

Liquidator 2: 0xe0DE641E48F63F52b4AF21ACd5152Df3E704a546

Bug Bounty

There is no active bug bounty for the contracts.

Users who find bugs or exploits will be extensively reimbursed. Contact: sameep@quickswap.exchange

Swap

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

Query Available Amounts

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.

Opening / Increasing a 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

Closing / Decreasing a Position

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

Positions List

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

Last updated