このページの翻訳は LLM によって生成されています。誤りに気づいた場合は GitHub で issue を開いてお知らせください。
手数料APIリファレンス
取引単位の手数料、日次統計、プロトコル・トレーダーの集計を取得します。
feeTransaction
Section titled “feeTransaction”IDで手数料取引を取得します。
シグネチャ:
feeTransaction(id: ID!): FeeTransactionパラメーター:
id:文字列の取引ID。
戻り値: FeeTransaction またはnull。
例:
query GetFeeTransaction { fee { feeTransaction(id: "abc123") { id traderAddress feeType totalFeeCharged govFee vaultFee referrerAllocation triggerFee collateralDenom blockHeight blockTime } }}feeTransactions
Section titled “feeTransactions”絞り込みとページ分割付きの手数料取引一覧。
シグネチャ:
feeTransactions( filter: FeeTransactionFilter limit: Int = 100 offset: Int = 0): [FeeTransaction!]!パラメーター:
filter:任意フィルター。traderAddress:トレーダー。collateralDenom:担保。feeType:OPENINGまたはCLOSING。fromDate:開始日、RFC3339。toDate:終了日、RFC3339。minAmount:最低額。maxAmount:最高額。
limit:最大件数、既定100。offset:スキップ件数、既定0。
戻り値: FeeTransaction の配列。
例:利用者の手数料
query GetUserFees($trader: String!) { fee { feeTransactions( filter: { traderAddress: $trader } limit: 50 ) { id feeType totalFeeCharged govFee vaultFee referrerAllocation triggerFee blockTime tradeId orderType } }}例:期間で絞り込み
query GetFeesInRange { fee { feeTransactions( filter: { fromDate: "2024-01-01T00:00:00Z" toDate: "2024-01-31T23:59:59Z" feeType: OPENING } limit: 100 ) { id traderAddress totalFeeCharged blockTime } }}例:大きな手数料のみ
query GetLargeFees { fee { feeTransactions( filter: { minAmount: 1000000 # Filter fees > 1,000,000 } limit: 20 ) { id traderAddress totalFeeCharged feeType } }}用途:
- 利用者の手数料履歴。
- プロトコル手数料監視。
- 大口取引追跡。
- 期間別分析。
feeDailyStats
Section titled “feeDailyStats”日次の手数料集計を取得します。
シグネチャ:
feeDailyStats( filter: FeeDailyStatsFilter limit: Int = 30 offset: Int = 0): [FeeDailyStats!]!パラメーター:
filter:任意フィルター。traderAddress:トレーダー。collateralDenom:担保。fromDate、toDate:開始・終了日。protocolWide:trueならプロトコル全体。
limit:最大件数、既定30。offset:スキップ件数、既定0。
戻り値: FeeDailyStats の配列。
例:プロトコルの日次統計
query GetProtocolDailyStats { fee { feeDailyStats( filter: { protocolWide: true } limit: 30 ) { date collateralDenom openingFeeCount openingFeeTotal openingGovFee openingReferrerFee openingVaultFee closingFeeCount closingFeeTotal closingGovFee closingReferrerFee closingVaultFee closingTriggerFee totalBadDebt updatedAt } }}例:トレーダーの日次統計
query GetTraderDailyStats($trader: String!) { fee { feeDailyStats( filter: { traderAddress: $trader fromDate: "2024-01-01T00:00:00Z" } limit: 90 ) { date openingFeeTotal closingFeeTotal totalBadDebt } }}用途:
- 日次チャート。
- 過去の手数料分析。
- 収益追跡。
- トレーダー別内訳。
feeAnalytics
Section titled “feeAnalytics”追加指標を含む詳細分析を取得します。
シグネチャ:
feeAnalytics( filter: FeeDailyStatsFilter limit: Int = 30 offset: Int = 0): [FeeAnalytics!]!パラメーター: feeDailyStats と同じ。
戻り値: FeeAnalytics の配列。
例:
query GetFeeAnalytics { fee { feeAnalytics( filter: { protocolWide: true } limit: 30 ) { date collateralDenom openingCount openingTotal openingGov openingReferrer openingVault openingTrigger closingCount closingTotal closingGov closingReferrer closingVault closingTrigger totalFeesAll avgFeeMultiplier totalBadDebt traderAddress } }}feeDailyStatsとの違い:
avgFeeMultiplierを含みます。- 新規・決済合計の
totalFeesAll。 - より詳しいトリガー内訳。
用途:
- 高度な分析UI。
- 手数料倍率追跡。
- 全体レポート。
protocolFeeSummary
Section titled “protocolFeeSummary”指定期間のプロトコル全体集計。
シグネチャ:
protocolFeeSummary( collateralDenom: String fromDate: Time toDate: Time): ProtocolFeeSummary!パラメーター:
collateralDenom:任意の担保フィルター。fromDate、toDate:任意の開始・終了日。
戻り値: ProtocolFeeSummary。
例:プロトコルの全期間集計
query GetProtocolSummary { fee { protocolFeeSummary { period { fromDate toDate } totalFees totalOpeningFees totalClosingFees totalGovFees totalVaultFees totalReferrerFees totalTriggerFees totalBadDebt openingCount closingCount uniqueTraders avgFeeMultiplier } }}例:月次集計
query GetMonthlySummary { fee { protocolFeeSummary( fromDate: "2024-01-01T00:00:00Z" toDate: "2024-01-31T23:59:59Z" ) { totalFees totalOpeningFees totalClosingFees uniqueTraders openingCount closingCount } }}例:担保別集計
query GetCollateralSummary { fee { protocolFeeSummary( collateralDenom: "uusdc" fromDate: "2024-01-01T00:00:00Z" ) { totalFees totalVaultFees totalGovFees uniqueTraders } }}用途:
- プロトコル収益レポート。
- KPI追跡。
- 運用指標。
- 期間比較。
traderFeeSummary
Section titled “traderFeeSummary”特定トレーダーの集計。
シグネチャ:
traderFeeSummary( traderAddress: String! collateralDenom: String fromDate: Time toDate: Time): TraderFeeSummary!パラメーター:
traderAddress:必須アドレス。collateralDenom:任意の担保フィルター。fromDate、toDate:任意の開始・終了日。
戻り値: TraderFeeSummary。
例:トレーダーの全期間集計
query GetTraderSummary($trader: String!) { fee { traderFeeSummary(traderAddress: $trader) { traderAddress period { fromDate toDate } totalFees totalOpeningFees totalClosingFees totalReferrerAllocation totalBadDebt openingCount closingCount avgFeeMultiplier } }}例:トレーダーの月次集計
query GetTraderMonthlySummary($trader: String!) { fee { traderFeeSummary( traderAddress: $trader fromDate: "2024-01-01T00:00:00Z" toDate: "2024-01-31T23:59:59Z" ) { totalFees openingCount closingCount avgFeeMultiplier } }}用途:
- 利用者ダッシュボード。
- 取引費用分析。
- 手数料最適化。
- 紹介追跡。
型リファレンス
Section titled “型リファレンス”FeeTransaction
Section titled “FeeTransaction”手数料取引の全詳細。
type FeeTransaction { id: ID! traderAddress: String! tradeId: Int! tradeIndex: Int! feeType: FeeType! collateralDenom: String! totalFeeCharged: Int! govFee: Int! netGovFee: Int! vaultFee: Int! referrerAllocation: Int! triggerFee: Int! openFeeComponent: Int triggerFeeComponent: Int triggererReward: Int collateralLeft: Int badDebt: Int! feeMultiplier: Float! orderType: String catalystAddress: String blockHeight: Int! blockTime: Time! createdAt: Time!}主なフィールド:
totalFeeCharged:支払った総額。govFee:ガバナンス。vaultFee:LPボールト。referrerAllocation:紹介者配分。triggerFee:注文実行者。badDebt:担保不足の清算による不良債権。feeMultiplier:適用した動的倍率。
FeeDailyStats
Section titled “FeeDailyStats”日次手数料集計。
type FeeDailyStats { date: Time! collateralDenom: String! traderAddress: String openingFeeCount: Int! openingFeeTotal: Int! openingGovFee: Int! openingReferrerFee: Int! openingTriggerFee: Int! openingVaultFee: Int! closingFeeCount: Int! closingFeeTotal: Int! closingGovFee: Int! closingReferrerFee: Int! closingTriggerFee: Int! closingVaultFee: Int! totalBadDebt: Int! updatedAt: Time!}FeeAnalytics
Section titled “FeeAnalytics”追加指標を含む詳細分析。
type FeeAnalytics { date: Time! collateralDenom: String! traderAddress: String openingCount: Int! openingTotal: Int! openingGov: Int! openingReferrer: Int! openingTrigger: Int! openingVault: Int! closingCount: Int! closingTotal: Int! closingGov: Int! closingReferrer: Int! closingTrigger: Int! closingVault: Int! totalFeesAll: Int! avgFeeMultiplier: Float! totalBadDebt: Int!}ProtocolFeeSummary
Section titled “ProtocolFeeSummary”プロトコル全体の集計。
type ProtocolFeeSummary { period: TimePeriod! totalFees: Int! totalOpeningFees: Int! totalClosingFees: Int! totalGovFees: Int! totalVaultFees: Int! totalReferrerFees: Int! totalTriggerFees: Int! totalBadDebt: Int! openingCount: Int! closingCount: Int! uniqueTraders: Int! avgFeeMultiplier: Float!}TraderFeeSummary
Section titled “TraderFeeSummary”トレーダー別の集計。
type TraderFeeSummary { traderAddress: String! period: TimePeriod! totalFees: Int! totalOpeningFees: Int! totalClosingFees: Int! totalReferrerAllocation: Int! totalBadDebt: Int! openingCount: Int! closingCount: Int! avgFeeMultiplier: Float!}FeeType:
OPENING:新規時の手数料。CLOSING:決済時の手数料。
プロトコルの総収益
Section titled “プロトコルの総収益”const totalRevenue = protocolFeeSummary.totalGovFees + protocolFeeSummary.totalVaultFees取引当たり平均手数料
Section titled “取引当たり平均手数料”const avgOpeningFee = protocolFeeSummary.totalOpeningFees / protocolFeeSummary.openingCount
const avgClosingFee = protocolFeeSummary.totalClosingFees / protocolFeeSummary.closingCount手数料配分率
Section titled “手数料配分率”const calculateBreakdown = (summary) => { const total = summary.totalFees return { govPct: (summary.totalGovFees / total) * 100, vaultPct: (summary.totalVaultFees / total) * 100, referrerPct: (summary.totalReferrerFees / total) * 100, triggerPct: (summary.totalTriggerFees / total) * 100 }}手数料額の変換
Section titled “手数料額の変換”// Fees are in smallest unit, convert to decimalconst convertFee = (feeAmount, decimals) => { return feeAmount / (10 ** decimals)}
// Example: USDC fees (6 decimals)const feeUSDC = convertFee(1000000, 6) // = 1.0 USDC期間指定クエリ
Section titled “期間指定クエリ”// Get current month statsconst now = new Date()const firstDay = new Date(now.getFullYear(), now.getMonth(), 1)const lastDay = new Date(now.getFullYear(), now.getMonth() + 1, 0)
const query = ` query GetMonthlyStats { fee { protocolFeeSummary( fromDate: "${firstDay.toISOString()}" toDate: "${lastDay.toISOString()}" ) { totalFees uniqueTraders } } }`大量データのページ分割
Section titled “大量データのページ分割”// Fetch all fee transactions in batchesconst fetchAllFees = async (trader, limit = 100) => { let allFees = [] let offset = 0 let hasMore = true
while (hasMore) { const { data } = await client.query({ query: FEE_TRANSACTIONS_QUERY, variables: { trader, limit, offset } })
const fees = data.fee.feeTransactions allFees = allFees.concat(fees)
hasMore = fees.length === limit offset += limit }
return allFees}日次統計のキャッシュ
Section titled “日次統計のキャッシュ”// Cache daily stats (they don't change)const cacheDailyStats = new Map()
const getDailyStats = async (date) => { const dateKey = date.toISOString().split('T')[0]
if (cacheDailyStats.has(dateKey)) { return cacheDailyStats.get(dateKey) }
const stats = await fetchDailyStats(date) cacheDailyStats.set(dateKey, stats) return stats}