From 23827a7768b95ecbc42d1c4f58e96518570d6642 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Fri, 12 Jan 2024 11:49:29 +0200 Subject: [PATCH 1/4] start refactoring --- lib/gql/trending-markets.ts | 127 +++++++++++------------- lib/hooks/queries/useInfiniteMarkets.ts | 4 +- 2 files changed, 62 insertions(+), 69 deletions(-) diff --git a/lib/gql/trending-markets.ts b/lib/gql/trending-markets.ts index 870ede531..b79b1757a 100644 --- a/lib/gql/trending-markets.ts +++ b/lib/gql/trending-markets.ts @@ -15,6 +15,7 @@ import Decimal from "decimal.js"; import { GraphQLClient, gql } from "graphql-request"; import { DAY_SECONDS, ZTG } from "lib/constants"; import { hiddenMarketIds } from "lib/constants/markets"; +import { marketMetaFilter } from "lib/hooks/queries/constants"; import { ForeignAssetPrices, getBaseAssetPrices, @@ -23,71 +24,60 @@ import { MarketOutcome, MarketOutcomes } from "lib/types/markets"; import { getCurrentPrediction } from "lib/util/assets"; import { fetchAllPages } from "lib/util/fetch-all-pages"; import { parseAssetIdString } from "lib/util/parse-asset-id"; -import { marketMetaFilter } from "./constants"; -const poolChangesQuery = gql` - query PoolChanges($start: DateTime, $end: DateTime) { - historicalPools( +const marketChangesQuery = gql` + query MarketChanges($start: DateTime, $end: DateTime) { + historicalMarkets( where: { timestamp_gt: $start, volume_gt: "0", timestamp_lt: $end } orderBy: id_DESC ) { - poolId dVolume - } - } -`; - -const marketQuery = gql` - query Market($poolId: Int) { - markets( - where: { - pool: { poolId_eq: $poolId } - marketId_not_in: ${hiddenMarketIds} - hasValidMetaCategories_eq: true - categories_isNull: false - ${marketMetaFilter} - } - ) { - marketId - outcomeAssets - question - creation - img - baseAsset - creator - marketType { - categorical - scalar - } - categories { - color - name + market { + marketId } - pool { - volume - } - outcomeAssets - tags - period { - end - } - status - scalarType } } `; -const assetsQuery = gql` - query Assets($poolId: Int) { - assets(where: { pool: { poolId_eq: $poolId } }) { - pool { - poolId - } - price - assetId - } - } -`; +// const marketQuery = gql` +// query Market($poolId: Int) { +// markets( +// where: { +// pool: { poolId_eq: $poolId } +// marketId_not_in: ${hiddenMarketIds} +// hasValidMetaCategories_eq: true +// categories_isNull: false +// ${marketMetaFilter} +// } +// ) { +// marketId +// outcomeAssets +// question +// creation +// img +// baseAsset +// creator +// marketType { +// categorical +// scalar +// } +// categories { +// color +// name +// } +// pool { +// volume +// } +// outcomeAssets +// tags +// period { +// end +// } +// status +// scalarType +// } +// } +// `; const getTrendingMarkets = async ( client: GraphQLClient, @@ -98,12 +88,14 @@ const getTrendingMarkets = async ( new Date().getTime() - DAY_SECONDS * 7 * 1000, ).toISOString(); - const { historicalPools } = await client.request<{ - historicalPools: { + const { historicalMarkets } = await client.request<{ + historicalMarkets: { dVolume: string; - poolId: number; + market: { + marketId: number; + }; }[]; - }>(poolChangesQuery, { + }>(marketChangesQuery, { start: dateOneWeekAgo, end: now, }); @@ -116,6 +108,7 @@ const getTrendingMarkets = async ( where: { status_eq: MarketStatus.Active, scoringRule_eq: ScoringRule.Lmsr, + // ...marketMetaFilter, }, }); return markets; @@ -124,7 +117,7 @@ const getTrendingMarkets = async ( const basePrices = await getBaseAssetPrices(sdk); const trendingMarketIds = calcTrendingMarkets( - historicalPools, + historicalMarkets, basePrices, markets, ); @@ -189,7 +182,9 @@ const lookupPrice = ( const calcTrendingMarkets = ( transactions: { - poolId: number; + market: { + marketId: number; + }; dVolume: string; }[], basePrices: ForeignAssetPrices, @@ -200,16 +195,14 @@ const calcTrendingMarkets = ( // find total volume for each market transactions.forEach((transaction) => { - //for lsmr poolId === marketId - const marketId = transaction.poolId; + const marketId = transaction.market.marketId; if (markets.some((market) => market.marketId === marketId)) { - const volume = marketVolumes[transaction.poolId]; + const volume = marketVolumes[marketId]; if (volume) { - // for amm2 marketId === poolId - marketVolumes[transaction.poolId] = volume.plus(transaction.dVolume); + marketVolumes[marketId] = volume.plus(transaction.dVolume); } else { - marketVolumes[transaction.poolId] = new Decimal(transaction.dVolume); + marketVolumes[marketId] = new Decimal(transaction.dVolume); } } }); diff --git a/lib/hooks/queries/useInfiniteMarkets.ts b/lib/hooks/queries/useInfiniteMarkets.ts index 6eb7aea5b..4e0fca73a 100644 --- a/lib/hooks/queries/useInfiniteMarkets.ts +++ b/lib/hooks/queries/useInfiniteMarkets.ts @@ -20,7 +20,7 @@ export const rootKey = "markets-filtered"; const orderByMap = { [MarketsOrderBy.Newest]: MarketOrderByInput.MarketIdDesc, [MarketsOrderBy.Oldest]: MarketOrderByInput.MarketIdAsc, - [MarketsOrderBy.MostVolume]: MarketOrderByInput.PoolVolumeDesc, + [MarketsOrderBy.MostVolume]: "volume_DESC", [MarketsOrderBy.LeastVolume]: MarketOrderByInput.PoolVolumeAsc, }; @@ -98,7 +98,7 @@ export const useInfiniteMarkets = ( }, offset: !pageParam ? 0 : limit * pageParam, limit: limit, - order: orderByMap[orderBy], + order: orderByMap[orderBy] as MarketOrderByInput, //todo: fix this type once sdk updated, }); const resMarkets: Array = markets.map((market) => { From 1bce02d128c18097afad3393ca9a536927fef0b8 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Fri, 12 Jan 2024 12:27:04 +0200 Subject: [PATCH 2/4] Support new subquid version --- components/markets/MarketsList.tsx | 2 +- components/markets/SimilarMarketsSection.tsx | 4 +- components/markets/market-card/index.tsx | 2 +- lib/gql/featured-markets.ts | 2 +- lib/gql/get-network-stats.ts | 45 +++-------- lib/gql/trending-markets.ts | 4 +- lib/hooks/queries/useInfiniteMarkets.ts | 4 +- lib/hooks/queries/useMarketSpotPrices.ts | 4 +- lib/hooks/queries/usePortfolioPositions.ts | 2 +- lib/hooks/queries/useRecommendedMarkets.ts | 12 +-- package.json | 2 +- pages/api/og/[marketId].ts | 4 +- pages/liquidity/[poolid].tsx | 4 +- yarn.lock | 85 +++++++++----------- 14 files changed, 66 insertions(+), 110 deletions(-) diff --git a/components/markets/MarketsList.tsx b/components/markets/MarketsList.tsx index 5b245b52b..ecaf26212 100644 --- a/components/markets/MarketsList.tsx +++ b/components/markets/MarketsList.tsx @@ -103,7 +103,7 @@ const MarketsList = ({ className = "" }: MarketsListProps) => { />
{markets?.map((market) => { - const volume = market.pool?.volume ?? market.neoPool?.volume ?? 0; + const volume = market.volume; const scalarType = market.scalarType as ScalarRangeType; const stat = stats?.find((s) => s.marketId === market.marketId); const question = market.question ?? ""; diff --git a/components/markets/SimilarMarketsSection.tsx b/components/markets/SimilarMarketsSection.tsx index c2dfe8e98..f3e2325d9 100644 --- a/components/markets/SimilarMarketsSection.tsx +++ b/components/markets/SimilarMarketsSection.tsx @@ -74,9 +74,7 @@ export const SimilarMarketsSection = ({ neoPool={market?.neoPool} status={market.status} baseAsset={market.baseAsset} - volume={new Decimal(market.pool?.volume ?? 0) - .div(ZTG) - .toNumber()} + volume={new Decimal(market.volume ?? 0).div(ZTG).toNumber()} tags={ market.tags?.filter((tag): tag is string => tag !== null) ?? [] diff --git a/components/markets/market-card/index.tsx b/components/markets/market-card/index.tsx index d2173a03d..206c787c6 100644 --- a/components/markets/market-card/index.tsx +++ b/components/markets/market-card/index.tsx @@ -34,7 +34,7 @@ export interface IndexedMarketCardData { scalarType: ScalarRangeType | null; prediction: { name: string; price: number }; volume: number; - pool?: { poolId?: number; volume: string } | null; + pool?: { poolId?: number } | null; neoPool?: FullMarketFragment["neoPool"] | null; baseAsset: string; tags?: string[]; diff --git a/lib/gql/featured-markets.ts b/lib/gql/featured-markets.ts index aa74de0b3..7f7ce68ec 100644 --- a/lib/gql/featured-markets.ts +++ b/lib/gql/featured-markets.ts @@ -45,7 +45,7 @@ const getFeaturedMarkets = async ( creator: market.creator, img: market.img ?? "", prediction: prediction, - volume: new Decimal(market.pool?.volume ?? 0).div(ZTG).toNumber(), + volume: new Decimal(market.volume ?? 0).div(ZTG).toNumber(), baseAsset: market.baseAsset, outcomes: marketCategories, pool: market.pool, diff --git a/lib/gql/get-network-stats.ts b/lib/gql/get-network-stats.ts index 2fea2a95d..eb86c99b0 100644 --- a/lib/gql/get-network-stats.ts +++ b/lib/gql/get-network-stats.ts @@ -5,30 +5,24 @@ import { parseAssetIdString } from "lib/util/parse-asset-id"; import { getBaseAssetHistoricalPrices, lookupPrice } from "./historical-prices"; import { PoolOrderByInput, + MarketOrderByInput, NeoPoolOrderByInput, HistoricalSwapOrderByInput, } from "@zeitgeistpm/indexer"; +import { MarketsOrderBy } from "lib/types/market-filter"; export const getNetworkStats = async (sdk: Sdk) => { - const [marketCountBN, basePrices, pools, neoPools, historicalSwaps] = + const [marketCountBN, basePrices, markets, historicalSwaps] = await Promise.all([ sdk.api.query.marketCommons.marketCounter(), getBaseAssetHistoricalPrices(), fetchAllPages(async (pageNumber, limit) => { - const { pools } = await sdk.indexer.pools({ + const { markets } = await sdk.indexer.markets({ limit: limit, offset: pageNumber * limit, - order: PoolOrderByInput.IdAsc, + order: MarketOrderByInput.IdAsc, }); - return pools; - }), - fetchAllPages(async (pageNumber, limit) => { - const { neoPools } = await sdk.indexer.neoPools({ - limit: limit, - offset: pageNumber * limit, - order: NeoPoolOrderByInput.IdAsc, - }); - return neoPools; + return markets; }), fetchAllPages(async (pageNumber, limit) => { const { historicalSwaps } = await sdk.indexer.historicalSwaps({ @@ -40,28 +34,14 @@ export const getNetworkStats = async (sdk: Sdk) => { }), ]); - const totalPoolVolumeUsd = pools.reduce((total, pool) => { - const poolCreationBaseAssetPrice = lookupPrice( - basePrices, - parseAssetIdString(pool.baseAsset) as BaseAssetId, - new Date(pool.createdAt).getTime(), - ); - - const volumeUsd = new Decimal(pool.volume).mul( - poolCreationBaseAssetPrice ?? 0, - ); - - return total.plus(volumeUsd); - }, new Decimal(0)); - - const totalNeopoolVolumeUsd = pools.reduce((total, pool) => { + const totalMarketVolumeUsd = markets.reduce((total, market) => { const poolCreationBaseAssetPrice = lookupPrice( basePrices, - parseAssetIdString(pool.baseAsset) as BaseAssetId, - new Date(pool.createdAt).getTime(), + parseAssetIdString(market.baseAsset) as BaseAssetId, + new Date(market.pool?.createdAt ?? market.neoPool?.createdAt).getTime(), ); - const volumeUsd = new Decimal(pool.volume).mul( + const volumeUsd = new Decimal(market.volume).mul( poolCreationBaseAssetPrice ?? 0, ); @@ -76,9 +56,6 @@ export const getNetworkStats = async (sdk: Sdk) => { return { marketCount: marketCountBN.toNumber(), tradersCount, - volumeUsd: totalNeopoolVolumeUsd - .plus(totalPoolVolumeUsd) - .div(ZTG) - .toNumber(), + volumeUsd: totalMarketVolumeUsd.div(ZTG).toNumber(), }; }; diff --git a/lib/gql/trending-markets.ts b/lib/gql/trending-markets.ts index b79b1757a..4ddbe3bac 100644 --- a/lib/gql/trending-markets.ts +++ b/lib/gql/trending-markets.ts @@ -151,9 +151,7 @@ const getTrendingMarkets = async ( img: market.img ?? "", prediction: prediction, creator: market.creator, - volume: Number( - new Decimal(market.neoPool?.volume ?? 0).div(ZTG).toFixed(0), - ), + volume: Number(new Decimal(market?.volume ?? 0).div(ZTG).toFixed(0)), baseAsset: market.baseAsset, outcomes: marketCategories, pool: market.pool ?? null, diff --git a/lib/hooks/queries/useInfiniteMarkets.ts b/lib/hooks/queries/useInfiniteMarkets.ts index 4e0fca73a..4cfbf72c0 100644 --- a/lib/hooks/queries/useInfiniteMarkets.ts +++ b/lib/hooks/queries/useInfiniteMarkets.ts @@ -20,8 +20,8 @@ export const rootKey = "markets-filtered"; const orderByMap = { [MarketsOrderBy.Newest]: MarketOrderByInput.MarketIdDesc, [MarketsOrderBy.Oldest]: MarketOrderByInput.MarketIdAsc, - [MarketsOrderBy.MostVolume]: "volume_DESC", - [MarketsOrderBy.LeastVolume]: MarketOrderByInput.PoolVolumeAsc, + [MarketsOrderBy.MostVolume]: MarketOrderByInput.VolumeDesc, + [MarketsOrderBy.LeastVolume]: MarketOrderByInput.VolumeAsc, }; const validMarketWhereInput: MarketWhereInput = { diff --git a/lib/hooks/queries/useMarketSpotPrices.ts b/lib/hooks/queries/useMarketSpotPrices.ts index e24b942d1..02ae0706e 100644 --- a/lib/hooks/queries/useMarketSpotPrices.ts +++ b/lib/hooks/queries/useMarketSpotPrices.ts @@ -99,11 +99,11 @@ const calcMarketPrices = ( const outcomeWeights = market.pool.weights.filter( (weight) => weight.assetId.toLocaleLowerCase() !== - market.pool?.baseAsset.toLocaleLowerCase(), + market.baseAsset.toLocaleLowerCase(), ); //base weight is equal to the sum of all other assets - const baseWeight = new Decimal(market.pool.totalWeight).div(2); + const baseWeight = new Decimal(market?.pool.totalWeight ?? 0).div(2); outcomeWeights.forEach((weight, index) => { const spotPrice = calcSpotPrice( diff --git a/lib/hooks/queries/usePortfolioPositions.ts b/lib/hooks/queries/usePortfolioPositions.ts index 9408ab62f..e997bb164 100644 --- a/lib/hooks/queries/usePortfolioPositions.ts +++ b/lib/hooks/queries/usePortfolioPositions.ts @@ -295,7 +295,7 @@ export const usePortfolioPositions = ( ): null | Decimal => { const poolZtgBalance = poolsZtgBalances[pool.poolId]?.toNumber(); - const ztgWeight = new Decimal(pool.totalWeight).div(2); + const ztgWeight = new Decimal(pool.totalWeight ?? 0).div(2); const assetWeight = getAssetWeight(pool, assetId).unwrap(); const poolAssetBalance = poolAssetBalances?.get( diff --git a/lib/hooks/queries/useRecommendedMarkets.ts b/lib/hooks/queries/useRecommendedMarkets.ts index e86b08718..b04a83a27 100644 --- a/lib/hooks/queries/useRecommendedMarkets.ts +++ b/lib/hooks/queries/useRecommendedMarkets.ts @@ -26,14 +26,12 @@ export const useRecommendedMarkets = (marketId?: number, limit = 2) => { if (enabled) { const { markets: similarMarkets } = await sdk.indexer.markets({ limit, - order: [MarketOrderByInput.PoolVolumeDesc], + order: [MarketOrderByInput.VolumeDesc], where: { tags_containsAny: market?.tags, status_eq: MarketStatus.Active, marketId_not_eq: marketId, - pool: { - volume_gt: "0", - }, + volume_gt: "0", }, }); @@ -45,13 +43,11 @@ export const useRecommendedMarkets = (marketId?: number, limit = 2) => { } else { const { markets: popularMarkets } = await sdk.indexer.markets({ limit, - order: [MarketOrderByInput.PoolVolumeDesc], + order: [MarketOrderByInput.VolumeDesc], where: { status_eq: MarketStatus.Active, marketId_not_eq: marketId, - pool: { - volume_gt: "0", - }, + volume_gt: "0", }, }); return { diff --git a/package.json b/package.json index e3dbcdc8c..dd6cc6aea 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@zeitgeistpm/avatara-nft-sdk": "^1.3.1", "@zeitgeistpm/avatara-react": "^1.3.2", "@zeitgeistpm/avatara-util": "^1.2.0", - "@zeitgeistpm/sdk": "2.49.1", + "@zeitgeistpm/sdk": "2.51.0", "@zeitgeistpm/utility": "^2.24.1", "axios": "^0.21.4", "boring-avatars": "^1.6.1", diff --git a/pages/api/og/[marketId].ts b/pages/api/og/[marketId].ts index 9b6f3cfc7..8fbdc3562 100644 --- a/pages/api/og/[marketId].ts +++ b/pages/api/og/[marketId].ts @@ -57,9 +57,7 @@ export default async function ( prediction = getCurrentPrediction(market.assets as any, market); } - const volume = new Decimal(market.pool?.volume ?? market.neoPool?.volume ?? 0) - .div(ZTG) - .toFixed(2); + const volume = new Decimal(market?.volume ?? 0).div(ZTG).toFixed(2); const ends = moment(Number(market.period.end)).format("MMM Do, YYYY"); diff --git a/pages/liquidity/[poolid].tsx b/pages/liquidity/[poolid].tsx index dead569af..234be9bf3 100644 --- a/pages/liquidity/[poolid].tsx +++ b/pages/liquidity/[poolid].tsx @@ -88,12 +88,12 @@ const PoolDetails: NextPage = () => { const { data: pool, isInitialLoading, isFetched } = usePool({ poolId }); const { data: market } = useMarket({ poolId }); - const baseAssetId = parseAssetIdString(pool?.baseAsset); + const baseAssetId = parseAssetIdString(market?.baseAsset); const { data: metadata } = useAssetMetadata(baseAssetId); const { data: liquidity } = usePoolLiquidity({ poolId }); const volume = isIndexedData(pool) - ? new Decimal(pool.volume).div(ZTG).toFixed(2) + ? new Decimal(market?.volume ?? 0).div(ZTG).toFixed(2) : null; const swapFee = Number(pool?.swapFee); diff --git a/yarn.lock b/yarn.lock index cca4cc6db..63672f32a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4179,25 +4179,14 @@ __metadata: languageName: node linkType: hard -"@zeitgeistpm/augment-api@npm:^2.21.0": - version: 2.22.0 - resolution: "@zeitgeistpm/augment-api@npm:2.22.0" +"@zeitgeistpm/augment-api@npm:^2.26.0": + version: 2.26.0 + resolution: "@zeitgeistpm/augment-api@npm:2.26.0" peerDependencies: "@polkadot/api-base": "*" "@polkadot/rpc-core": "*" "@polkadot/types": "*" - checksum: 7976146bf19c72a3b92dd01eeecf6dd8513ba0769ad68e602c78f9568f9744aeb04ad00b658e9357206cd101c465f04e32356f61b1485784de91991f73a6f341 - languageName: node - linkType: hard - -"@zeitgeistpm/augment-api@npm:^2.25.1": - version: 2.25.1 - resolution: "@zeitgeistpm/augment-api@npm:2.25.1" - peerDependencies: - "@polkadot/api-base": "*" - "@polkadot/rpc-core": "*" - "@polkadot/types": "*" - checksum: 57dd122445ce623e02bf4cc3ee91968d88711d35952d9295c5be4d7b0e4181fd643ebd13ec3a3548649ef172bb7634276043dd45325fe83a798b27b555643f93 + checksum: e18fa3394246ec2d877dc91df532af03896ea85dd136741bf987c6e8a37ce664a67a1012e211394a01bfc452a520e9c48deb64aee7a1ae9a9e9745c4c7b580e1 languageName: node linkType: hard @@ -4267,40 +4256,40 @@ __metadata: languageName: node linkType: hard -"@zeitgeistpm/indexer@npm:^3.20.1": - version: 3.20.1 - resolution: "@zeitgeistpm/indexer@npm:3.20.1" +"@zeitgeistpm/indexer@npm:^3.22.0": + version: 3.22.0 + resolution: "@zeitgeistpm/indexer@npm:3.22.0" dependencies: graphql: ^16.6.0 graphql-request: ^5.0.0 graphql-tag: ^2.12.6 - checksum: 4d8fa03c08eb154abdbed0e62e7ae4e2de6ae09677f6a2cf318a2c74a039e48fd5eaac5f26feefd3adfe5278a92e3481ddbc9cc9261cf4ece53f2f39dceb0f77 + checksum: cf66a5a00343d8a76cb9a6745e41efc457ab1da6e3a3cec8a0e2a68edc8bee2cee2e0dcd36fc68dcaa22bf7d6671f8375822ebff8ff5b613cf9142b23cabe9e1 languageName: node linkType: hard -"@zeitgeistpm/rpc@npm:^2.14.0": - version: 2.14.0 - resolution: "@zeitgeistpm/rpc@npm:2.14.0" +"@zeitgeistpm/rpc@npm:^2.15.0": + version: 2.15.0 + resolution: "@zeitgeistpm/rpc@npm:2.15.0" dependencies: - "@zeitgeistpm/augment-api": ^2.21.0 - "@zeitgeistpm/utility": ^2.24.0 + "@zeitgeistpm/augment-api": ^2.26.0 + "@zeitgeistpm/utility": ^2.25.0 peerDependencies: "@polkadot/api": "*" "@polkadot/keyring": "*" "@polkadot/types": "*" - checksum: 3bb452b262e16f9169070889d298e1148564965b20a8ebbaccc35a2b14efb76f90f38ef6c1e822b1f9e3d82ab6c4f0ae4cad290458cd8be28b6a2b18932f3f6a + checksum: 2ffe91ca3101d688aa5da2e4dccf31b6c87dfc1c6994c7a8b9ae6a1c64cc274db65273f544ff32441f9801b431af2f499f02482a18669cbc0572a2f1b893144e languageName: node linkType: hard -"@zeitgeistpm/sdk@npm:2.49.1": - version: 2.49.1 - resolution: "@zeitgeistpm/sdk@npm:2.49.1" +"@zeitgeistpm/sdk@npm:2.51.0": + version: 2.51.0 + resolution: "@zeitgeistpm/sdk@npm:2.51.0" dependencies: - "@zeitgeistpm/augment-api": ^2.25.1 - "@zeitgeistpm/indexer": ^3.20.1 - "@zeitgeistpm/rpc": ^2.14.0 - "@zeitgeistpm/utility": ^2.24.1 - "@zeitgeistpm/web3.storage": ^2.15.0 + "@zeitgeistpm/augment-api": ^2.26.0 + "@zeitgeistpm/indexer": ^3.22.0 + "@zeitgeistpm/rpc": ^2.15.0 + "@zeitgeistpm/utility": ^2.25.0 + "@zeitgeistpm/web3.storage": ^2.16.0 cids: ^1.1.9 decimal.js: ^10.4.3 human-object-diff: ^3.0.0 @@ -4314,7 +4303,7 @@ __metadata: "@polkadot/api": "*" "@polkadot/types": "*" "@polkadot/util": "*" - checksum: b0b6059c3bc8a018ecb148f91b54641f522aa74448468337562d6507340a2cd70df3594514f9edde367c27f8f2aa4cec6136679f5660f89fd7b7d3d09f5e83e1 + checksum: d24e1e394d4af2b93382c76bd5ee04bb9e9258be93e4ded55eeae9ec48709eafff91960b15aa5f9c670ad9ceda02d9095aa882c08b9877a908e989c82f890017 languageName: node linkType: hard @@ -4376,7 +4365,7 @@ __metadata: "@zeitgeistpm/avatara-nft-sdk": ^1.3.1 "@zeitgeistpm/avatara-react": ^1.3.2 "@zeitgeistpm/avatara-util": ^1.2.0 - "@zeitgeistpm/sdk": 2.49.1 + "@zeitgeistpm/sdk": 2.51.0 "@zeitgeistpm/utility": ^2.24.1 autoprefixer: 10.2.5 axios: ^0.21.4 @@ -4446,9 +4435,9 @@ __metadata: languageName: unknown linkType: soft -"@zeitgeistpm/utility@npm:^2.24.0": - version: 2.24.0 - resolution: "@zeitgeistpm/utility@npm:2.24.0" +"@zeitgeistpm/utility@npm:^2.24.1": + version: 2.24.1 + resolution: "@zeitgeistpm/utility@npm:2.24.1" dependencies: decimal.js: ^10.4.3 lodash.omit: ^4.5.0 @@ -4458,13 +4447,13 @@ __metadata: "@polkadot/api": "*" "@polkadot/types": "*" "@polkadot/util": "*" - checksum: d671238f8b6baacd0c75bba2612754dde3d96586aa799f98d1b50d0de15c23d3c63868482c45aad4ee97884a88cdee5b7f0ab3b91201f4b1365262e27a79faec + checksum: 75416aca267e198e4f4f444ce80ad0988b3b3435430898121753773ac6873d84d7855b7ee9b4946dd8178b6d84c582124dda96d97cb681ee4c5b25fb84546133 languageName: node linkType: hard -"@zeitgeistpm/utility@npm:^2.24.1": - version: 2.24.1 - resolution: "@zeitgeistpm/utility@npm:2.24.1" +"@zeitgeistpm/utility@npm:^2.25.0": + version: 2.25.0 + resolution: "@zeitgeistpm/utility@npm:2.25.0" dependencies: decimal.js: ^10.4.3 lodash.omit: ^4.5.0 @@ -4474,15 +4463,15 @@ __metadata: "@polkadot/api": "*" "@polkadot/types": "*" "@polkadot/util": "*" - checksum: 75416aca267e198e4f4f444ce80ad0988b3b3435430898121753773ac6873d84d7855b7ee9b4946dd8178b6d84c582124dda96d97cb681ee4c5b25fb84546133 + checksum: eb74e58bc28bfac1eb315f9b008b563e4ae8d1fa70b133d9ef9d16c4fdc7cf7aa731f1d155a5bf26a336b693fb0aea773f558bc60a6a1ec999289b42852fc190 languageName: node linkType: hard -"@zeitgeistpm/web3.storage@npm:^2.15.0": - version: 2.15.0 - resolution: "@zeitgeistpm/web3.storage@npm:2.15.0" +"@zeitgeistpm/web3.storage@npm:^2.16.0": + version: 2.16.0 + resolution: "@zeitgeistpm/web3.storage@npm:2.16.0" dependencies: - "@zeitgeistpm/utility": ^2.24.0 + "@zeitgeistpm/utility": ^2.25.0 cids: ^1.1.9 ipfs-http-client: ^60.0.0 ipfs-only-hash: ^4.0.0 @@ -4491,7 +4480,7 @@ __metadata: up: ^1.0.2 peerDependencies: "@polkadot/util": "*" - checksum: 4b6255ac7a0f30f1dd7654ee792107689cc44c6ecedb55192592dbd68040a459437d69f9eedb3a5a82b575e07f48c345795d9954302a3baa73fbf7f1d5bddf7b + checksum: 3cafd120a3a68c510949369998035eaefbd48c27d6a98efe26e3c92e1e6b1bd429a5e47b314e35f88dff05d03b9b275ebbed40d4fa60494f1ea815a4c58dd2de languageName: node linkType: hard From c8064c44697e959fef4cefb60f12187d14dcea20 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Fri, 12 Jan 2024 12:49:21 +0200 Subject: [PATCH 3/4] more fixes --- components/markets/MarketHeader.tsx | 4 +--- lib/gql/markets.ts | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/components/markets/MarketHeader.tsx b/components/markets/MarketHeader.tsx index 86d74cddc..cb66e4a20 100644 --- a/components/markets/MarketHeader.tsx +++ b/components/markets/MarketHeader.tsx @@ -345,9 +345,7 @@ const MarketHeader: FC<{ const [showMarketHistory, setShowMarketHistory] = useState(false); const starts = Number(period.start); const ends = Number(period.end); - const volume = new Decimal(pool?.volume ?? neoPool?.volume ?? 0) - .div(ZTG) - .toNumber(); + const volume = new Decimal(market.volume).div(ZTG).toNumber(); const { outcome, by } = getMarketStatusDetails( marketType, diff --git a/lib/gql/markets.ts b/lib/gql/markets.ts index ae35b2c61..28f57ced0 100644 --- a/lib/gql/markets.ts +++ b/lib/gql/markets.ts @@ -25,16 +25,15 @@ const marketQuery = gql` marketId description baseAsset + volume pool { poolId createdAt - volume baseAsset } neoPool { createdAt collateral - volume } question slug @@ -90,6 +89,7 @@ export interface MarketPageIndexedData { question: string; description: string | PortableTextBlock[]; status: MarketStatus; + volume: string; period: { block: string[]; start: string; @@ -105,14 +105,12 @@ export interface MarketPageIndexedData { resolvedOutcome: string; pool?: { poolId: number; - volume: string; createdAt: string; baseAsset: string; }; neoPool?: { collateral: string; createdAt: string; - volume: string; }; scalarType: ScalarRangeType; marketType: { From 58c8301818fb87d47cdab57b6b37d3cbc02945b9 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Fri, 12 Jan 2024 13:18:25 +0200 Subject: [PATCH 4/4] removed commented code --- lib/gql/trending-markets.ts | 42 +------------------------------------ 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/lib/gql/trending-markets.ts b/lib/gql/trending-markets.ts index 4ddbe3bac..866704288 100644 --- a/lib/gql/trending-markets.ts +++ b/lib/gql/trending-markets.ts @@ -39,46 +39,6 @@ const marketChangesQuery = gql` } `; -// const marketQuery = gql` -// query Market($poolId: Int) { -// markets( -// where: { -// pool: { poolId_eq: $poolId } -// marketId_not_in: ${hiddenMarketIds} -// hasValidMetaCategories_eq: true -// categories_isNull: false -// ${marketMetaFilter} -// } -// ) { -// marketId -// outcomeAssets -// question -// creation -// img -// baseAsset -// creator -// marketType { -// categorical -// scalar -// } -// categories { -// color -// name -// } -// pool { -// volume -// } -// outcomeAssets -// tags -// period { -// end -// } -// status -// scalarType -// } -// } -// `; - const getTrendingMarkets = async ( client: GraphQLClient, sdk: Sdk, @@ -108,7 +68,7 @@ const getTrendingMarkets = async ( where: { status_eq: MarketStatus.Active, scoringRule_eq: ScoringRule.Lmsr, - // ...marketMetaFilter, + ...marketMetaFilter, }, }); return markets;