Skip to content

Commit

Permalink
feat: Resolve pool list bins
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss committed Dec 9, 2023
1 parent 1d86c6e commit 6bc1c9b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/web/src/components/earn/pool-info/PoolInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ const PoolInfo: React.FC<PoolInfoProps> = ({ pool, routeItem, themeKey }) => {
return <DoubleLogo left={rewards[0].token.logoURI} right={rewards[1].token.logoURI} size={20} />;
}, [rewards]);

const resolvedBins = useMemo(() => {
const length = 20;
if (pool.bins.length <= length) {
return pool.bins;
}
const resolvedRate = pool.bins.length / length;
return Array.from({ length }, (_, index) => {
const pickIndex = Math.round((index + 1) * resolvedRate) - 1;
console.log(pickIndex)
return pool.bins[pickIndex];
})
}, [pool.bins]);

return (
<PoolInfoWrapper
onClick={() => routeItem(poolId)}
Expand Down Expand Up @@ -76,7 +89,7 @@ const PoolInfo: React.FC<PoolInfoProps> = ({ pool, routeItem, themeKey }) => {
tokenA={tokenA}
tokenB={tokenB}
currentTick={pool.currentTick}
bins={pool.bins}
bins={resolvedBins}
mouseover
themeKey={themeKey}
/>
Expand Down

0 comments on commit 6bc1c9b

Please sign in to comment.