コンテンツにスキップ
このページの翻訳は LLM によって生成されています。誤りに気づいた場合は GitHub で issue を開いてお知らせください。

Sai Keeper GraphQL クエリ

Sai スキル · GitHub の原文

以下は Jiyuu で公開されている英語の原文です。

Use this reference for indexed, app-facing Sai data: perp positions and history, SLP Vault history, Oracle prices, referral analytics, and live subscriptions. For live protocol state or contract-owned values, use contracts.md instead.

The deployed schema is the authority. Read it with a GraphQL introspection query or in the playground at the host root. The endpoint path is /query.

NetworkHTTPWebSocket
Mainnethttps://sai-keeper.nibiru.fi/querywss://sai-keeper.nibiru.fi/query
Testnet2https://sai-keeper.testnet-2.nibiru.fi/querywss://sai-keeper.testnet-2.nibiru.fi/query

Verify a field against the deployment you query. Mainnet and Testnet2 can run different Keeper versions.

The root Query type exposes domain objects: oracle, perp, lp, referral, appVersion, saiPoints, and explorer. Scope fields under their domain rather than querying them at the root.

DomainKey fieldsNotes
perptrade, trades, tradeHistory, borrowing, borrowings, statsUserPortfolio, traderFeeTierProgressIndexed trades, market borrowing state, and portfolio/fee-tier summaries. trades(where:) requires a trader address.
lpvaults, depositHistory, withdrawRequests, vaultStats, epochDurationDaysIndexed vault and LP history; not a replacement for live vault accounting.
oracletokens, token, tokenPricesUsdApp-indexed token metadata and prices. Use lastUpdatedBlock to assess freshness.
referralreferralCodes, referralTrades, referralRedemption, referralRedemptionTrader, referralClaims, referralStatsHistorical referral data keyed by referrer or trader.

There is no GraphQL fee root domain or fields such as feeTransactions in the current schema. For fee details, use Perp trade history fields such as openingFeeUsd and closingFeeUsd, contract fee queries, or database references as appropriate.

  • Perp query field trades uses PerpTradesFilter, whose required trader field can be narrowed by perpMarketId, perpCollateralId, and isOpen.
  • Perp query field tradeHistory uses PerpTradeHistoryFilter, whose required trader field returns the trader’s indexed mutations.
  • Lists accept their schema-defined order_by, order_desc, limit, and offset arguments. Do not assume that an order enum applies to another domain.
  • Many contract-sized values are GraphQL Int base units, including Perp trade collateral and open interest. Exceptions are deliberate: table Balance exposes amount as a string, and USD/price/percentage fields commonly use GraphQL Float.
  • GraphQL type Token does not expose decimal metadata. Table Balance includes token_info.decimals when a wallet or Sai balance subscription is relevant.

The current Subscription type provides exactly these fields:

FieldRequired filter or arguments
tokenPricesUsdOptional SubTokenPriceUsdFilter (tokenId)
perpTradesSubPerpTradesFilter! (trader)
perpTradeHistorySubPerpTradeHistoryFilter! (trader)
perpBorrowingsNone
perpBorrowingmarketId, collateralId
lpVaultsNone
lpDepositHistorySubLpDepositHistoryFilter! (depositor, vault)
lpWithdrawRequestsSubLpWithdrawRequestsFilter! (depositor, vault)
userBalancesSubUserBalancesFilter! (user)
userInfoSubUserFilter! (user)

No lpDeposits subscription exists in the current schema. For a user’s vault state, query the LP history/request fields or read live contract state according to the fact being requested.

query OpenTrades($trader: String!) {
perp {
trades(where: { trader: $trader, isOpen: true }) {
id
collateralAmount
leverage
isLong
state { positionValue liquidationPrice }
}
}
}
query ReferralHistory($referrer: String!) {
referral {
referralCodes(referrer: $referrer) { code active uniqueTraders volumeUSD }
referralRedemption(referrer: $referrer) { trader code active block { block block_ts } }
}
}
  • contracts.md: live Perp, Oracle, and vault queries.
  • rest.md: public aggregates rather than entity history.
  • Private agent skill sai-db: table ownership, aggregation, and freshness.