Developer FAQs
Last updated
Was this helpful?
Last updated
Was this helpful?
Content Out of Date
This content is not maintained and refers to an out-of-date version of Perpetual Protocol.
For the latest documentation, see
There is no API in the regular sense. Perpetual Protocol uses The Graph API to provide data, and protocol functions can be called using tools that interact directly with the on-chain smart contracts.
Useful subgraphs
AKA how much vUSD will I pay for 1 vETH and similar questions.
You can get quotes using our quoter contract:
Example code:
liquidity
?First call
and the function will return a struct:
To get this number programmatically, you need to get your impermanent position size
impermanentPosition = accountBalance.getTotalPositionSize() - accountBalance.getTakerPositionSize()
and the open notional
impermanentOpenNotional = accountBalance.getTotalOpenNotional() - accountBalance.getTakerOpenNotional()
then you can get
impermanentLoss = impermanentPosition * indexPrice + impermanentOpenNotional
next get pending fees
pendingFees = accountBalance.getPnlAndPendingFee()
now you can calculate net return
netReturn = pendingFees + impermanentLoss
We can calculate the base/quote amount in a liquidity at any given time as long as we know the current price at that time.
There are 3 cases: 1. current price is in the range:
2. current price is above the upper price, only quote token in the liquidity:
3. current price is below the lower price, only base toke in the liquidity:
For more info about `isBaseToQuote` and other values, see the.