@drift-labs/sdk 0.2.0-master.30 → 0.2.0-master.32
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/lib/admin.d.ts +11 -7
- package/lib/admin.js +50 -12
- package/lib/clearingHouse.d.ts +26 -23
- package/lib/clearingHouse.js +290 -652
- package/lib/clearingHouseUser.d.ts +1 -1
- package/lib/clearingHouseUser.js +9 -12
- package/lib/config.js +1 -1
- package/lib/constants/numericConstants.d.ts +7 -0
- package/lib/constants/numericConstants.js +8 -1
- package/lib/constants/spotMarkets.js +4 -4
- package/lib/dlob/DLOB.d.ts +7 -5
- package/lib/dlob/DLOB.js +159 -88
- package/lib/dlob/DLOBNode.d.ts +2 -0
- package/lib/dlob/DLOBNode.js +3 -0
- package/lib/dlob/NodeList.d.ts +2 -1
- package/lib/dlob/NodeList.js +10 -4
- package/lib/events/types.d.ts +2 -1
- package/lib/events/types.js +1 -0
- package/lib/factory/bigNum.d.ts +1 -0
- package/lib/factory/bigNum.js +14 -0
- package/lib/idl/clearing_house.json +1091 -611
- package/lib/math/amm.d.ts +2 -2
- package/lib/math/amm.js +31 -28
- package/lib/math/market.d.ts +1 -1
- package/lib/math/market.js +6 -6
- package/lib/math/spotBalance.js +7 -8
- package/lib/math/trade.js +11 -11
- package/lib/types.d.ts +118 -41
- package/lib/types.js +34 -4
- package/package.json +4 -2
- package/src/admin.ts +129 -29
- package/src/clearingHouse.ts +380 -787
- package/src/clearingHouseUser.ts +11 -14
- package/src/config.ts +1 -1
- package/src/constants/numericConstants.ts +7 -0
- package/src/constants/spotMarkets.ts +5 -4
- package/src/dlob/DLOB.ts +221 -103
- package/src/dlob/DLOBNode.ts +5 -0
- package/src/dlob/NodeList.ts +15 -5
- package/src/events/types.ts +3 -0
- package/src/factory/bigNum.ts +23 -0
- package/src/idl/clearing_house.json +1091 -611
- package/src/math/amm.ts +42 -29
- package/src/math/market.ts +9 -4
- package/src/math/spotBalance.ts +11 -8
- package/src/math/trade.ts +11 -11
- package/src/types.ts +82 -41
- package/tests/bn/test.ts +13 -8
- package/tests/dlob/helpers.ts +56 -33
- package/tests/dlob/test.ts +1397 -495
- package/src/assert/assert.js +0 -9
- package/src/events/eventList.js +0 -77
- package/src/examples/makeTradeExample.js +0 -157
- package/src/token/index.js +0 -38
- package/src/tx/types.js +0 -2
- package/src/tx/utils.js +0 -17
- package/src/util/computeUnits.js +0 -27
- package/src/util/getTokenAddress.js +0 -9
- package/src/util/promiseTimeout.js +0 -14
- package/src/util/tps.js +0 -27
package/lib/events/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Commitment, TransactionSignature } from '@solana/web3.js';
|
|
2
|
-
import { DepositRecord, FundingPaymentRecord, FundingRateRecord, LiquidationRecord, NewUserRecord, OrderActionRecord, OrderRecord, SettlePnlRecord, LPRecord, InsuranceFundRecord } from '../index';
|
|
2
|
+
import { DepositRecord, FundingPaymentRecord, FundingRateRecord, LiquidationRecord, NewUserRecord, OrderActionRecord, OrderRecord, SettlePnlRecord, LPRecord, InsuranceFundRecord, SpotInterestRecord } from '../index';
|
|
3
3
|
export declare type EventSubscriptionOptions = {
|
|
4
4
|
eventTypes?: EventType[];
|
|
5
5
|
maxEventsPerType?: number;
|
|
@@ -32,6 +32,7 @@ export declare type EventMap = {
|
|
|
32
32
|
NewUserRecord: Event<NewUserRecord>;
|
|
33
33
|
LPRecord: Event<LPRecord>;
|
|
34
34
|
InsuranceFundRecord: Event<InsuranceFundRecord>;
|
|
35
|
+
SpotInterestRecord: Event<SpotInterestRecord>;
|
|
35
36
|
};
|
|
36
37
|
export declare type EventType = keyof EventMap;
|
|
37
38
|
export interface EventSubscriberEvents {
|
package/lib/events/types.js
CHANGED
package/lib/factory/bigNum.d.ts
CHANGED
package/lib/factory/bigNum.js
CHANGED
|
@@ -189,6 +189,8 @@ class BigNum {
|
|
|
189
189
|
: useTradePrecision
|
|
190
190
|
? this.toTradePrecision()
|
|
191
191
|
: this.print();
|
|
192
|
+
if (!printVal.includes(BigNum.delim))
|
|
193
|
+
return printVal;
|
|
192
194
|
return printVal.replace(/0+$/g, '').replace(/\.$/, '').replace(/,$/, '');
|
|
193
195
|
}
|
|
194
196
|
debug() {
|
|
@@ -210,6 +212,9 @@ class BigNum {
|
|
|
210
212
|
.join('');
|
|
211
213
|
return `${leftSide}${BigNum.delim}${filledRightSide}`;
|
|
212
214
|
}
|
|
215
|
+
getZeroes(count) {
|
|
216
|
+
return new Array(count).fill('0').join('');
|
|
217
|
+
}
|
|
213
218
|
/**
|
|
214
219
|
* Pretty print to the specified number of significant figures
|
|
215
220
|
* @param fixedPrecision
|
|
@@ -218,6 +223,12 @@ class BigNum {
|
|
|
218
223
|
toPrecision(fixedPrecision, trailingZeroes = false) {
|
|
219
224
|
const printString = this.print();
|
|
220
225
|
let precisionPrintString = printString.slice(0, fixedPrecision + 1);
|
|
226
|
+
const thisString = this.toString();
|
|
227
|
+
if (!printString.includes(BigNum.delim) &&
|
|
228
|
+
thisString.length < fixedPrecision) {
|
|
229
|
+
const precisionMismatch = fixedPrecision - thisString.length;
|
|
230
|
+
return BigNum.from(thisString + this.getZeroes(precisionMismatch), precisionMismatch).toPrecision(fixedPrecision, trailingZeroes);
|
|
231
|
+
}
|
|
221
232
|
if (!precisionPrintString.includes(BigNum.delim) ||
|
|
222
233
|
precisionPrintString[precisionPrintString.length - 1] === BigNum.delim) {
|
|
223
234
|
precisionPrintString = printString.slice(0, fixedPrecision);
|
|
@@ -297,6 +308,9 @@ class BigNum {
|
|
|
297
308
|
if (!leftSide) {
|
|
298
309
|
return this.shift(new anchor_1.BN(precision)).toPrecision(precision, true);
|
|
299
310
|
}
|
|
311
|
+
if (leftSide.length <= precision) {
|
|
312
|
+
return this.toPrecision(precision);
|
|
313
|
+
}
|
|
300
314
|
if (leftSide.length <= 3) {
|
|
301
315
|
return this.shift(new anchor_1.BN(precision)).toPrecision(precision, true);
|
|
302
316
|
}
|