Skip to content

Commit

Permalink
v0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mschneider committed Apr 15, 2024
1 parent d7d909c commit e050696
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openbook-dex/openbook-v2",
"version": "0.2.3",
"version": "0.2.4",
"description": "Typescript Client for openbook-v2 program.",
"repository": "https://github.com/openbook-dex/openbook-v2/",
"author": {
Expand Down
14 changes: 8 additions & 6 deletions ts/client/src/accounts/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ export class Market {
);
}
public priceUiToLots(uiAmount: number): BN {
return toNative(uiAmount * Number(this.account.baseLotSize.toString()), this.account.quoteDecimals)
.div(
new BN(Math.pow(10, this.account.baseDecimals)).imul(
this.account.quoteLotSize,
),
);
return toNative(
uiAmount * Number(this.account.baseLotSize.toString()),
this.account.quoteDecimals,
).div(
new BN(Math.pow(10, this.account.baseDecimals)).imul(
this.account.quoteLotSize,
),
);
}

public makerFeeFloor(quoteNative: BN): BN {
Expand Down
8 changes: 4 additions & 4 deletions ts/client/src/test/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ async function testMarketLots(): Promise<void> {
);
const market = await Market.load(client, marketPk);

if ("1" !== market.priceUiToLots(1e-10).toString()) {
if ('1' !== market.priceUiToLots(1e-10).toString()) {
throw new Error('price lot calculation rounds wrongly');
}
if ("0" !== market.priceUiToLots(9e-11).toString()) {
if ('0' !== market.priceUiToLots(9e-11).toString()) {
throw new Error('price lot calculation rounds wrongly');
}
if ("1" !== market.priceUiToLots(19e-11).toString()) {
if ('1' !== market.priceUiToLots(19e-11).toString()) {
throw new Error('price lot calculation rounds wrongly');
}
}
Expand All @@ -82,4 +82,4 @@ async function testMarketLots(): Promise<void> {
// void testFindAllMarkets();
// void testDecodeMarket();
// void testWatchMarket();
void testMarketLots();
void testMarketLots();

0 comments on commit e050696

Please sign in to comment.