Skip to content

LP API Reference

Query and subscribe to liquidity pool data including vaults, deposits, withdrawals, and revenue tracking.

List all liquidity vaults with their metrics.

Signature:

vaults(
where: LpVaultsFilter
limit: Int
offset: Int
order_by: LpVaultsOrder
order_desc: Boolean
): [LpVault!]!

Parameters:

  • where: Filter object (optional)
    • address: Filter by vault address
  • limit: Max results
  • offset: Skip results
  • order_by: Sort by address
  • order_desc: Sort descending

Returns: Array of LpVault objects

Example - Get All Vaults:

query GetAllVaults {
lp {
vaults {
address
collateralDenom
collateralToken {
symbol
name
logoUrl
decimals
}
tvl
sharePrice
apy
availableAssets
currentEpoch
epochStart
sharesDenom
sharesERC20
collateralERC20
revenueInfo {
RevenueCumulative
NetProfit
TraderLosses
ClosedPnl
CurrentEpochPositiveOpenPnl
Liabilities
Rewards
}
}
}
}

Example - Get Specific Vault:

query GetVault($address: String!) {
lp {
vaults(where: { address: $address }) {
address
tvl
sharePrice
apy
availableAssets
}
}
}

Key Fields Explained:

  • tvl: Total value locked in the vault
  • sharePrice: Current value of one vault share
  • apy: Annual percentage yield (annualized return)
  • availableAssets: Assets not currently in open positions
  • currentEpoch: Current epoch number
  • epochStart: Unix timestamp when current epoch started

Use Cases:

  • Display vault list with metrics
  • Compare vault performance
  • Show available liquidity
  • Calculate potential returns

Get user deposits in vaults.

Signature:

deposits(
where: LpDepositsFilter
limit: Int
offset: Int
order_by: LpDepositsOrder
order_desc: Boolean
): [LpDeposit!]!

Parameters:

  • where: Filter object (optional)
    • depositor: Filter by depositor address
    • vault: Filter by vault address
  • limit: Max results
  • offset: Skip results
  • order_by: Sort by depositor or vault
  • order_desc: Sort descending

Returns: Array of LpDeposit objects

Example - Get User Deposits:

query GetUserDeposits($user: String!) {
lp {
deposits(where: { depositor: $user }) {
depositor
shares
vault {
address
collateralToken { symbol }
sharePrice
tvl
apy
}
}
}
}

Example - Calculate Deposit Value:

query CalculateDepositValue($user: String!) {
lp {
deposits(where: { depositor: $user }) {
shares
vault {
sharePrice
collateralToken {
symbol
decimals
}
}
}
}
}

To calculate value:

const value = (shares * sharePrice) / (10 ** decimals)

Use Cases:

  • Display user’s LP positions
  • Calculate total deposited value
  • Track share ownership
  • Portfolio management

Get historical deposit and withdrawal events.

Signature:

depositHistory(
where: LpDepositHistoryFilter
limit: Int
offset: Int
order_by: LpDepositHistoryOrder
order_desc: Boolean
): [LpDepositHistoryItem!]!

Parameters:

  • where: Filter object (optional)
    • depositor: Filter by depositor address
    • vault: Filter by vault address
  • limit: Max results
  • offset: Skip results
  • order_by: Sort by depositor, sequence, or vault
  • order_desc: Sort descending

Returns: Array of LpDepositHistoryItem objects

Example - Get Deposit History:

query GetDepositHistory($user: String!) {
lp {
depositHistory(
where: { depositor: $user }
order_by: sequence
order_desc: true
limit: 50
) {
id
depositor
amount
shares
isWithdraw
vault {
address
collateralToken { symbol }
}
block {
block
block_ts
}
}
}
}

Example - Filter Vault History:

query GetVaultHistory($vaultAddress: String!) {
lp {
depositHistory(
where: { vault: $vaultAddress }
order_by: sequence
order_desc: true
limit: 100
) {
depositor
amount
shares
isWithdraw
block { block_ts }
}
}
}

Key Fields:

  • isWithdraw: true for withdrawals, false for deposits
  • amount: Amount of collateral deposited/withdrawn
  • shares: Shares minted (deposit) or burned (withdrawal)

Use Cases:

  • Build activity timeline
  • Track deposit/withdrawal events
  • Audit vault operations
  • Calculate historical returns

Get pending withdrawal requests.

Signature:

withdrawRequests(
where: LpWithdrawRequestsFilter
limit: Int
offset: Int
order_by: LpWithdrawRequestsOrder
order_desc: Boolean
): [LpWithdrawRequest!]!

Parameters:

  • where: Filter object (optional)
    • depositor: Filter by depositor address
    • vault: Filter by vault address
  • limit: Max results
  • offset: Skip results
  • order_by: Sort by depositor, unlock_epoch, or vault
  • order_desc: Sort descending

Returns: Array of LpWithdrawRequest objects

