Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: query limit #143

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
11 changes: 7 additions & 4 deletions src/apis/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const getPoolPerformance = async ({
)
const poolVolumes = fillAndSortByTimestamp(
poolPerformance.poolVolumes,
24 * 60 * 60,
300,
volumeFromTimestamp,
volumeToTimestamp,
(timestamp: number) => {
Expand Down Expand Up @@ -311,7 +311,7 @@ export const getPoolPerformance = async ({
)
const poolSpreadProfits = fillAndSortByTimestamp(
poolPerformance.poolSpreadProfits,
60 * 60,
300,
spreadProfitFromTimestamp,
spreadProfitToTimestamp,
(timestamp: number) => {
Expand Down
Loading