Skip to content

Commit d96d4e4

Browse files
committed
merge master
2 parents c80de65 + c756c9f commit d96d4e4

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

sdk/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.121.0-beta.16
1+
2.121.0-beta.20

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@drift-labs/sdk",
3-
"version": "2.121.0-beta.16",
3+
"version": "2.121.0-beta.20",
44
"main": "lib/node/index.js",
55
"types": "lib/node/index.d.ts",
66
"browser": "./lib/browser/index.js",

sdk/src/dlob/orderBookLevels.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import {
1515
PositionDirection,
1616
QUOTE_PRECISION,
1717
standardizePrice,
18-
standardizeBaseAssetAmount,
1918
SwapDirection,
2019
ZERO,
2120
PRICE_PRECISION,
2221
AMM_TO_QUOTE_PRECISION_RATIO,
22+
standardizeBaseAssetAmount,
2323
} from '..';
2424
import { PublicKey } from '@solana/web3.js';
2525
import { assert } from '../assert/assert';
@@ -277,10 +277,7 @@ export function getVammL2Generator({
277277
topOfBookBidSize = topOfBookBidSize.add(baseSwapped);
278278
bidSize = openBids.sub(topOfBookBidSize).div(new BN(numBaseOrders));
279279
} else {
280-
baseSwapped = standardizeBaseAssetAmount(
281-
bidSize,
282-
marketAccount.amm.orderStepSize
283-
);
280+
baseSwapped = bidSize;
284281
[afterSwapQuoteReserves, afterSwapBaseReserves] =
285282
calculateAmmReservesAfterSwap(
286283
bidAmm,
@@ -296,10 +293,11 @@ export function getVammL2Generator({
296293
);
297294
}
298295

299-
const price = quoteSwapped.mul(BASE_PRECISION).div(baseSwapped);
300-
// orderTickSize,
301-
// PositionDirection.LONG
302-
// );
296+
const price = standardizePrice(
297+
quoteSwapped.mul(BASE_PRECISION).div(baseSwapped),
298+
marketAccount.amm.orderTickSize,
299+
PositionDirection.LONG
300+
);
303301

304302
bidAmm.baseAssetReserve = afterSwapBaseReserves;
305303
bidAmm.quoteAssetReserve = afterSwapQuoteReserves;
@@ -384,10 +382,7 @@ export function getVammL2Generator({
384382
.sub(topOfBookAskSize)
385383
.div(new BN(numBaseOrders));
386384
} else {
387-
baseSwapped = standardizeBaseAssetAmount(
388-
askSize,
389-
marketAccount.amm.orderStepSize
390-
);
385+
baseSwapped = askSize;
391386
[afterSwapQuoteReserves, afterSwapBaseReserves] =
392387
calculateAmmReservesAfterSwap(
393388
askAmm,
@@ -403,7 +398,11 @@ export function getVammL2Generator({
403398
);
404399
}
405400

406-
const price = quoteSwapped.mul(BASE_PRECISION).div(baseSwapped);
401+
const price = standardizePrice(
402+
quoteSwapped.mul(BASE_PRECISION).div(baseSwapped),
403+
marketAccount.amm.orderTickSize,
404+
PositionDirection.SHORT
405+
);
407406

408407
askAmm.baseAssetReserve = afterSwapBaseReserves;
409408
askAmm.quoteAssetReserve = afterSwapQuoteReserves;

sdk/src/math/spotBalance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ export function calculateWithdrawLimit(
631631
borrowLimit = BN.min(borrowLimit, maxBorrowTokens);
632632
}
633633

634-
if (withdrawLimit.eq(ZERO)) {
634+
if (withdrawLimit.eq(ZERO) || isVariant(spotMarket.assetTier, 'protected')) {
635635
borrowLimit = ZERO;
636636
}
637637

0 commit comments

Comments
 (0)