From 7ba5c1c6e3e86fd4a2975225cf40cb7fdfd8978a Mon Sep 17 00:00:00 2001 From: Binye Barwe Date: Sat, 16 Dec 2023 21:09:02 -0500 Subject: [PATCH] quantityToUiBase --- package.json | 2 +- ts/client/src/market.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 42908a777..a8d1edef5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openbook-dex/openbook-v2", - "version": "0.0.24", + "version": "0.0.25", "description": "Typescript Client for openbook-v2 program.", "repository": "https://github.com/openbook-dex/openbook-v2/", "author": { diff --git a/ts/client/src/market.ts b/ts/client/src/market.ts index 3e8d70ecc..6b263f0cf 100644 --- a/ts/client/src/market.ts +++ b/ts/client/src/market.ts @@ -174,3 +174,11 @@ export function baseLotsToUi(market: MarketAccount, quantity: BN): number { export function quoteLotsToUi(market: MarketAccount, quantity: BN): number { return parseFloat(quantity.toString()) * quoteLotsToUiConverter(market); } + +export function quantityToUiBase( + market: MarketAccount, + quantity: BN, + decimals: number, +): number { + return toUiDecimals(quantity.mul(market.baseLotSize).toNumber(), decimals); +}