diff --git a/package-lock.json b/package-lock.json index 5853ccd..fa2056d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@clober/v2-sdk", - "version": "0.0.88", + "version": "0.0.89", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@clober/v2-sdk", - "version": "0.0.88", + "version": "0.0.89", "license": "MIT", "dependencies": { "axios": "^1.7.7", diff --git a/package.json b/package.json index 6f407f7..0be1584 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@clober/v2-sdk", - "version": "0.0.88", + "version": "0.0.89", "description": "🛠 An SDK for building applications on top of Clober V2", "files": [ "dist" diff --git a/src/apis/pool.ts b/src/apis/pool.ts index c59a7c2..25c1760 100644 --- a/src/apis/pool.ts +++ b/src/apis/pool.ts @@ -29,12 +29,14 @@ export const fetchPoolPerformance = async ( poolVolumes: PoolVolumeDto[] poolSnapshots: PoolSnapshotDto[] poolSnapshotBefore: PoolSnapshotDto[] + poolSnapshots2: PoolSnapshotDto[] + poolSnapshots3: PoolSnapshotDto[] poolSpreadProfits: PoolSpreadProfitDto[] } }>( chainId, 'getPoolPerformanceData', - 'query getPoolPerformanceData($poolKey: String!, $volumeFrom: BigInt!, $snapshotFrom: BigInt!, $snapshotIntervalType: String!, $spreadProfitFrom: BigInt!) { poolVolumes( where: {poolKey: $poolKey, intervalType: "5m", timestamp_gte: $volumeFrom} ) { id poolKey intervalType timestamp currencyAVolume currencyBVolume bookACurrencyAVolume bookACurrencyBVolume bookBCurrencyAVolume bookBCurrencyBVolume } poolSnapshots( first: 1000 skip: 0 orderBy: timestamp orderDirection: asc where: {poolKey: $poolKey, intervalType: $snapshotIntervalType, timestamp_gte: $snapshotFrom} ) { id poolKey intervalType timestamp price liquidityA liquidityB totalSupply } poolSnapshotBefore: poolSnapshots( first: 1 skip: 0 orderBy: timestamp orderDirection: desc where: {poolKey: $poolKey, intervalType: $snapshotIntervalType, timestamp_lt: $snapshotFrom} ) { id poolKey intervalType timestamp price liquidityA liquidityB totalSupply } poolSpreadProfits(where: {intervalType: "5m", timestamp_gte: $spreadProfitFrom}) { id intervalType timestamp accumulatedProfitInUsd } }', + 'query getPoolPerformanceData($poolKey: String!, $volumeFrom: BigInt!, $snapshotFrom: BigInt!, $snapshotIntervalType: String!, $spreadProfitFrom: BigInt!) { poolVolumes( first: 1000, skip: 0, orderBy: timestamp orderDirection: asc where: {poolKey: $poolKey, intervalType: "5m", timestamp_gte: $volumeFrom} ) { id poolKey intervalType timestamp currencyAVolume currencyBVolume bookACurrencyAVolume bookACurrencyBVolume bookBCurrencyAVolume bookBCurrencyBVolume } poolSnapshots( first: 1000 skip: 0 orderBy: timestamp orderDirection: asc where: {poolKey: $poolKey, intervalType: $snapshotIntervalType, timestamp_gte: $snapshotFrom} ) { id poolKey intervalType timestamp price liquidityA liquidityB totalSupply } poolSnapshotBefore: poolSnapshots( first: 1 skip: 0 orderBy: timestamp orderDirection: desc where: {poolKey: $poolKey, intervalType: $snapshotIntervalType, timestamp_lt: $snapshotFrom} ) { id poolKey intervalType timestamp price liquidityA liquidityB totalSupply } poolSnapshots2: poolSnapshots( first: 1000 skip: 1000 orderBy: timestamp orderDirection: asc where: {poolKey: $poolKey, intervalType: $snapshotIntervalType, timestamp_gte: $snapshotFrom} ) { id poolKey intervalType timestamp price liquidityA liquidityB totalSupply } poolSnapshots3: poolSnapshots( first: 1000 skip: 2000 orderBy: timestamp orderDirection: asc where: {poolKey: $poolKey, intervalType: $snapshotIntervalType, timestamp_gte: $snapshotFrom} ) { id poolKey intervalType timestamp price liquidityA liquidityB totalSupply } poolSpreadProfits( first: 1000, skip: 0, orderBy: timestamp orderDirection: asc where: {intervalType: "5m", timestamp_gte: $spreadProfitFrom} ) { id intervalType timestamp accumulatedProfitInUsd } }', { poolKey, volumeFrom: volumeFromTimestamp, @@ -45,9 +47,10 @@ export const fetchPoolPerformance = async ( ) return { poolVolumes: result.data.poolVolumes, - poolSnapshots: result.data.poolSnapshotBefore.concat( - result.data.poolSnapshots, - ), + poolSnapshots: result.data.poolSnapshotBefore + .concat(result.data.poolSnapshots) + .concat(result.data.poolSnapshots2) + .concat(result.data.poolSnapshots3), poolSpreadProfits: result.data.poolSpreadProfits, } } diff --git a/src/view.ts b/src/view.ts index 0d03001..ea7d655 100644 --- a/src/view.ts +++ b/src/view.ts @@ -271,7 +271,7 @@ export const getPoolPerformance = async ({ ) const poolVolumes = fillAndSortByTimestamp( poolPerformance.poolVolumes, - 24 * 60 * 60, + 300, volumeFromTimestamp, volumeToTimestamp, (timestamp: number) => { @@ -311,7 +311,7 @@ export const getPoolPerformance = async ({ ) const poolSpreadProfits = fillAndSortByTimestamp( poolPerformance.poolSpreadProfits, - 60 * 60, + 300, spreadProfitFromTimestamp, spreadProfitToTimestamp, (timestamp: number) => {