@drift-labs/sdk 2.33.0 → 2.33.1-beta.1
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/dlob/DLOBSubscriber.d.ts +2 -1
- package/lib/dlob/DLOBSubscriber.js +2 -2
- package/lib/driftClient.d.ts +2 -1
- package/lib/driftClient.js +2 -1
- package/lib/jupiter/jupiterClient.d.ts +3 -1
- package/lib/jupiter/jupiterClient.js +3 -1
- package/lib/math/superStake.d.ts +2 -1
- package/lib/math/superStake.js +2 -1
- package/package.json +1 -1
- package/src/dlob/DLOBSubscriber.ts +3 -1
- package/src/driftClient.ts +3 -0
- package/src/jupiter/jupiterClient.ts +4 -0
- package/src/math/superStake.ts +3 -0
- package/src/assert/assert.js +0 -9
- package/src/token/index.js +0 -38
- package/src/util/computeUnits.js +0 -27
- package/src/util/promiseTimeout.js +0 -14
- package/src/util/tps.js +0 -27
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.33.1-beta.1
|
|
@@ -29,12 +29,13 @@ export declare class DLOBSubscriber {
|
|
|
29
29
|
* @param includeVamm Whether to include the VAMM orders in the order book. Defaults to false. If true, creates vAMM generator {@link getVammL2Generator} and adds it to fallbackL2Generators.
|
|
30
30
|
* @param fallbackL2Generators L2 generators for fallback liquidity e.g. vAMM {@link getVammL2Generator}, openbook {@link SerumSubscriber}
|
|
31
31
|
*/
|
|
32
|
-
getL2({ marketName, marketIndex, marketType, depth, includeVamm, fallbackL2Generators, }: {
|
|
32
|
+
getL2({ marketName, marketIndex, marketType, depth, includeVamm, numVammOrders, fallbackL2Generators, }: {
|
|
33
33
|
marketName?: string;
|
|
34
34
|
marketIndex?: number;
|
|
35
35
|
marketType?: MarketType;
|
|
36
36
|
depth?: number;
|
|
37
37
|
includeVamm?: boolean;
|
|
38
|
+
numVammOrders?: number;
|
|
38
39
|
fallbackL2Generators?: L2OrderBookGenerator[];
|
|
39
40
|
}): L2OrderBook;
|
|
40
41
|
/**
|
|
@@ -46,7 +46,7 @@ class DLOBSubscriber {
|
|
|
46
46
|
* @param includeVamm Whether to include the VAMM orders in the order book. Defaults to false. If true, creates vAMM generator {@link getVammL2Generator} and adds it to fallbackL2Generators.
|
|
47
47
|
* @param fallbackL2Generators L2 generators for fallback liquidity e.g. vAMM {@link getVammL2Generator}, openbook {@link SerumSubscriber}
|
|
48
48
|
*/
|
|
49
|
-
getL2({ marketName, marketIndex, marketType, depth = 10, includeVamm = false, fallbackL2Generators = [], }) {
|
|
49
|
+
getL2({ marketName, marketIndex, marketType, depth = 10, includeVamm = false, numVammOrders, fallbackL2Generators = [], }) {
|
|
50
50
|
if (marketName) {
|
|
51
51
|
const derivedMarketInfo = this.driftClient.getMarketIndexAndType(marketName);
|
|
52
52
|
if (!derivedMarketInfo) {
|
|
@@ -79,7 +79,7 @@ class DLOBSubscriber {
|
|
|
79
79
|
(0, orderBookLevels_1.getVammL2Generator)({
|
|
80
80
|
marketAccount: this.driftClient.getPerpMarketAccount(marketIndex),
|
|
81
81
|
oraclePriceData,
|
|
82
|
-
numOrders: depth,
|
|
82
|
+
numOrders: numVammOrders !== null && numVammOrders !== void 0 ? numVammOrders : depth,
|
|
83
83
|
}),
|
|
84
84
|
];
|
|
85
85
|
}
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -327,7 +327,7 @@ export declare class DriftClient {
|
|
|
327
327
|
reduceOnly?: SwapReduceOnly;
|
|
328
328
|
txParams?: TxParams;
|
|
329
329
|
}): Promise<TransactionSignature>;
|
|
330
|
-
getJupiterSwapIx({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, userAccountPublicKey, }: {
|
|
330
|
+
getJupiterSwapIx({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, route, reduceOnly, userAccountPublicKey, }: {
|
|
331
331
|
jupiterClient: JupiterClient;
|
|
332
332
|
outMarketIndex: number;
|
|
333
333
|
inMarketIndex: number;
|
|
@@ -336,6 +336,7 @@ export declare class DriftClient {
|
|
|
336
336
|
amount: BN;
|
|
337
337
|
slippageBps?: number;
|
|
338
338
|
swapMode?: SwapMode;
|
|
339
|
+
onlyDirectRoutes?: boolean;
|
|
339
340
|
route?: Route;
|
|
340
341
|
reduceOnly?: SwapReduceOnly;
|
|
341
342
|
userAccountPublicKey?: PublicKey;
|
package/lib/driftClient.js
CHANGED
|
@@ -1963,7 +1963,7 @@ class DriftClient {
|
|
|
1963
1963
|
this.spotMarketLastSlotCache.set(inMarketIndex, slot);
|
|
1964
1964
|
return txSig;
|
|
1965
1965
|
}
|
|
1966
|
-
async getJupiterSwapIx({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, userAccountPublicKey, }) {
|
|
1966
|
+
async getJupiterSwapIx({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, route, reduceOnly, userAccountPublicKey, }) {
|
|
1967
1967
|
const outMarket = this.getSpotMarketAccount(outMarketIndex);
|
|
1968
1968
|
const inMarket = this.getSpotMarketAccount(inMarketIndex);
|
|
1969
1969
|
if (!route) {
|
|
@@ -1973,6 +1973,7 @@ class DriftClient {
|
|
|
1973
1973
|
amount,
|
|
1974
1974
|
slippageBps,
|
|
1975
1975
|
swapMode,
|
|
1976
|
+
onlyDirectRoutes,
|
|
1976
1977
|
});
|
|
1977
1978
|
if (!routes || routes.length === 0) {
|
|
1978
1979
|
throw new Error('No jupiter routes found');
|
|
@@ -42,13 +42,15 @@ export declare class JupiterClient {
|
|
|
42
42
|
* @param amount the amount of the input token
|
|
43
43
|
* @param slippageBps the slippage tolerance in basis points
|
|
44
44
|
* @param swapMode the swap mode (ExactIn or ExactOut)
|
|
45
|
+
* @param onlyDirectRoutes whether to only return direct routes
|
|
45
46
|
*/
|
|
46
|
-
getRoutes({ inputMint, outputMint, amount, slippageBps, swapMode, }: {
|
|
47
|
+
getRoutes({ inputMint, outputMint, amount, slippageBps, swapMode, onlyDirectRoutes, }: {
|
|
47
48
|
inputMint: PublicKey;
|
|
48
49
|
outputMint: PublicKey;
|
|
49
50
|
amount: BN;
|
|
50
51
|
slippageBps?: number;
|
|
51
52
|
swapMode?: SwapMode;
|
|
53
|
+
onlyDirectRoutes?: boolean;
|
|
52
54
|
}): Promise<Route[]>;
|
|
53
55
|
/**
|
|
54
56
|
* Get a swap transaction for a route
|
|
@@ -19,14 +19,16 @@ class JupiterClient {
|
|
|
19
19
|
* @param amount the amount of the input token
|
|
20
20
|
* @param slippageBps the slippage tolerance in basis points
|
|
21
21
|
* @param swapMode the swap mode (ExactIn or ExactOut)
|
|
22
|
+
* @param onlyDirectRoutes whether to only return direct routes
|
|
22
23
|
*/
|
|
23
|
-
async getRoutes({ inputMint, outputMint, amount, slippageBps = 50, swapMode = 'ExactIn', }) {
|
|
24
|
+
async getRoutes({ inputMint, outputMint, amount, slippageBps = 50, swapMode = 'ExactIn', onlyDirectRoutes = false, }) {
|
|
24
25
|
const params = new URLSearchParams({
|
|
25
26
|
inputMint: inputMint.toString(),
|
|
26
27
|
outputMint: outputMint.toString(),
|
|
27
28
|
amount: amount.toString(),
|
|
28
29
|
slippageBps: slippageBps.toString(),
|
|
29
30
|
swapMode,
|
|
31
|
+
onlyDirectRoutes: onlyDirectRoutes.toString(),
|
|
30
32
|
}).toString();
|
|
31
33
|
const { data: routes } = await (await (0, node_fetch_1.default)(`https://quote-api.jup.ag/v4/quote?${params}`)).json();
|
|
32
34
|
return routes;
|
package/lib/math/superStake.d.ts
CHANGED
|
@@ -4,13 +4,14 @@ import { DriftClient } from '../driftClient';
|
|
|
4
4
|
import { BN } from '@coral-xyz/anchor';
|
|
5
5
|
import { User } from '../user';
|
|
6
6
|
import { DepositRecord } from '../types';
|
|
7
|
-
export declare function findBestSuperStakeIxs({ amount, jupiterClient, driftClient, userAccountPublicKey, marinadePrice, forceMarinade, }: {
|
|
7
|
+
export declare function findBestSuperStakeIxs({ amount, jupiterClient, driftClient, userAccountPublicKey, marinadePrice, forceMarinade, onlyDirectRoutes, }: {
|
|
8
8
|
amount: BN;
|
|
9
9
|
jupiterClient: JupiterClient;
|
|
10
10
|
driftClient: DriftClient;
|
|
11
11
|
marinadePrice?: number;
|
|
12
12
|
userAccountPublicKey?: PublicKey;
|
|
13
13
|
forceMarinade?: boolean;
|
|
14
|
+
onlyDirectRoutes?: boolean;
|
|
14
15
|
}): Promise<{
|
|
15
16
|
ixs: TransactionInstruction[];
|
|
16
17
|
lookupTables: AddressLookupTableAccount[];
|
package/lib/math/superStake.js
CHANGED
|
@@ -10,7 +10,7 @@ const anchor_1 = require("@coral-xyz/anchor");
|
|
|
10
10
|
const types_1 = require("../types");
|
|
11
11
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
12
12
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
13
|
-
async function findBestSuperStakeIxs({ amount, jupiterClient, driftClient, userAccountPublicKey, marinadePrice, forceMarinade, }) {
|
|
13
|
+
async function findBestSuperStakeIxs({ amount, jupiterClient, driftClient, userAccountPublicKey, marinadePrice, forceMarinade, onlyDirectRoutes, }) {
|
|
14
14
|
if (!marinadePrice) {
|
|
15
15
|
const marinadeProgram = (0, marinade_1.getMarinadeFinanceProgram)(driftClient.provider);
|
|
16
16
|
marinadePrice = await (0, marinade_1.getMarinadeMSolPrice)(marinadeProgram);
|
|
@@ -24,6 +24,7 @@ async function findBestSuperStakeIxs({ amount, jupiterClient, driftClient, userA
|
|
|
24
24
|
inputMint: solMint,
|
|
25
25
|
outputMint: mSOLMint,
|
|
26
26
|
amount,
|
|
27
|
+
onlyDirectRoutes,
|
|
27
28
|
});
|
|
28
29
|
bestRoute = jupiterRoutes[0];
|
|
29
30
|
jupiterPrice = bestRoute.inAmount / bestRoute.outAmount;
|
package/package.json
CHANGED
|
@@ -75,6 +75,7 @@ export class DLOBSubscriber {
|
|
|
75
75
|
marketType,
|
|
76
76
|
depth = 10,
|
|
77
77
|
includeVamm = false,
|
|
78
|
+
numVammOrders,
|
|
78
79
|
fallbackL2Generators = [],
|
|
79
80
|
}: {
|
|
80
81
|
marketName?: string;
|
|
@@ -82,6 +83,7 @@ export class DLOBSubscriber {
|
|
|
82
83
|
marketType?: MarketType;
|
|
83
84
|
depth?: number;
|
|
84
85
|
includeVamm?: boolean;
|
|
86
|
+
numVammOrders?: number;
|
|
85
87
|
fallbackL2Generators?: L2OrderBookGenerator[];
|
|
86
88
|
}): L2OrderBook {
|
|
87
89
|
if (marketName) {
|
|
@@ -122,7 +124,7 @@ export class DLOBSubscriber {
|
|
|
122
124
|
getVammL2Generator({
|
|
123
125
|
marketAccount: this.driftClient.getPerpMarketAccount(marketIndex),
|
|
124
126
|
oraclePriceData,
|
|
125
|
-
numOrders: depth,
|
|
127
|
+
numOrders: numVammOrders ?? depth,
|
|
126
128
|
}),
|
|
127
129
|
];
|
|
128
130
|
}
|
package/src/driftClient.ts
CHANGED
|
@@ -3418,6 +3418,7 @@ export class DriftClient {
|
|
|
3418
3418
|
amount,
|
|
3419
3419
|
slippageBps,
|
|
3420
3420
|
swapMode,
|
|
3421
|
+
onlyDirectRoutes,
|
|
3421
3422
|
route,
|
|
3422
3423
|
reduceOnly,
|
|
3423
3424
|
userAccountPublicKey,
|
|
@@ -3430,6 +3431,7 @@ export class DriftClient {
|
|
|
3430
3431
|
amount: BN;
|
|
3431
3432
|
slippageBps?: number;
|
|
3432
3433
|
swapMode?: SwapMode;
|
|
3434
|
+
onlyDirectRoutes?: boolean;
|
|
3433
3435
|
route?: Route;
|
|
3434
3436
|
reduceOnly?: SwapReduceOnly;
|
|
3435
3437
|
userAccountPublicKey?: PublicKey;
|
|
@@ -3447,6 +3449,7 @@ export class DriftClient {
|
|
|
3447
3449
|
amount,
|
|
3448
3450
|
slippageBps,
|
|
3449
3451
|
swapMode,
|
|
3452
|
+
onlyDirectRoutes,
|
|
3450
3453
|
});
|
|
3451
3454
|
|
|
3452
3455
|
if (!routes || routes.length === 0) {
|
|
@@ -57,6 +57,7 @@ export class JupiterClient {
|
|
|
57
57
|
* @param amount the amount of the input token
|
|
58
58
|
* @param slippageBps the slippage tolerance in basis points
|
|
59
59
|
* @param swapMode the swap mode (ExactIn or ExactOut)
|
|
60
|
+
* @param onlyDirectRoutes whether to only return direct routes
|
|
60
61
|
*/
|
|
61
62
|
public async getRoutes({
|
|
62
63
|
inputMint,
|
|
@@ -64,12 +65,14 @@ export class JupiterClient {
|
|
|
64
65
|
amount,
|
|
65
66
|
slippageBps = 50,
|
|
66
67
|
swapMode = 'ExactIn',
|
|
68
|
+
onlyDirectRoutes = false,
|
|
67
69
|
}: {
|
|
68
70
|
inputMint: PublicKey;
|
|
69
71
|
outputMint: PublicKey;
|
|
70
72
|
amount: BN;
|
|
71
73
|
slippageBps?: number;
|
|
72
74
|
swapMode?: SwapMode;
|
|
75
|
+
onlyDirectRoutes?: boolean;
|
|
73
76
|
}): Promise<Route[]> {
|
|
74
77
|
const params = new URLSearchParams({
|
|
75
78
|
inputMint: inputMint.toString(),
|
|
@@ -77,6 +80,7 @@ export class JupiterClient {
|
|
|
77
80
|
amount: amount.toString(),
|
|
78
81
|
slippageBps: slippageBps.toString(),
|
|
79
82
|
swapMode,
|
|
83
|
+
onlyDirectRoutes: onlyDirectRoutes.toString(),
|
|
80
84
|
}).toString();
|
|
81
85
|
|
|
82
86
|
const { data: routes } = await (
|
package/src/math/superStake.ts
CHANGED
|
@@ -20,6 +20,7 @@ export async function findBestSuperStakeIxs({
|
|
|
20
20
|
userAccountPublicKey,
|
|
21
21
|
marinadePrice,
|
|
22
22
|
forceMarinade,
|
|
23
|
+
onlyDirectRoutes,
|
|
23
24
|
}: {
|
|
24
25
|
amount: BN;
|
|
25
26
|
jupiterClient: JupiterClient;
|
|
@@ -27,6 +28,7 @@ export async function findBestSuperStakeIxs({
|
|
|
27
28
|
marinadePrice?: number;
|
|
28
29
|
userAccountPublicKey?: PublicKey;
|
|
29
30
|
forceMarinade?: boolean;
|
|
31
|
+
onlyDirectRoutes?: boolean;
|
|
30
32
|
}): Promise<{
|
|
31
33
|
ixs: TransactionInstruction[];
|
|
32
34
|
lookupTables: AddressLookupTableAccount[];
|
|
@@ -48,6 +50,7 @@ export async function findBestSuperStakeIxs({
|
|
|
48
50
|
inputMint: solMint,
|
|
49
51
|
outputMint: mSOLMint,
|
|
50
52
|
amount,
|
|
53
|
+
onlyDirectRoutes,
|
|
51
54
|
});
|
|
52
55
|
|
|
53
56
|
bestRoute = jupiterRoutes[0];
|
package/src/assert/assert.js
DELETED
package/src/token/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseTokenAccount = void 0;
|
|
4
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
5
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
-
function parseTokenAccount(data) {
|
|
7
|
-
const accountInfo = spl_token_1.AccountLayout.decode(data);
|
|
8
|
-
accountInfo.mint = new web3_js_1.PublicKey(accountInfo.mint);
|
|
9
|
-
accountInfo.owner = new web3_js_1.PublicKey(accountInfo.owner);
|
|
10
|
-
accountInfo.amount = spl_token_1.u64.fromBuffer(accountInfo.amount);
|
|
11
|
-
if (accountInfo.delegateOption === 0) {
|
|
12
|
-
accountInfo.delegate = null;
|
|
13
|
-
// eslint-disable-next-line new-cap
|
|
14
|
-
accountInfo.delegatedAmount = new spl_token_1.u64(0);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
accountInfo.delegate = new web3_js_1.PublicKey(accountInfo.delegate);
|
|
18
|
-
accountInfo.delegatedAmount = spl_token_1.u64.fromBuffer(accountInfo.delegatedAmount);
|
|
19
|
-
}
|
|
20
|
-
accountInfo.isInitialized = accountInfo.state !== 0;
|
|
21
|
-
accountInfo.isFrozen = accountInfo.state === 2;
|
|
22
|
-
if (accountInfo.isNativeOption === 1) {
|
|
23
|
-
accountInfo.rentExemptReserve = spl_token_1.u64.fromBuffer(accountInfo.isNative);
|
|
24
|
-
accountInfo.isNative = true;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
accountInfo.rentExemptReserve = null;
|
|
28
|
-
accountInfo.isNative = false;
|
|
29
|
-
}
|
|
30
|
-
if (accountInfo.closeAuthorityOption === 0) {
|
|
31
|
-
accountInfo.closeAuthority = null;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
accountInfo.closeAuthority = new web3_js_1.PublicKey(accountInfo.closeAuthority);
|
|
35
|
-
}
|
|
36
|
-
return accountInfo;
|
|
37
|
-
}
|
|
38
|
-
exports.parseTokenAccount = parseTokenAccount;
|
package/src/util/computeUnits.js
DELETED
|
@@ -1,27 +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.findComputeUnitConsumption = void 0;
|
|
13
|
-
function findComputeUnitConsumption(programId, connection, txSignature, commitment = 'confirmed') {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
const tx = yield connection.getTransaction(txSignature, { commitment });
|
|
16
|
-
const computeUnits = [];
|
|
17
|
-
const regex = new RegExp(`Program ${programId.toString()} consumed ([0-9]{0,6}) of ([0-9]{0,7}) compute units`);
|
|
18
|
-
tx.meta.logMessages.forEach((logMessage) => {
|
|
19
|
-
const match = logMessage.match(regex);
|
|
20
|
-
if (match && match[1]) {
|
|
21
|
-
computeUnits.push(match[1]);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return computeUnits;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
exports.findComputeUnitConsumption = findComputeUnitConsumption;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.promiseTimeout = void 0;
|
|
4
|
-
function promiseTimeout(promise, timeoutMs) {
|
|
5
|
-
let timeoutId;
|
|
6
|
-
const timeoutPromise = new Promise((resolve) => {
|
|
7
|
-
timeoutId = setTimeout(() => resolve(null), timeoutMs);
|
|
8
|
-
});
|
|
9
|
-
return Promise.race([promise, timeoutPromise]).then((result) => {
|
|
10
|
-
clearTimeout(timeoutId);
|
|
11
|
-
return result;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
exports.promiseTimeout = promiseTimeout;
|
package/src/util/tps.js
DELETED
|
@@ -1,27 +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.estimateTps = void 0;
|
|
13
|
-
function estimateTps(programId, connection, failed) {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
let signatures = yield connection.getSignaturesForAddress(programId, undefined, 'finalized');
|
|
16
|
-
if (failed) {
|
|
17
|
-
signatures = signatures.filter((signature) => signature.err);
|
|
18
|
-
}
|
|
19
|
-
const numberOfSignatures = signatures.length;
|
|
20
|
-
if (numberOfSignatures === 0) {
|
|
21
|
-
return 0;
|
|
22
|
-
}
|
|
23
|
-
return (numberOfSignatures /
|
|
24
|
-
(signatures[0].blockTime - signatures[numberOfSignatures - 1].blockTime));
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
exports.estimateTps = estimateTps;
|