Skip to content

Commit

Permalink
Merge pull request #133 from clober-dex/feat/fix-interval
Browse files Browse the repository at this point in the history
feat: fix interval
  • Loading branch information
Dorvin authored Oct 31, 2024
2 parents c01cff3 + 70bb072 commit 85f7686
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/apis/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const fetchPoolPerformance = async (
}>(
chainId,
'getPoolPerformanceData',
'query getPoolPerformanceData($poolKey: String!, $volumeFrom: BigInt!, $snapshotFrom: BigInt!, $snapshotIntervalType: String!, $spreadProfitFrom: BigInt!) { poolVolumes(where: { poolKey: $poolKey, intervalType: "1d", 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: "1h", timestamp_gte: $spreadProfitFrom, } ) { id intervalType timestamp accumulatedProfitInUsd } }',
'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 } }',
{
poolKey,
volumeFrom: volumeFromTimestamp,
Expand Down
4 changes: 2 additions & 2 deletions src/model/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class Pool {
export type PoolVolumeDto = {
id: string
poolKey: `0x${string}`
intervalType: '1d'
intervalType: '5m'
timestamp: bigint
currencyAVolume: bigint
currencyBVolume: bigint
Expand All @@ -208,7 +208,7 @@ export type PoolSnapshotDto = {

export type PoolSpreadProfitDto = {
id: string
intervalType: '1h'
intervalType: '5m'
timestamp: bigint
accumulatedProfitInUsd: string
}
4 changes: 2 additions & 2 deletions src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export type Currency6909Amount = { currency: Currency6909; value: string }

export type PoolVolumeDto = {
poolKey: `0x${string}`
intervalType: '1d'
intervalType: '5m'
timestamp: number
currencyAVolume: CurrencyAmount
currencyBVolume: CurrencyAmount
Expand All @@ -163,7 +163,7 @@ export type PoolSnapshotDto = {
}

export type PoolSpreadProfitDto = {
intervalType: '1h'
intervalType: '5m'
timestamp: number
accumulatedProfitInUsd: string
}
Expand Down
4 changes: 2 additions & 2 deletions src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export const getPoolPerformance = async ({
const emptyPoolVolume: ModelPoolVolume = {
id: '',
poolKey: pool.key,
intervalType: '1d',
intervalType: '5m',
timestamp: BigInt(timestamp),
currencyAVolume: 0n,
currencyBVolume: 0n,
Expand Down Expand Up @@ -309,7 +309,7 @@ export const getPoolPerformance = async ({
(timestamp: number) => {
const emptyPoolSpreadProfit: ModelPoolSpreadProfit = {
id: '',
intervalType: '1h',
intervalType: '5m',
timestamp: BigInt(timestamp),
accumulatedProfitInUsd: '0',
}
Expand Down

0 comments on commit 85f7686

Please sign in to comment.