From 41102964b3204ff538601a1e53a41b28b45bfa20 Mon Sep 17 00:00:00 2001 From: Xavier Date: Thu, 21 Mar 2024 15:37:19 +0900 Subject: [PATCH] fix: rawToBase --- src/helpers.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/helpers.ts b/src/helpers.ts index df4be72..36bf99d 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -44,15 +44,7 @@ export function rawToBase( rawAmount: BigInt, price: BigInt, ): BigInt { - const base = Token.load(book.base) as Token - const quote = Token.load(book.quote) as Token - const basePrecision = BigInt.fromI32(10).pow(base.decimals.toI32() as u8) - const quotePrecision = BigInt.fromI32(10).pow(quote.decimals.toI32() as u8) - return rawAmount - .times(book.unit) - .times(pricePrecision) - .times(basePrecision) - .div(quotePrecision.times(price)) + return rawAmount.times(book.unit).times(pricePrecision).div(price) } export function rawToQuote(book: Book, rawAmount: BigInt): BigInt {