このページの翻訳は LLM によって生成されています。誤りに気づいた場合は GitHub で issue を開いてお知らせください。
LP APIリファレンス
ボールト、入金、出金、収益を含む流動性プールデータを取得・購読します。
vaults
Section titled “vaults”全ボールトと指標を取得します。
シグネチャ:
vaults( where: LpVaultsFilter limit: Int offset: Int order_by: LpVaultsOrder order_desc: Boolean): [LpVault!]!パラメーター:
where:任意フィルター。address:ボールトアドレス。
limit:最大件数。offset:スキップ件数。order_by:address。order_desc:降順。
戻り値: LpVault の配列。
例:全ボールトの取得
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 } } }}例:特定ボールトの取得
query GetVault($address: String!) { lp { vaults(where: { address: $address }) { address tvl sharePrice apy availableAssets } }}主なフィールド:
tvl:ボールトの総預かり資産。sharePrice:持分1単位の現在価値。apy:年換算の利回り。availableAssets:未決済ポジションに使われていない資産。currentEpoch:現在のエポック番号。epochStart:現在エポックの開始Unix時刻。
用途:
- ボールト一覧と指標。
- 運用成績の比較。
- 利用可能な流動性。
- 想定収益の計算。
deposits
Section titled “deposits”利用者のボールト入金を取得します。
シグネチャ:
deposits( where: LpDepositsFilter limit: Int offset: Int order_by: LpDepositsOrder order_desc: Boolean): [LpDeposit!]!パラメーター:
where:任意フィルター。depositor:預金者アドレス。vault:ボールトアドレス。
limit:最大件数。offset:スキップ件数。order_by:depositorまたはvault。order_desc:降順。
戻り値: LpDeposit の配列。
例:利用者の入金
query GetUserDeposits($user: String!) { lp { deposits(where: { depositor: $user }) { depositor shares vault { address collateralToken { symbol } sharePrice tvl apy } } }}例:入金額の計算
query CalculateDepositValue($user: String!) { lp { deposits(where: { depositor: $user }) { shares vault { sharePrice collateralToken { symbol decimals } } } }}価値の計算:
const value = (shares * sharePrice) / (10 ** decimals)用途:
- 利用者のLPポジション。
- 預かり資産総額。
- 持分の所有状況。
- ポートフォリオ管理。
depositHistory
Section titled “depositHistory”過去の入出金イベントを取得します。
シグネチャ:
depositHistory( where: LpDepositHistoryFilter limit: Int offset: Int order_by: LpDepositHistoryOrder order_desc: Boolean): [LpDepositHistoryItem!]!パラメーター:
where:任意フィルター。depositor:預金者。vault:ボールト。
limit:最大件数。offset:スキップ件数。order_by:depositor、sequence、vault。order_desc:降順。
戻り値: LpDepositHistoryItem の配列。
例:入出金履歴
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 } } }}例:ボールト履歴の絞り込み
query GetVaultHistory($vaultAddress: String!) { lp { depositHistory( where: { vault: $vaultAddress } order_by: sequence order_desc: true limit: 100 ) { depositor amount shares isWithdraw block { block_ts } } }}主なフィールド:
isWithdraw:出金はtrue、入金はfalse。amount:入出金した担保額。shares:入金で発行、出金で焼却した持分。
用途:
- 活動タイムライン。
- 入出金の追跡。
- ボールト操作の監査。
- 過去の利回り計算。
withdrawRequests
Section titled “withdrawRequests”待機中の出金申請を取得します。
シグネチャ:
withdrawRequests( where: LpWithdrawRequestsFilter limit: Int offset: Int order_by: LpWithdrawRequestsOrder order_desc: Boolean): [LpWithdrawRequest!]!パラメーター:
where:任意フィルター。depositor:預金者。vault:ボールト。
limit:最大件数。offset:スキップ件数。order_by:depositor、unlock_epoch、vault。order_desc:降順。
戻り値: LpWithdrawRequest の配列。
例:利用者の出金
query GetWithdrawRequests($user: String!) { lp { withdrawRequests(where: { depositor: $user }) { depositor shares status unlockEpoch autoRedeem vault { address collateralToken { symbol } currentEpoch sharePrice } } }}例:出金状態の確認
query CheckWithdrawalReady($user: String!) { lp { withdrawRequests(where: { depositor: $user }) { shares unlockEpoch autoRedeem vault { currentEpoch sharePrice } } }}出金可能かの確認:
const isReady = vault.currentEpoch >= unlockEpochconst estimatedValue = (shares * vault.sharePrice) / (10 ** decimals)主なフィールド:
status:申請状態。unlockEpoch:出金可能になるエポック。autoRedeem:trueなら解除時に自動償還。
用途:
- 待機出金の表示。
- 出金時期の計算。
- 推定出金額の表示。
- 準備完了時の通知。
epochDurationDays
Section titled “epochDurationDays”エポックの長さを日単位で取得します。
シグネチャ:
epochDurationDays: Int!例:
query GetEpochDuration { lp { epochDurationDays epochDurationHours }}epochDurationHours
Section titled “epochDurationHours”エポックの長さを時間単位で取得します。
シグネチャ:
epochDurationHours: Int!サブスクリプション
Section titled “サブスクリプション”LPデータのリアルタイム更新を購読します。
lpVaults
Section titled “lpVaults”全ボールトの更新。
シグネチャ:
subscription { lpVaults: [LpVault!]!}例:
subscription WatchVaults { lpVaults { address tvl sharePrice apy availableAssets currentEpoch }}用途:
- リアルタイムTVL。
- APY更新。
- 利用可能な流動性の監視。
- エポック変更の追跡。
lpDeposits
Section titled “lpDeposits”利用者の入金更新。
シグネチャ:
subscription { lpDeposits(where: SubLpDepositsFilter!): [LpDeposit!]!}例:
subscription WatchUserDeposits($user: String!) { lpDeposits(where: { depositor: $user }) { depositor shares vault { address sharePrice } }}用途:
- ポートフォリオの即時更新。
- 持分残高の変化。
- ポジション価値の監視。
lpDepositHistory
Section titled “lpDepositHistory”入出金イベント。
シグネチャ:
subscription { lpDepositHistory(where: SubLpDepositHistoryFilter!): [LpDepositHistoryItem!]!}例:
subscription WatchDepositEvents($user: String!, $vault: String!) { lpDepositHistory(where: { depositor: $user, vault: $vault }) { id amount shares isWithdraw block { block_ts } }}用途:
- 即時の活動フィード。
- 取引通知。
- 履歴更新。
lpWithdrawRequests
Section titled “lpWithdrawRequests”出金申請の更新。
シグネチャ:
subscription { lpWithdrawRequests(where: SubLpWithdrawRequestsFilter!): [LpWithdrawRequest!]!}例:
subscription WatchWithdrawals($user: String!, $vault: String!) { lpWithdrawRequests(where: { depositor: $user, vault: $vault }) { shares status unlockEpoch vault { currentEpoch } }}用途:
- 出金可能時の通知。
- 状態追跡。
- 解除時のUI更新。
型リファレンス
Section titled “型リファレンス”LpVault
Section titled “LpVault”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!}LpDeposit
Section titled “LpDeposit”type LpDeposit { depositor: String! shares: Int! vault: LpVault!}LpDepositHistoryItem
Section titled “LpDepositHistoryItem”type LpDepositHistoryItem { id: Int! depositor: String! amount: Int! shares: Int! isWithdraw: Boolean! vault: LpVault! block: Block!}LpWithdrawRequest
Section titled “LpWithdrawRequest”type LpWithdrawRequest { depositor: String! shares: Int! status: String! unlockEpoch: Int! autoRedeem: Boolean! vault: LpVault!}RevenueInfo
Section titled “RevenueInfo”ボールト収益と運用成績を追跡します。
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 depositconst depositValue = (shares * sharePrice) / (10 ** decimals)// For pending withdrawalconst estimatedValue = (shares * currentSharePrice) / (10 ** decimals)出金までの時間
Section titled “出金までの時間”// Calculate epochs remainingconst epochsRemaining = unlockEpoch - currentEpoch
// Calculate time remaining (assuming epoch duration)const hoursRemaining = epochsRemaining * epochDurationHoursAPYの計算
Section titled “APYの計算”APYは過去の収益から計算します。
// Simplified APY calculationconst apy = (revenueInfo.NetProfit / tvl) * (365 / epochDurationDays)