diff --git a/components/liquidity/MarketLiquiditySection.tsx b/components/liquidity/MarketLiquiditySection.tsx index 6fd422950..120a582f0 100644 --- a/components/liquidity/MarketLiquiditySection.tsx +++ b/components/liquidity/MarketLiquiditySection.tsx @@ -89,12 +89,12 @@ const LiquidityHeaderButtonItem: FC< }; const LiquidityHeader = ({ market }: { market: FullMarketFragment }) => { - const { pool } = market; + const { pool, neoPool } = market; const { data: liquidity } = usePoolLiquidity( pool?.poolId ? { poolId: pool.poolId } : undefined, ); - const swapFee = new Decimal(Number(pool?.swapFee) ?? 0) + const swapFee = new Decimal(Number(pool?.swapFee ?? neoPool?.swapFee ?? 0)) .div(ZTG) .mul(100) .toNumber(); diff --git a/components/markets/MarketChart.tsx b/components/markets/MarketChart.tsx index a48f07212..e6da40349 100644 --- a/components/markets/MarketChart.tsx +++ b/components/markets/MarketChart.tsx @@ -27,7 +27,7 @@ const MarketChart = ({ }: { marketId: number; chartSeries: ChartSeries[]; - baseAsset: string; + baseAsset?: string; poolCreationDate: Date; marketStatus: MarketStatus; resolutionDate: Date; diff --git a/components/markets/MarketHeader.tsx b/components/markets/MarketHeader.tsx index e963045b7..86706b543 100644 --- a/components/markets/MarketHeader.tsx +++ b/components/markets/MarketHeader.tsx @@ -323,14 +323,22 @@ const MarketHeader: FC<{ rejectReason, promotionData, }) => { - const { categories, status, question, period, marketType, pool, scalarType } = - market; + const { + categories, + status, + question, + period, + marketType, + pool, + scalarType, + neoPool, + } = market; const [showMarketHistory, setShowMarketHistory] = useState(false); const starts = Number(period.start); const ends = Number(period.end); - const volume = pool?.volume - ? new Decimal(pool?.volume).div(ZTG).toNumber() - : 0; + const volume = new Decimal(pool?.volume ?? neoPool?.volume ?? 0) + .div(ZTG) + .toNumber(); const { outcome, by } = getMarketStatusDetails( marketType, diff --git a/components/markets/MarketsList.tsx b/components/markets/MarketsList.tsx index aca8d36d7..38fa8991f 100644 --- a/components/markets/MarketsList.tsx +++ b/components/markets/MarketsList.tsx @@ -133,6 +133,7 @@ const MarketsList = ({ className = "" }: MarketsListProps) => { marketType={marketType} scalarType={scalarType} pool={pool} + neoPool={market.neoPool} status={market.status} baseAsset={market.baseAsset} volume={new Decimal(volume).div(ZTG).toNumber()} diff --git a/components/markets/SimilarMarketsSection.tsx b/components/markets/SimilarMarketsSection.tsx index be9a3c351..c2dfe8e98 100644 --- a/components/markets/SimilarMarketsSection.tsx +++ b/components/markets/SimilarMarketsSection.tsx @@ -71,6 +71,7 @@ export const SimilarMarketsSection = ({ marketType={marketType} scalarType={scalarType} pool={market.pool ?? null} + neoPool={market?.neoPool} status={market.status} baseAsset={market.baseAsset} volume={new Decimal(market.pool?.volume ?? 0) diff --git a/components/markets/market-card/index.tsx b/components/markets/market-card/index.tsx index 9bff90a47..5640baab8 100644 --- a/components/markets/market-card/index.tsx +++ b/components/markets/market-card/index.tsx @@ -17,6 +17,7 @@ import { } from "@zeitgeistpm/sdk"; import { lookupAssetImagePath } from "lib/constants/foreign-asset"; import Image from "next/image"; +import { FullMarketFragment } from "@zeitgeistpm/indexer"; export interface IndexedMarketCardData { marketId: number; @@ -30,6 +31,7 @@ export interface IndexedMarketCardData { prediction: { name: string; price: number }; volume: number; pool?: { poolId?: number; volume: string } | null; + neoPool?: FullMarketFragment["neoPool"] | null; baseAsset: string; tags?: string[]; status: string; @@ -50,13 +52,11 @@ export interface MarketCardProps extends IndexedMarketCardData { const MarketCardPredictionBar = ({ prediction: { name, price }, - pool, }: { prediction: { name: string; price: number }; - pool: {}; }) => { // check if market has liquidity - if (Object.keys(pool).length !== 0) { + if (price != null) { const impliedPercentage = Math.round(Number(price) * 100); return ( @@ -180,6 +180,7 @@ export const MarketCard = ({ marketType, prediction, pool, + neoPool, scalarType, volume, baseAsset, @@ -257,9 +258,9 @@ export const MarketCard = ({ : formatNumberCompact(Number(prediction.name))} - ) : pool && marketType?.categorical ? ( - - ) : pool && scalarType && Object.keys(pool).length !== 0 ? ( + ) : (pool || neoPool) && marketType?.categorical ? ( + + ) : (pool || neoPool) && scalarType ? ( => { if (ids.length === 0) return []; - const response = await client.request<{ + const { marketStats } = await client.request<{ marketStats: MarketStats[]; }>(query, { ids }); - return response.marketStats; + return marketStats; }; diff --git a/lib/gql/markets.ts b/lib/gql/markets.ts index 56ae827a4..a7b373e93 100644 --- a/lib/gql/markets.ts +++ b/lib/gql/markets.ts @@ -30,6 +30,11 @@ const marketQuery = gql` volume baseAsset } + neoPool { + createdAt + collateral + volume + } question slug status @@ -97,12 +102,17 @@ export interface MarketPageIndexedData { categories: { name: string; color: string }[]; outcomeAssets: string[]; resolvedOutcome: string; - pool: { + pool?: { poolId: number; volume: string; createdAt: string; baseAsset: string; }; + neoPool?: { + collateral: string; + createdAt: string; + volume: string; + }; scalarType: ScalarRangeType; marketType: { scalar: string[]; diff --git a/pages/markets/[marketid].tsx b/pages/markets/[marketid].tsx index b162cdadb..582ef6440 100644 --- a/pages/markets/[marketid].tsx +++ b/pages/markets/[marketid].tsx @@ -278,13 +278,22 @@ const Market: NextPage = ({ )} - {chartSeries && indexedMarket?.pool?.poolId ? ( + {chartSeries && (indexedMarket?.pool || indexedMarket.neoPool) ? (
@@ -292,9 +301,9 @@ const Market: NextPage = ({ ) : ( <> )} - {marketHasPool && market.neoPool == null && ( -
-
+ {marketHasPool === false && ( +
+