Skip to content

Commit

Permalink
fixed disappear liq depth chart for blast
Browse files Browse the repository at this point in the history
  • Loading branch information
tncoskun committed Jan 3, 2025
1 parent c29ca97 commit 3a77ce1
Showing 1 changed file with 83 additions and 36 deletions.
119 changes: 83 additions & 36 deletions src/pages/platformAmbient/Trade/TradeCharts/TradeCandleStickChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,41 +330,48 @@ function TradeCandleStickChart(props: propsIF) {
);

const depthBidLeft = Math.min(
...unparsedLiquidityData.ranges.map((o: any) => {
return o.cumBidLiq !== undefined && o.cumBidLiq > 0
? o.cumBidLiq
: Infinity;
}),
...unparsedLiquidityData.ranges

.filter(
(o: any) =>
o.cumBidLiq !== undefined && o.cumBidLiq !== 0,
)
.map((i) => (i.cumBidLiq > 0 ? i.cumBidLiq : -i.cumBidLiq)),
);

const depthBidRight = Math.max(
...unparsedLiquidityData.ranges.map((o: any) => {
return o.cumBidLiq !== undefined && o.cumBidLiq > 0
? o.cumBidLiq
: 0;
}),
...unparsedLiquidityData.ranges
.filter(
(o: any) =>
o.cumBidLiq !== undefined && o.cumBidLiq !== 0,
)
.map((i) => (i.cumBidLiq > 0 ? i.cumBidLiq : -i.cumBidLiq)),
);

const depthAskLeft = Math.min(
...unparsedLiquidityData.ranges.map((o: any) => {
return o.cumAskLiq !== undefined && o.cumAskLiq > 0
? o.cumAskLiq
: Infinity;
}),
...unparsedLiquidityData.ranges
.filter(
(o: any) =>
o.cumAskLiq !== undefined && o.cumAskLiq !== 0,
)
.map((i) => (i.cumAskLiq > 0 ? i.cumAskLiq : -i.cumAskLiq)),
);

const depthAskRight = Math.max(
...unparsedLiquidityData.ranges.map((o: any) => {
const price = isDenomBase
? o.upperBoundInvPriceDecimalCorrected
: o.upperBoundPriceDecimalCorrected;
if (price > barThreshold / 10 && price < limitBoundary) {
return o.cumAskLiq !== undefined && o.cumAskLiq > 0
? o.cumAskLiq
: 0;
}
return 0;
}),
...unparsedLiquidityData.ranges
.filter((o: any) => {
const price = isDenomBase
? o.upperBoundInvPriceDecimalCorrected
: o.upperBoundPriceDecimalCorrected;

return (
price > barThreshold / 10 &&
price < limitBoundary &&
o.cumAskLiq !== undefined &&
o.cumAskLiq !== 0
);
})
.map((i) => (i.cumAskLiq > 0 ? i.cumAskLiq : -i.cumAskLiq)),
);

const liquidityScale = d3
Expand Down Expand Up @@ -436,13 +443,23 @@ function TradeCandleStickChart(props: propsIF) {
if (!isDenomBase) {
if (
data.cumAskLiq !== undefined &&
data.cumAskLiq !== '0' &&
data.cumAskLiq !== 0 &&
liqUpperPrices !== '+inf' &&
!Number.isNaN(depthLiquidityScale(data.cumAskLiq)) &&
!Number.isNaN(
depthLiquidityScale(
data.cumAskLiq > 0
? data.cumAskLiq
: -data.cumAskLiq,
),
) &&
liqUpperPrices < poolPriceDisplay * 10
) {
depthLiqBidData.push({
activeLiq: depthLiquidityScale(data.cumAskLiq),
activeLiq: depthLiquidityScale(
data.cumAskLiq > 0
? data.cumAskLiq
: -data.cumAskLiq,
),
liqPrices: liqUpperPrices,
deltaAverageUSD: data.deltaAverageUSD,
cumAverageUSD: data.cumAverageUSD,
Expand All @@ -456,11 +473,21 @@ function TradeCandleStickChart(props: propsIF) {

if (
data.cumBidLiq !== undefined &&
!Number.isNaN(depthLiquidityScale(data.cumBidLiq)) &&
!Number.isNaN(
depthLiquidityScale(
data.cumBidLiq > 0
? data.cumBidLiq
: -data.cumBidLiq,
),
) &&
liqLowerPrices > poolPriceDisplay / 10
) {
depthLiqAskData.push({
activeLiq: depthLiquidityScale(data.cumBidLiq),
activeLiq: depthLiquidityScale(
data.cumBidLiq > 0
? data.cumBidLiq
: -data.cumBidLiq,
),
liqPrices: liqLowerPrices,
deltaAverageUSD: data.deltaAverageUSD,
cumAverageUSD: data.cumAverageUSD,
Expand All @@ -474,13 +501,23 @@ function TradeCandleStickChart(props: propsIF) {
} else {
if (
data.cumBidLiq !== undefined &&
data.cumBidLiq !== '0' &&
data.cumBidLiq !== 0 &&
liqUpperPrices !== '+inf' &&
liqUpperPrices < poolPriceDisplay * 10 &&
!Number.isNaN(depthLiquidityScale(data.cumBidLiq))
!Number.isNaN(
depthLiquidityScale(
data.cumBidLiq > 0
? data.cumBidLiq
: -data.cumBidLiq,
),
)
) {
depthLiqBidData.push({
activeLiq: depthLiquidityScale(data.cumBidLiq),
activeLiq: depthLiquidityScale(
data.cumBidLiq > 0
? data.cumBidLiq
: -data.cumBidLiq,
),
liqPrices: liqUpperPrices,
deltaAverageUSD: data.deltaAverageUSD,
cumAverageUSD: data.cumAverageUSD,
Expand All @@ -495,12 +532,22 @@ function TradeCandleStickChart(props: propsIF) {
if (
data.cumAskLiq !== undefined &&
data.cumAskLiq !== '0' &&
!Number.isNaN(depthLiquidityScale(data.cumAskLiq)) &&
!Number.isNaN(
depthLiquidityScale(
data.cumAskLiq > 0
? data.cumAskLiq
: -data.cumAskLiq,
),
) &&
liqUpperPrices <= limitBoundary &&
liqUpperPrices > poolPriceDisplay / 10
) {
depthLiqAskData.push({
activeLiq: depthLiquidityScale(data.cumAskLiq),
activeLiq: depthLiquidityScale(
data.cumAskLiq > 0
? data.cumAskLiq
: -data.cumAskLiq,
),
liqPrices: liqLowerPrices,
deltaAverageUSD: data.deltaAverageUSD,
cumAverageUSD: data.cumAverageUSD,
Expand Down

0 comments on commit 3a77ce1

Please sign in to comment.