Skip to content

Commit

Permalink
use new priceNative method
Browse files Browse the repository at this point in the history
  • Loading branch information
CapCap committed Dec 12, 2024
1 parent 1c168b2 commit 26c10b7
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/typescript/frontend/src/app/dexscreener/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ import {
type toLiquidityEventModel,
type toSwapEventModel,
} from "@sdk/indexer-v2/types";
import Big from "big.js";
import { calculateRealReserves } from "@sdk/markets";
import { calculateCurvePrice, calculateRealReserves } from "@sdk/markets";
import { toCoinDecimalString } from "../../lib/utils/decimals";
import { DECIMALS } from "@sdk/const";
import { symbolEmojisToPairId } from "./util";
Expand Down Expand Up @@ -182,8 +181,6 @@ export interface EventsResponse {
events: Event[];
}

const TWO_TO_64 = new Big(2).pow(64);

export function toDexscreenerSwapEvent(
event: ReturnType<typeof toSwapEventModel>
): SwapEvent & BlockInfo {
Expand Down Expand Up @@ -213,9 +210,7 @@ export function toDexscreenerSwapEvent(
asset1: toCoinDecimalString(quote, DECIMALS),
};

const priceNative = new Big(event.swap.avgExecutionPriceQ64.toString())
.div(TWO_TO_64)
.toFixed(64);
const priceNative = calculateCurvePrice(event.state).toFixed(50).toString();

if (!event.blockAndEvent) throw new Error("blockAndEvent is undefined");

Expand Down

0 comments on commit 26c10b7

Please sign in to comment.