From 9e25ed0dde1c65a298276945c36c8544d5d80203 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Wed, 29 May 2024 15:17:25 +0100 Subject: [PATCH 1/4] remove scoring rule filtering --- lib/gql/trending-markets.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/gql/trending-markets.ts b/lib/gql/trending-markets.ts index 54cde94a0..b0a1af19f 100644 --- a/lib/gql/trending-markets.ts +++ b/lib/gql/trending-markets.ts @@ -67,7 +67,6 @@ const getTrendingMarkets = async ( order: MarketOrderByInput.IdDesc, where: { status_eq: MarketStatus.Active, - scoringRule_eq: ScoringRule.AmmCdaHybrid, ...marketMetaFilter, }, }); From e5ebb85279d2e6730d9ab871f8c67aa7c101bec4 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Wed, 29 May 2024 15:52:25 +0100 Subject: [PATCH 2/4] fix market list --- lib/hooks/queries/useInfiniteMarkets.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/hooks/queries/useInfiniteMarkets.ts b/lib/hooks/queries/useInfiniteMarkets.ts index ae93bd716..208f4d71e 100644 --- a/lib/hooks/queries/useInfiniteMarkets.ts +++ b/lib/hooks/queries/useInfiniteMarkets.ts @@ -109,6 +109,10 @@ export const useInfiniteMarkets = ( scoringRule_eq: ScoringRule.AmmCdaHybrid, neoPool_isNull: withLiquidityOnly ? false : undefined, }, + { + scoringRule_eq: ScoringRule.Lmsr, + neoPool_isNull: withLiquidityOnly ? false : undefined, + }, ], }, ], From f2163eae7be037ddfe603b109a637d3fa4810e00 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Wed, 29 May 2024 16:00:59 +0100 Subject: [PATCH 3/4] make remaining scoring rule changes backwards compatible --- .../AssetTradingButtons.tsx | 22 ++++++++----------- .../liquidity/MarketLiquiditySection.tsx | 5 +---- lib/hooks/queries/useMarketSpotPrices.ts | 3 ++- lib/hooks/queries/usePortfolioPositions.ts | 11 ++++++++-- lib/util/calc-resolved-market-prices.ts | 3 ++- pages/markets/[marketid].tsx | 9 ++------ 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/components/assets/AssetActionButtons/AssetTradingButtons.tsx b/components/assets/AssetActionButtons/AssetTradingButtons.tsx index bf2ddcece..cbfbc4cf5 100644 --- a/components/assets/AssetActionButtons/AssetTradingButtons.tsx +++ b/components/assets/AssetActionButtons/AssetTradingButtons.tsx @@ -53,19 +53,15 @@ const AssetTradingButtons = ({ {tradeItem && ( setIsOpen(false)}> - {market?.scoringRule === ScoringRule.AmmCdaHybrid ? ( - - ) : ( - - )} + )} diff --git a/components/liquidity/MarketLiquiditySection.tsx b/components/liquidity/MarketLiquiditySection.tsx index a37a340fb..54e2c1553 100644 --- a/components/liquidity/MarketLiquiditySection.tsx +++ b/components/liquidity/MarketLiquiditySection.tsx @@ -28,10 +28,7 @@ export const MarketLiquiditySection = ({ market: FullMarketFragment; poll?: boolean; }) => { - const marketHasPool = - (market?.scoringRule === ScoringRule.Cpmm && market.pool != null) || - (market?.scoringRule === ScoringRule.AmmCdaHybrid && - market.neoPool != null); + const marketHasPool = market.neoPool != null; return ( <> diff --git a/lib/hooks/queries/useMarketSpotPrices.ts b/lib/hooks/queries/useMarketSpotPrices.ts index 1c88a72ec..03f5ca766 100644 --- a/lib/hooks/queries/useMarketSpotPrices.ts +++ b/lib/hooks/queries/useMarketSpotPrices.ts @@ -54,7 +54,8 @@ export const useMarketSpotPrices = ( if (!enabled) return; const spotPrices: MarketPrices = market?.status !== "Resolved" - ? market.scoringRule === ScoringRule.AmmCdaHybrid + ? market.scoringRule === ScoringRule.AmmCdaHybrid || + market.scoringRule === ScoringRule.Lmsr ? calcMarketPricesAmm2(amm2Pool!) : calcMarketPrices(market, basePoolBalance!, balances!) : calcResolvedMarketPrices(market); diff --git a/lib/hooks/queries/usePortfolioPositions.ts b/lib/hooks/queries/usePortfolioPositions.ts index c3b17f7b6..b7b275379 100644 --- a/lib/hooks/queries/usePortfolioPositions.ts +++ b/lib/hooks/queries/usePortfolioPositions.ts @@ -193,7 +193,11 @@ export const usePortfolioPositions = ( const pools = usePoolsByIds(filter); const markets = useMarketsByIds(filter); const amm2MarketIds = markets.data - ?.filter((market) => market.scoringRule === ScoringRule.AmmCdaHybrid) + ?.filter( + (market) => + market.scoringRule === ScoringRule.AmmCdaHybrid || + market.scoringRule === ScoringRule.Lmsr, + ) .map((m) => m.marketId); const { data: amm2SpotPrices } = useAmm2MarketSpotPrices(amm2MarketIds); @@ -318,7 +322,10 @@ export const usePortfolioPositions = ( price = calcResolvedMarketPrices(market).get(getIndexOf(assetId)); price24HoursAgo = price; } else { - if (market.scoringRule === ScoringRule.AmmCdaHybrid) { + if ( + market.scoringRule === ScoringRule.AmmCdaHybrid || + market.scoringRule === ScoringRule.Lmsr + ) { price = lookupAssetPrice(assetId, amm2SpotPrices); price24HoursAgo = lookupAssetPrice( diff --git a/lib/util/calc-resolved-market-prices.ts b/lib/util/calc-resolved-market-prices.ts index 9c8805c03..33aafa8ec 100644 --- a/lib/util/calc-resolved-market-prices.ts +++ b/lib/util/calc-resolved-market-prices.ts @@ -9,7 +9,8 @@ export const calcResolvedMarketPrices = ( market: FullMarketFragment, ): MarketPrices => { const assetIds = ( - market.scoringRule === ScoringRule.AmmCdaHybrid + market.scoringRule === ScoringRule.AmmCdaHybrid || + market.scoringRule === ScoringRule.Lmsr ? market.neoPool?.account.balances.map((b) => parseAssetIdString(b.assetId), ) diff --git a/pages/markets/[marketid].tsx b/pages/markets/[marketid].tsx index 19611df1b..9318a7348 100644 --- a/pages/markets/[marketid].tsx +++ b/pages/markets/[marketid].tsx @@ -346,12 +346,7 @@ const Market: NextPage = ({ const hasLiveTwitchStream = hasLiveTwitchStreamClient || hasLiveTwitchStreamServer; - const marketHasPool = - (market?.scoringRule === ScoringRule.Cpmm && - poolId != null && - poolIdLoading === false) || - (market?.scoringRule === ScoringRule.AmmCdaHybrid && - market.neoPool != null); + const marketHasPool = market.neoPool != null; const poolCreationDate = new Date( indexedMarket.pool?.createdAt ?? indexedMarket.neoPool?.createdAt ?? "", @@ -396,7 +391,7 @@ const Market: NextPage = ({ Twitch Stream From 7bd95db9b6247783d95fdd543b4ea14748386342 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Wed, 29 May 2024 16:05:27 +0100 Subject: [PATCH 4/4] fix build --- pages/markets/[marketid].tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/markets/[marketid].tsx b/pages/markets/[marketid].tsx index 9318a7348..5f0a5b2a2 100644 --- a/pages/markets/[marketid].tsx +++ b/pages/markets/[marketid].tsx @@ -346,7 +346,7 @@ const Market: NextPage = ({ const hasLiveTwitchStream = hasLiveTwitchStreamClient || hasLiveTwitchStreamServer; - const marketHasPool = market.neoPool != null; + const marketHasPool = market?.neoPool != null; const poolCreationDate = new Date( indexedMarket.pool?.createdAt ?? indexedMarket.neoPool?.createdAt ?? "",