Example - Get User Withdrawals:

query GetWithdrawRequests($user: String!) {
lp {
withdrawRequests(where: { depositor: $user }) {
depositor
shares
status
unlockEpoch
autoRedeem
vault {
address
collateralToken { symbol }
currentEpoch
sharePrice
}
}
}
}

Example - Check Withdrawal Status:

query CheckWithdrawalReady($user: String!) {
lp {
withdrawRequests(where: { depositor: $user }) {
shares
unlockEpoch
autoRedeem
vault {
currentEpoch
sharePrice
}
}
}
}

To check if ready:

const isReady = vault.currentEpoch >= unlockEpoch
const estimatedValue = (shares * vault.sharePrice) / (10 ** decimals)

Key Fields:

  • status: Withdrawal request status
  • unlockEpoch: Epoch when withdrawal becomes available
  • autoRedeem: If true, automatically redeemed when unlocked

Use Cases:

  • Display pending withdrawals
  • Calculate withdrawal timing
  • Show estimated withdrawal value
  • Notify when ready

Get epoch duration in days.

Signature:

epochDurationDays: Int!

Example:

query GetEpochDuration {
lp {
epochDurationDays
epochDurationHours
}
}

Get epoch duration in hours.

Signature:

epochDurationHours: Int!

Subscribe to real-time LP data updates.

Subscribe to all vault updates.

Signature:

subscription {
lpVaults: [LpVault!]!
}

Example:

subscription WatchVaults {
lpVaults {
address
tvl
sharePrice
apy
availableAssets
currentEpoch
}
}

Use Cases:

  • Real-time TVL tracking
  • Live APY updates
  • Monitor available liquidity
  • Track epoch changes

Subscribe to user deposit updates.

Signature:

subscription {
lpDeposits(where: SubLpDepositsFilter!): [LpDeposit!]!
}

Example:

subscription WatchUserDeposits($user: String!) {
lpDeposits(where: { depositor: $user }) {
depositor
shares
vault {
address
sharePrice
}
}
}

Use Cases:

  • Update user portfolio in real-time
  • Track share balance changes
  • Monitor position value

Subscribe to deposit/withdrawal events.

Signature:

subscription {
lpDepositHistory(where: SubLpDepositHistoryFilter!): [LpDepositHistoryItem!]!
}

Example:

subscription WatchDepositEvents($user: String!, $vault: String!) {
lpDepositHistory(where: { depositor: $user, vault: $vault }) {
id
amount
shares
isWithdraw
block { block_ts }
}
}

Use Cases:

  • Real-time activity feed
  • Instant transaction notifications
  • Live history updates

Subscribe to withdrawal request updates.

Signature:

subscription {
lpWithdrawRequests(where: SubLpWithdrawRequestsFilter!): [LpWithdrawRequest!]!
}

Example:

subscription WatchWithdrawals($user: String!, $vault: String!) {
lpWithdrawRequests(where: { depositor: $user, vault: $vault }) {
shares
status
unlockEpoch
vault {
currentEpoch
}
}
}

Use Cases:

  • Notify when withdrawal ready
  • Track withdrawal status
  • Update UI when unlocked

type LpVault {
address: String!
collateralDenom: String!
collateralToken: Token!
collateralERC20: String!
sharesDenom: String!
sharesERC20: String!
tvl: Int!
sharePrice: Float!
apy: Float
availableAssets: Int!
currentEpoch: Int!
epochStart: Int!
revenueInfo: RevenueInfo!
}
type LpDeposit {
depositor: String!
shares: Int!
vault: LpVault!
}
type LpDepositHistoryItem {
id: Int!
depositor: String!
amount: Int!
shares: Int!
isWithdraw: Boolean!
vault: LpVault!
block: Block!
}
type LpWithdrawRequest {
depositor: String!
shares: Int!
status: String!
unlockEpoch: Int!
autoRedeem: Boolean!
vault: LpVault!
}

Tracks vault revenue and performance.

type RevenueInfo {
RevenueCumulative: Int! # Total revenue earned
NetProfit: Int! # Current net profit
TraderLosses: Int! # Profits from trader losses
ClosedPnl: Int! # Realized PnL from closed positions
CurrentEpochPositiveOpenPnl: Int! # Current epoch unrealized gains
Liabilities: Int! # Current liabilities (trader profits)
Rewards: Int! # Rewards received
}

// Calculate current value of deposit
const depositValue = (shares * sharePrice) / (10 ** decimals)
// For pending withdrawal
const estimatedValue = (shares * currentSharePrice) / (10 ** decimals)
// Calculate epochs remaining
const epochsRemaining = unlockEpoch - currentEpoch
// Calculate time remaining (assuming epoch duration)
const hoursRemaining = epochsRemaining * epochDurationHours

APY is calculated from historical revenue:

// Simplified APY calculation
const apy = (revenueInfo.NetProfit / tvl) * (365 / epochDurationDays)