@drift-labs/sdk 2.43.0-beta.9 → 2.45.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +1 -1
- package/lib/accounts/webSocketAccountSubscriber.d.ts +1 -0
- package/lib/accounts/webSocketAccountSubscriber.js +18 -3
- package/lib/accounts/webSocketProgramAccountSubscriber.d.ts +1 -0
- package/lib/accounts/webSocketProgramAccountSubscriber.js +18 -3
- package/lib/adminClient.d.ts +1 -0
- package/lib/adminClient.js +8 -0
- package/lib/dlob/DLOB.d.ts +9 -3
- package/lib/dlob/DLOB.js +77 -14
- package/lib/dlob/orderBookLevels.js +1 -0
- package/lib/driftClient.d.ts +3 -1
- package/lib/driftClient.js +86 -69
- package/lib/idl/drift.json +22 -1
- package/lib/jupiter/jupiterClient.js +10 -2
- package/lib/math/amm.js +2 -1
- package/lib/math/trade.js +18 -24
- package/lib/tx/fastSingleTxSender.js +6 -1
- package/lib/user.js +7 -8
- package/package.json +1 -1
- package/src/accounts/webSocketAccountSubscriber.ts +20 -6
- package/src/accounts/webSocketProgramAccountSubscriber.ts +19 -6
- package/src/adminClient.ts +14 -0
- package/src/dlob/DLOB.ts +114 -20
- package/src/dlob/orderBookLevels.ts +1 -0
- package/src/driftClient.ts +129 -82
- package/src/idl/drift.json +22 -1
- package/src/jupiter/jupiterClient.ts +12 -2
- package/src/math/amm.ts +2 -2
- package/src/math/trade.ts +26 -26
- package/src/tx/fastSingleTxSender.ts +7 -3
- package/src/user.ts +12 -8
|
@@ -54,9 +54,13 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
54
54
|
|
|
55
55
|
startBlockhashRefreshLoop(): void {
|
|
56
56
|
setInterval(async () => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
try {
|
|
58
|
+
this.recentBlockhash = (
|
|
59
|
+
await this.connection.getLatestBlockhash(this.opts)
|
|
60
|
+
).blockhash;
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error('Error in startBlockhashRefreshLoop: ', e);
|
|
63
|
+
}
|
|
60
64
|
}, this.blockhashRefreshInterval);
|
|
61
65
|
}
|
|
62
66
|
|
package/src/user.ts
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
calculateReservePrice,
|
|
49
49
|
calculateSpotMarketMarginRatio,
|
|
50
50
|
calculateUnrealizedAssetWeight,
|
|
51
|
+
divCeil,
|
|
51
52
|
getBalance,
|
|
52
53
|
getSignedTokenAmount,
|
|
53
54
|
getStrictTokenValue,
|
|
@@ -3054,14 +3055,17 @@ export class User {
|
|
|
3054
3055
|
'Initial'
|
|
3055
3056
|
);
|
|
3056
3057
|
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3058
|
+
let amountWithdrawable;
|
|
3059
|
+
if (assetWeight.eq(ZERO)) {
|
|
3060
|
+
amountWithdrawable = userDepositAmount;
|
|
3061
|
+
} else {
|
|
3062
|
+
amountWithdrawable = divCeil(
|
|
3063
|
+
divCeil(freeCollateral.mul(MARGIN_PRECISION), assetWeight).mul(
|
|
3064
|
+
PRICE_PRECISION
|
|
3065
|
+
),
|
|
3066
|
+
oracleData.price
|
|
3067
|
+
).mul(precisionIncrease);
|
|
3068
|
+
}
|
|
3065
3069
|
|
|
3066
3070
|
const maxWithdrawValue = BN.min(
|
|
3067
3071
|
BN.min(amountWithdrawable, userDepositAmount),
|