@drift-labs/sdk 0.2.0-master.22 → 0.2.0-master.23
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/addresses/pda.d.ts +3 -0
- package/lib/addresses/pda.js +23 -1
- package/lib/admin.d.ts +3 -0
- package/lib/admin.js +31 -0
- package/lib/clearingHouse.d.ts +9 -2
- package/lib/clearingHouse.js +132 -4
- package/lib/clearingHouseUser.js +5 -5
- package/lib/config.js +1 -1
- package/lib/constants/banks.d.ts +2 -0
- package/lib/constants/banks.js +9 -0
- package/lib/constants/numericConstants.d.ts +2 -0
- package/lib/constants/numericConstants.js +4 -1
- package/lib/events/sort.js +7 -10
- package/lib/events/types.d.ts +2 -1
- package/lib/events/types.js +1 -0
- package/lib/idl/clearing_house.json +1007 -151
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/math/insurance.d.ts +4 -0
- package/lib/math/insurance.js +27 -0
- package/lib/math/margin.d.ts +1 -1
- package/lib/math/margin.js +5 -7
- package/lib/math/position.js +1 -1
- package/lib/types.d.ts +56 -20
- package/lib/types.js +0 -3
- package/package.json +1 -1
- package/src/addresses/pda.ts +47 -0
- package/src/admin.ts +65 -0
- package/src/clearingHouse.ts +217 -9
- package/src/clearingHouseUser.ts +10 -6
- package/src/config.ts +1 -1
- package/src/constants/banks.ts +16 -0
- package/src/constants/numericConstants.ts +4 -0
- package/src/events/sort.ts +10 -14
- package/src/events/types.ts +3 -0
- package/src/idl/clearing_house.json +1007 -151
- package/src/index.ts +1 -0
- package/src/math/insurance.ts +35 -0
- package/src/math/margin.ts +3 -10
- package/src/math/position.ts +2 -2
- package/src/types.ts +64 -20
- package/src/events/eventSubscriber.js +0 -139
- package/src/events/sort.js +0 -44
package/src/index.ts
CHANGED
|
@@ -41,6 +41,7 @@ export * from './math/trade';
|
|
|
41
41
|
export * from './math/orders';
|
|
42
42
|
export * from './math/repeg';
|
|
43
43
|
export * from './math/margin';
|
|
44
|
+
export * from './math/insurance';
|
|
44
45
|
export * from './orderParams';
|
|
45
46
|
export * from './slot/SlotSubscriber';
|
|
46
47
|
export * from './wallet';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ONE, ZERO } from '../constants/numericConstants';
|
|
2
|
+
import { BN } from '../index';
|
|
3
|
+
|
|
4
|
+
export function stakeAmountToShares(
|
|
5
|
+
amount: BN,
|
|
6
|
+
totalIfShares: BN,
|
|
7
|
+
insuranceFundVaultBalance: BN
|
|
8
|
+
): BN {
|
|
9
|
+
let nShares: BN;
|
|
10
|
+
if (insuranceFundVaultBalance.gt(ZERO)) {
|
|
11
|
+
nShares = amount.mul(totalIfShares).div(insuranceFundVaultBalance);
|
|
12
|
+
} else {
|
|
13
|
+
nShares = amount;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return nShares;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function unstakeSharesToAmount(
|
|
20
|
+
nShares: BN,
|
|
21
|
+
totalIfShares: BN,
|
|
22
|
+
insuranceFundVaultBalance: BN
|
|
23
|
+
): BN {
|
|
24
|
+
let amount: BN;
|
|
25
|
+
if (totalIfShares.gt(ZERO)) {
|
|
26
|
+
amount = BN.max(
|
|
27
|
+
ZERO,
|
|
28
|
+
nShares.mul(insuranceFundVaultBalance).div(totalIfShares).sub(ONE)
|
|
29
|
+
);
|
|
30
|
+
} else {
|
|
31
|
+
amount = ZERO;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return amount;
|
|
35
|
+
}
|
package/src/math/margin.ts
CHANGED
|
@@ -92,22 +92,15 @@ export function calculateOraclePriceForPerpMargin(
|
|
|
92
92
|
return marginPrice;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
export function
|
|
95
|
+
export function calculateBaseAssetValueWithOracle(
|
|
96
96
|
market: MarketAccount,
|
|
97
97
|
marketPosition: UserPosition,
|
|
98
98
|
oraclePriceData: OraclePriceData
|
|
99
99
|
): BN {
|
|
100
|
-
|
|
101
|
-
marketPosition,
|
|
102
|
-
market,
|
|
103
|
-
oraclePriceData
|
|
104
|
-
);
|
|
105
|
-
const baseAssetValue = marketPosition.baseAssetAmount
|
|
100
|
+
return marketPosition.baseAssetAmount
|
|
106
101
|
.abs()
|
|
107
|
-
.mul(
|
|
102
|
+
.mul(oraclePriceData.price)
|
|
108
103
|
.div(AMM_TO_QUOTE_PRECISION_RATIO.mul(MARK_PRICE_PRECISION));
|
|
109
|
-
|
|
110
|
-
return baseAssetValue;
|
|
111
104
|
}
|
|
112
105
|
|
|
113
106
|
export function calculateWorstCaseBaseAssetAmount(
|
package/src/math/position.ts
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
getSwapDirection,
|
|
19
19
|
} from './amm';
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import { calculateBaseAssetValueWithOracle } from './margin';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* calculateBaseAssetValue
|
|
@@ -99,7 +99,7 @@ export function calculatePositionPNL(
|
|
|
99
99
|
return marketPosition.quoteAssetAmount;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
const baseAssetValue =
|
|
102
|
+
const baseAssetValue = calculateBaseAssetValueWithOracle(
|
|
103
103
|
market,
|
|
104
104
|
marketPosition,
|
|
105
105
|
oraclePriceData
|
package/src/types.ts
CHANGED
|
@@ -58,9 +58,6 @@ export class OrderAction {
|
|
|
58
58
|
|
|
59
59
|
export class OrderActionExplanation {
|
|
60
60
|
static readonly NONE = { none: {} };
|
|
61
|
-
static readonly BREACHED_MARGIN_REQUIREMENT = {
|
|
62
|
-
breachedMarginRequirement: {},
|
|
63
|
-
};
|
|
64
61
|
static readonly ORACLE_PRICE_BREACHED_LIMIT_PRICE = {
|
|
65
62
|
oraclePriceBreachedLimitPrice: {},
|
|
66
63
|
};
|
|
@@ -156,10 +153,15 @@ export type FundingRateRecord = {
|
|
|
156
153
|
recordId: BN;
|
|
157
154
|
marketIndex: BN;
|
|
158
155
|
fundingRate: BN;
|
|
156
|
+
fundingRateLong: BN;
|
|
157
|
+
fundingRateShort: BN;
|
|
159
158
|
cumulativeFundingRateLong: BN;
|
|
160
159
|
cumulativeFundingRateShort: BN;
|
|
161
160
|
oraclePriceTwap: BN;
|
|
162
161
|
markPriceTwap: BN;
|
|
162
|
+
periodRevenue: BN;
|
|
163
|
+
netBaseAssetAmount: BN;
|
|
164
|
+
netUnsettledLpBaseAssetAmount: BN;
|
|
163
165
|
};
|
|
164
166
|
|
|
165
167
|
export type FundingPaymentRecord = {
|
|
@@ -274,27 +276,41 @@ export type SettlePnlRecord = {
|
|
|
274
276
|
|
|
275
277
|
export type OrderRecord = {
|
|
276
278
|
ts: BN;
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
user: PublicKey;
|
|
280
|
+
order: Order;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export type OrderActionRecord = {
|
|
284
|
+
ts: BN;
|
|
283
285
|
action: OrderAction;
|
|
284
286
|
actionExplanation: OrderActionExplanation;
|
|
285
|
-
filler: PublicKey;
|
|
286
|
-
fillRecordId: BN;
|
|
287
287
|
marketIndex: BN;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
288
|
+
filler: PublicKey | null;
|
|
289
|
+
fillerReward: BN | null;
|
|
290
|
+
fillRecordId: BN | null;
|
|
291
|
+
referrer: PublicKey | null;
|
|
292
|
+
baseAssetAmountFilled: BN | null;
|
|
293
|
+
quoteAssetAmountFilled: BN | null;
|
|
294
|
+
takerPnl: BN | null;
|
|
295
|
+
makerPnl: BN | null;
|
|
296
|
+
takerFee: BN | null;
|
|
297
|
+
makerRebate: BN | null;
|
|
298
|
+
referrerReward: BN | null;
|
|
299
|
+
refereeDiscount: BN | null;
|
|
300
|
+
quoteAssetAmountSurplus: BN | null;
|
|
301
|
+
taker: PublicKey | null;
|
|
302
|
+
takerOrderId: BN | null;
|
|
303
|
+
takerOrderBaseAssetAmount: BN | null;
|
|
304
|
+
takerOrderBaseAssetAmountFilled: BN | null;
|
|
305
|
+
takerOrderQuoteAssetAmountFilled: BN | null;
|
|
306
|
+
takerOrderFee: BN | null;
|
|
307
|
+
maker: PublicKey | null;
|
|
308
|
+
makerOrderId: BN | null;
|
|
309
|
+
makerOrderBaseAssetAmount: BN | null;
|
|
310
|
+
makerOrderBaseAssetAmountFilled: BN | null;
|
|
311
|
+
makerOrderQuoteAssetAmountFilled: BN | null;
|
|
312
|
+
makerOrderFee: BN | null;
|
|
294
313
|
oraclePrice: BN;
|
|
295
|
-
referrer: PublicKey;
|
|
296
|
-
referrerReward: BN;
|
|
297
|
-
refereeDiscount: BN;
|
|
298
314
|
};
|
|
299
315
|
|
|
300
316
|
export type StateAccount = {
|
|
@@ -357,6 +373,20 @@ export type BankAccount = {
|
|
|
357
373
|
vault: PublicKey;
|
|
358
374
|
vaultAuthority: PublicKey;
|
|
359
375
|
vaultAuthorityNonce: number;
|
|
376
|
+
|
|
377
|
+
insuranceFundVault: PublicKey;
|
|
378
|
+
insuranceFundVaultAuthority: PublicKey;
|
|
379
|
+
insuranceFundVaultAuthorityNonce: number;
|
|
380
|
+
insuranceWithdrawEscrowPeriod: BN;
|
|
381
|
+
revenuePool: PoolBalance;
|
|
382
|
+
|
|
383
|
+
totalIfShares: BN;
|
|
384
|
+
userIfShares: BN;
|
|
385
|
+
|
|
386
|
+
userIfFactor: BN;
|
|
387
|
+
totalIfFactor: BN;
|
|
388
|
+
liquidationIfFactor: BN;
|
|
389
|
+
|
|
360
390
|
decimals: number;
|
|
361
391
|
optimalUtilization: BN;
|
|
362
392
|
optimalBorrowRate: BN;
|
|
@@ -439,6 +469,7 @@ export type AMM = {
|
|
|
439
469
|
maxSpread: number;
|
|
440
470
|
marketPosition: UserPosition;
|
|
441
471
|
marketPositionPerLp: UserPosition;
|
|
472
|
+
ammJitIntensity: number;
|
|
442
473
|
maxBaseAssetReserve: BN;
|
|
443
474
|
minBaseAssetReserve: BN;
|
|
444
475
|
};
|
|
@@ -478,6 +509,7 @@ export type UserStatsAccount = {
|
|
|
478
509
|
isReferrer: boolean;
|
|
479
510
|
totalReferrerReward: BN;
|
|
480
511
|
authority: PublicKey;
|
|
512
|
+
quoteAssetInsuranceFundStake: BN;
|
|
481
513
|
};
|
|
482
514
|
|
|
483
515
|
export type UserAccount = {
|
|
@@ -664,3 +696,15 @@ export type OrderFillerRewardStructure = {
|
|
|
664
696
|
};
|
|
665
697
|
|
|
666
698
|
export type MarginCategory = 'Initial' | 'Maintenance';
|
|
699
|
+
|
|
700
|
+
export type InsuranceFundStake = {
|
|
701
|
+
bankIndex: BN;
|
|
702
|
+
authority: PublicKey;
|
|
703
|
+
|
|
704
|
+
ifShares: BN;
|
|
705
|
+
ifBase: BN;
|
|
706
|
+
|
|
707
|
+
lastWithdrawRequestShares: BN;
|
|
708
|
+
lastWithdrawRequestValue: BN;
|
|
709
|
+
lastWithdrawRequestTs: BN;
|
|
710
|
+
};
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EventSubscriber = void 0;
|
|
13
|
-
const types_1 = require("./types");
|
|
14
|
-
const txEventCache_1 = require("./txEventCache");
|
|
15
|
-
const eventList_1 = require("./eventList");
|
|
16
|
-
const pollingLogProvider_1 = require("./pollingLogProvider");
|
|
17
|
-
const fetchLogs_1 = require("./fetchLogs");
|
|
18
|
-
const webSocketLogProvider_1 = require("./webSocketLogProvider");
|
|
19
|
-
const events_1 = require("events");
|
|
20
|
-
const sort_1 = require("./sort");
|
|
21
|
-
class EventSubscriber {
|
|
22
|
-
constructor(connection, program, options = types_1.DefaultEventSubscriptionOptions) {
|
|
23
|
-
this.connection = connection;
|
|
24
|
-
this.program = program;
|
|
25
|
-
this.options = options;
|
|
26
|
-
this.awaitTxPromises = new Map();
|
|
27
|
-
this.awaitTxResolver = new Map();
|
|
28
|
-
this.options = Object.assign({}, types_1.DefaultEventSubscriptionOptions, options);
|
|
29
|
-
this.txEventCache = new txEventCache_1.TxEventCache(this.options.maxTx);
|
|
30
|
-
this.eventListMap = new Map();
|
|
31
|
-
for (const eventType of this.options.eventTypes) {
|
|
32
|
-
this.eventListMap.set(eventType, new eventList_1.EventList(eventType, this.options.maxEventsPerType, sort_1.getSortFn(this.options.orderBy, this.options.orderDir, eventType), this.options.orderDir));
|
|
33
|
-
}
|
|
34
|
-
this.eventEmitter = new events_1.EventEmitter();
|
|
35
|
-
if (this.options.logProviderConfig.type === 'websocket') {
|
|
36
|
-
this.logProvider = new webSocketLogProvider_1.WebSocketLogProvider(this.connection, this.program.programId, this.options.commitment);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
this.logProvider = new pollingLogProvider_1.PollingLogProvider(this.connection, this.program.programId, options.commitment, this.options.logProviderConfig.frequency);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
subscribe() {
|
|
43
|
-
if (this.logProvider.isSubscribed()) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
this.fetchPreviousTx().catch((e) => {
|
|
47
|
-
console.error('Error fetching previous txs in event subscriber');
|
|
48
|
-
console.error(e);
|
|
49
|
-
});
|
|
50
|
-
return this.logProvider.subscribe((txSig, slot, logs) => {
|
|
51
|
-
this.handleTxLogs(txSig, slot, logs);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
handleTxLogs(txSig, slot, logs) {
|
|
55
|
-
if (this.txEventCache.has(txSig)) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const wrappedEvents = this.parseEventsFromLogs(txSig, slot, logs);
|
|
59
|
-
for (const wrappedEvent of wrappedEvents) {
|
|
60
|
-
this.eventListMap.get(wrappedEvent.eventType).insert(wrappedEvent);
|
|
61
|
-
this.eventEmitter.emit('newEvent', wrappedEvent);
|
|
62
|
-
}
|
|
63
|
-
if (this.awaitTxPromises.has(txSig)) {
|
|
64
|
-
this.awaitTxPromises.delete(txSig);
|
|
65
|
-
this.awaitTxResolver.get(txSig)();
|
|
66
|
-
this.awaitTxResolver.delete(txSig);
|
|
67
|
-
}
|
|
68
|
-
this.txEventCache.add(txSig, wrappedEvents);
|
|
69
|
-
}
|
|
70
|
-
fetchPreviousTx() {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
if (!this.options.untilTx) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
let txFetched = 0;
|
|
76
|
-
let beforeTx = undefined;
|
|
77
|
-
const untilTx = this.options.untilTx;
|
|
78
|
-
while (txFetched < this.options.maxTx) {
|
|
79
|
-
const response = yield fetchLogs_1.fetchLogs(this.connection, this.program.programId, this.options.commitment === 'finalized' ? 'finalized' : 'confirmed', beforeTx, untilTx);
|
|
80
|
-
if (response === undefined) {
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
txFetched += response.transactionLogs.length;
|
|
84
|
-
beforeTx = response.earliestTx;
|
|
85
|
-
for (const { txSig, slot, logs } of response.transactionLogs) {
|
|
86
|
-
this.handleTxLogs(txSig, slot, logs);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
unsubscribe() {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return yield this.logProvider.unsubscribe();
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
parseEventsFromLogs(txSig, slot, logs) {
|
|
97
|
-
const records = [];
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
this.program._events._eventParser.parseLogs(logs, (event) => {
|
|
100
|
-
const expectRecordType = this.eventListMap.has(event.name);
|
|
101
|
-
if (expectRecordType) {
|
|
102
|
-
event.data.txSig = txSig;
|
|
103
|
-
event.data.slot = slot;
|
|
104
|
-
event.data.eventType = event.name;
|
|
105
|
-
records.push(event.data);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
return records;
|
|
109
|
-
}
|
|
110
|
-
awaitTx(txSig) {
|
|
111
|
-
if (this.awaitTxPromises.has(txSig)) {
|
|
112
|
-
return this.awaitTxPromises.get(txSig);
|
|
113
|
-
}
|
|
114
|
-
if (this.txEventCache.has(txSig)) {
|
|
115
|
-
return Promise.resolve();
|
|
116
|
-
}
|
|
117
|
-
const promise = new Promise((resolve) => {
|
|
118
|
-
this.awaitTxResolver.set(txSig, resolve);
|
|
119
|
-
});
|
|
120
|
-
this.awaitTxPromises.set(txSig, promise);
|
|
121
|
-
return promise;
|
|
122
|
-
}
|
|
123
|
-
getEventList(eventType) {
|
|
124
|
-
return this.eventListMap.get(eventType);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* This requires the EventList be cast to an array, which requires reallocation of memory.
|
|
128
|
-
* Would bias to using getEventList over getEvents
|
|
129
|
-
*
|
|
130
|
-
* @param eventType
|
|
131
|
-
*/
|
|
132
|
-
getEventsArray(eventType) {
|
|
133
|
-
return this.eventListMap.get(eventType).toArray();
|
|
134
|
-
}
|
|
135
|
-
getEventsByTx(txSig) {
|
|
136
|
-
return this.txEventCache.get(txSig);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
exports.EventSubscriber = EventSubscriber;
|
package/src/events/sort.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSortFn = void 0;
|
|
4
|
-
const index_1 = require("../index");
|
|
5
|
-
function clientSortAscFn() {
|
|
6
|
-
return 'less than';
|
|
7
|
-
}
|
|
8
|
-
function clientSortDescFn() {
|
|
9
|
-
return 'greater than';
|
|
10
|
-
}
|
|
11
|
-
function defaultBlockchainSortFn(currentEvent, newEvent) {
|
|
12
|
-
return currentEvent.slot <= newEvent.slot ? 'less than' : 'greater than';
|
|
13
|
-
}
|
|
14
|
-
function orderRecordSortFn(currentEvent, newEvent) {
|
|
15
|
-
const currentEventMarketIndex = !currentEvent.maker.equals(index_1.PublicKey.default)
|
|
16
|
-
? currentEvent.makerOrder.marketIndex
|
|
17
|
-
: currentEvent.takerOrder.marketIndex;
|
|
18
|
-
const newEventMarketIndex = !newEvent.maker.equals(index_1.PublicKey.default)
|
|
19
|
-
? newEvent.makerOrder.marketIndex
|
|
20
|
-
: newEvent.takerOrder.marketIndex;
|
|
21
|
-
if (!currentEventMarketIndex.eq(newEventMarketIndex)) {
|
|
22
|
-
return currentEvent.ts.lte(newEvent.ts) ? 'less than' : 'greater than';
|
|
23
|
-
}
|
|
24
|
-
if (currentEvent.fillRecordId.gt(index_1.ZERO) && newEvent.fillRecordId.gt(index_1.ZERO)) {
|
|
25
|
-
return currentEvent.fillRecordId.lte(newEvent.fillRecordId)
|
|
26
|
-
? 'less than'
|
|
27
|
-
: 'greater than';
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return currentEvent.ts.lte(newEvent.ts) ? 'less than' : 'greater than';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function getSortFn(orderBy, orderDir, eventType) {
|
|
34
|
-
if (orderBy === 'client') {
|
|
35
|
-
return orderDir === 'asc' ? clientSortAscFn : clientSortDescFn;
|
|
36
|
-
}
|
|
37
|
-
switch (eventType) {
|
|
38
|
-
case 'OrderRecord':
|
|
39
|
-
return orderRecordSortFn;
|
|
40
|
-
default:
|
|
41
|
-
return defaultBlockchainSortFn;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.getSortFn = getSortFn;
|