diff --git a/package.json b/package.json index cc82bc715..4d5426652 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polkaswap-exchange-web", - "version": "1.23.0", + "version": "1.23.1", "repository": { "type": "git", "url": "https://github.com/sora-xor/polkaswap-exchange-web.git" diff --git a/src/indexer/queries/assets.ts b/src/indexer/queries/assets.ts index 0fd9c0234..0fabceaa0 100644 --- a/src/indexer/queries/assets.ts +++ b/src/indexer/queries/assets.ts @@ -39,17 +39,13 @@ type SubqueryAssetData = SubqueryAssetEntity & { }; type SubsquidAssetData = SubsquidAssetEntity & { - hourSnapshots: { - nodes: SubsquidAssetSnapshotEntity[]; - }; - daySnapshots: { - nodes: SubsquidAssetSnapshotEntity[]; - }; + hourSnapshots: SubsquidAssetSnapshotEntity[]; + daySnapshots: SubsquidAssetSnapshotEntity[]; }; const SubqueryAssetsQuery = gql>` query AssetsQuery($after: Cursor, $ids: [String!], $dayTimestamp: Int, $weekTimestamp: Int) { - data: assets(after: $after, filter: { and: [{ id: { in: $ids } }, { liquidity: { greaterThan: "1" } }] }) { + data: assets(orderBy: ID_ASC, after: $after, filter: { and: [{ id: { in: $ids } }] }) { pageInfo { hasNextPage endCursor @@ -83,8 +79,8 @@ const SubqueryAssetsQuery = gql>` - query AssetsQuery($after: String, $ids: [String!], $dayTimestamp: Int, $weekTimestamp: Int) { - data: assets(after: $after, filter: { AND: [{ id_in: $ids }, { liquidity_gt: "1" }] }) { + query AssetsConnectionQuery($after: String, $ids: [String!], $dayTimestamp: Int, $weekTimestamp: Int) { + data: assetsConnection(orderBy: id_ASC, after: $after, where: { AND: [{ id_in: $ids }] }) { pageInfo { hasNextPage endCursor @@ -95,17 +91,33 @@ const SubsquidAssetsQuery = gql { }; const parse = (item: SubqueryAssetData | SubsquidAssetData): Record => { + const hourSnapshots = 'nodes' in item.hourSnapshots ? item.hourSnapshots.nodes : item.hourSnapshots; + const daySnapshots = 'nodes' in item.daySnapshots ? item.daySnapshots.nodes : item.daySnapshots; return { [item.id]: { reserves: FPNumber.fromCodecValue(item.liquidity ?? 0), - startPriceDay: new FPNumber(last(item.hourSnapshots.nodes)?.priceUSD?.open ?? 0), - startPriceWeek: new FPNumber(last(item.daySnapshots.nodes)?.priceUSD?.open ?? 0), - volumeDay: calcVolume(item.hourSnapshots.nodes), - volumeWeek: calcVolume(item.daySnapshots.nodes), + startPriceDay: new FPNumber(last(hourSnapshots)?.priceUSD?.open ?? 0), + startPriceWeek: new FPNumber(last(daySnapshots)?.priceUSD?.open ?? 0), + volumeDay: calcVolume(hourSnapshots), + volumeWeek: calcVolume(daySnapshots), }, }; };