@@ -4,7 +4,7 @@ import { useEffect, useMemo, useRef } from 'react'
44import { auctionQueries } from 'uniswap/src/data/rest/auctions/auctionQueries'
55import { EVMUniverseChainId } from 'uniswap/src/features/chains/types'
66import { logger } from 'utilities/src/logger/logger'
7- import { CHART_CONSTRAINTS , MAX_RENDERABLE_BARS } from '~/components/Toucan/Auction/BidDistributionChart/constants'
7+ import { MAX_RENDERABLE_BARS } from '~/components/Toucan/Auction/BidDistributionChart/constants'
88import { AuctionProgressState , BidDistributionData } from '~/components/Toucan/Auction/store/types'
99import { useAuctionStore , useAuctionStoreActions } from '~/components/Toucan/Auction/store/useAuctionStore'
1010import { getPollingIntervalMs } from '~/utils/averageBlockTimeMs'
@@ -32,22 +32,19 @@ function areBidMapsEqual(a: BidDistributionData | undefined, b: BidDistributionD
3232}
3333
3434/**
35- * Caps concentration data to MAX_RENDERABLE_BARS ticks.
35+ * Caps concentration data to MAX_RENDERABLE_BARS ticks above floor price .
3636 *
37- * The cap window is centered around the clearing price (with a few ticks below
38- * and the rest above) so bids near the clearing price are always preserved.
39- * Falls back to a floor-based window when clearing price is unavailable.
37+ * Includes all bids from floor price upward (so bids below clearing are preserved),
38+ * but caps the upper range to avoid extreme outlier bids blowing up the chart.
4039 */
4140function capConcentrationData ( {
4241 concentration,
4342 floorPriceQ96,
4443 tickSizeQ96,
45- clearingPriceQ96,
4644} : {
4745 concentration : Record < string , { volume : string } > | undefined
4846 floorPriceQ96 : string | undefined
4947 tickSizeQ96 : string | undefined
50- clearingPriceQ96 : string | undefined
5148} ) : { cappedConcentration : Record < string , { volume : string } > ; capped : boolean ; excludedVolume : bigint } {
5249 if ( ! concentration || ! floorPriceQ96 || ! tickSizeQ96 ) {
5350 return { cappedConcentration : concentration ?? { } , capped : false , excludedVolume : 0n }
@@ -60,25 +57,9 @@ function capConcentrationData({
6057 return { cappedConcentration : concentration , capped : false , excludedVolume : 0n }
6158 }
6259
63- let minPriceQ96 : bigint
64- let maxPriceQ96 : bigint
65-
66- if ( clearingPriceQ96 ) {
67- // Align with computeTickWindow's asymmetric logic: keep only a few ticks below
68- // clearing price and fill the rest of the budget above. This avoids holding
69- // thousands of below-clearing bids in memory that will never render.
70- const belowTicks = BigInt ( CHART_CONSTRAINTS . PREFERRED_TICKS_BELOW_CLEARING_PRICE )
71- const clearing = BigInt ( clearingPriceQ96 )
72- minPriceQ96 = clearing - belowTicks * tickSize
73- if ( minPriceQ96 < floor ) {
74- minPriceQ96 = floor
75- }
76- maxPriceQ96 = minPriceQ96 + tickSize * BigInt ( MAX_RENDERABLE_BARS - 1 )
77- } else {
78- // Fallback: cap from floor when clearing price is unknown
79- minPriceQ96 = floor
80- maxPriceQ96 = floor + tickSize * BigInt ( MAX_RENDERABLE_BARS - 1 )
81- }
60+ // Include everything from floor up to MAX_RENDERABLE_BARS ticks above floor
61+ const minPriceQ96 = floor
62+ const maxPriceQ96 = floor + tickSize * BigInt ( MAX_RENDERABLE_BARS - 1 )
8263
8364 const filteredEntries : Array < [ string , { volume : string } ] > = [ ]
8465 let excludedVolume = 0n
@@ -91,7 +72,7 @@ function capConcentrationData({
9172 excludedVolume += BigInt ( value . volume )
9273 }
9374 } catch {
94- // Ignore unparsable entries; they won't be rendered.
75+ // Ignore unparsable entries
9576 }
9677 }
9778
@@ -152,10 +133,9 @@ interface UseLoadBidDistributionDataParams {
152133 */
153134export function useLoadBidDistributionData ( { chainId, auctionAddress } : UseLoadBidDistributionDataParams ) : void {
154135 const { setBidDistributionData } = useAuctionStoreActions ( )
155- const { floorPrice, tickSize, clearingPrice , isAuctionActive } = useAuctionStore ( ( state ) => ( {
136+ const { floorPrice, tickSize, isAuctionActive } = useAuctionStore ( ( state ) => ( {
156137 floorPrice : state . auctionDetails ?. floorPrice ,
157138 tickSize : state . auctionDetails ?. tickSize ,
158- clearingPrice : state . auctionDetails ?. clearingPrice ,
159139 isAuctionActive : state . progress . state === AuctionProgressState . IN_PROGRESS ,
160140 } ) )
161141
@@ -208,7 +188,6 @@ export function useLoadBidDistributionData({ chainId, auctionAddress }: UseLoadB
208188 concentration,
209189 floorPriceQ96 : floorPrice ,
210190 tickSizeQ96 : tickSize ,
211- clearingPriceQ96 : clearingPrice ,
212191 } )
213192
214193 // Sort prices numerically (ascending) before creating the map
@@ -238,5 +217,5 @@ export function useLoadBidDistributionData({ chainId, auctionAddress }: UseLoadB
238217 prevBidMapRef . current = bidMap
239218 setBidDistributionData ( bidMap , excludedVolume > 0n ? excludedVolume . toString ( ) : null )
240219 }
241- } , [ data , setBidDistributionData , floorPrice , tickSize , clearingPrice ] )
220+ } , [ data , setBidDistributionData , floorPrice , tickSize ] )
242221}
0 commit comments