Skip to content

Commit

Permalink
fix: rawToBase
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorvin committed Mar 21, 2024
1 parent 6e161f1 commit 4110296
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4110296

Please sign in to comment.