From 5525f4cd5939769b14dd8b0874d88a5238b01e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B8b=C4=97rt=C3=B8?= <106074508+EchoDex@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:23:28 +0400 Subject: [PATCH] feat: update indexer query --- package.json | 2 +- src/IndexerApi.ts | 24 +++++++++++++++++------- src/interface.ts | 8 ++++---- src/query/index.ts | 12 ++++++------ 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 70d572e..a403d83 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@compolabs/spark-orderbook-ts-sdk", - "version": "1.11.0", + "version": "1.11.1", "type": "module", "main": "./dist/index.сjs", "module": "./dist/index.js", diff --git a/src/IndexerApi.ts b/src/IndexerApi.ts index 1bfdb6e..240a7a0 100644 --- a/src/IndexerApi.ts +++ b/src/IndexerApi.ts @@ -77,8 +77,18 @@ export class IndexerApi extends GraphClient { order_by: { timestamp: $orderBy } ) { id - trade_price - trade_size + market + tradeSize + tradePrice + buyer + buyOrderId + buyerBaseAmount + buyerQuoteAmount + seller + sellOrderId + sellerBaseAmount + sellerQuoteAmount + sellerIsMaker timestamp } } @@ -123,15 +133,15 @@ export class IndexerApi extends GraphClient { const query = gql` query TradeOrderEventQuery($where: TradeOrderEvent_bool_exp) { TradeOrderEvent(where: $where) { - trade_size - trade_price + tradeSize + tradePrice } } `; type TradeOrderEventPartial = Pick< TradeOrderEvent, - "trade_size" | "trade_price" + "tradeSize" | "tradePrice" >; const response = await this.client.query<{ @@ -156,8 +166,8 @@ export class IndexerApi extends GraphClient { const data = response.data.TradeOrderEvent.reduce( (prev, currentData) => { - const price = BigInt(currentData.trade_price); - const size = BigInt(currentData.trade_size); + const price = BigInt(currentData.tradePrice); + const size = BigInt(currentData.tradeSize); prev.volume24h += size; if (prev.high24h < price) { diff --git a/src/interface.ts b/src/interface.ts index add80b3..1ae767a 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -160,8 +160,8 @@ export interface Order { id: string; asset: string; amount: string; - initial_amount: string; - order_type: OrderType; + initialAmount: string; + orderType: OrderType; price: string; status: Status; user: string; @@ -176,8 +176,8 @@ export interface GetTradeOrderEventsParams { export interface TradeOrderEvent { id: string; timestamp: string; - trade_price: string; - trade_size: string; + tradePrice: string; + tradeSize: string; } export type Volume = { diff --git a/src/query/index.ts b/src/query/index.ts index 91e1a01..1c874bf 100644 --- a/src/query/index.ts +++ b/src/query/index.ts @@ -10,7 +10,7 @@ export const getOrdersQuery = ( const where: any = {}; if (params.orderType) { - where.order_type = { _eq: params.orderType }; + where.orderType = { _eq: params.orderType }; } if (params.market) { @@ -52,8 +52,8 @@ export const getOrdersQuery = ( id asset amount - initial_amount - order_type + initialAmount + orderType price status user @@ -81,7 +81,7 @@ export const getActiveOrdersQuery = ( const where: any = {}; if (params.orderType) { - where.order_type = { _eq: params.orderType }; + where.orderType = { _eq: params.orderType }; } if (params.market) { @@ -114,8 +114,8 @@ export const getActiveOrdersQuery = ( id asset amount - initial_amount - order_type + initialAmount + orderType price status user