@drift-labs/sdk 2.25.0-beta.0 → 2.25.0-beta.2
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 +1 -0
- package/lib/adminClient.d.ts +1 -0
- package/lib/constants/numericConstants.d.ts +61 -59
- package/lib/constants/perpMarkets.js +10 -0
- package/lib/constants/spotMarkets.d.ts +1 -0
- package/lib/dlob/DLOB.d.ts +1 -0
- package/lib/dlob/DLOBNode.d.ts +1 -0
- package/lib/dlob/NodeList.d.ts +1 -0
- package/lib/driftClient.d.ts +1 -0
- package/lib/factory/bigNum.d.ts +8 -7
- package/lib/idl/drift.json +1 -1
- package/lib/math/amm.d.ts +2 -1
- package/lib/math/auction.d.ts +1 -0
- package/lib/math/conversion.d.ts +2 -1
- package/lib/math/funding.d.ts +1 -0
- package/lib/math/insurance.d.ts +1 -0
- package/lib/math/margin.d.ts +1 -0
- package/lib/math/market.d.ts +1 -0
- package/lib/math/oracles.d.ts +1 -0
- package/lib/math/orders.d.ts +1 -0
- package/lib/math/position.d.ts +1 -0
- package/lib/math/repeg.d.ts +1 -0
- package/lib/math/spotBalance.d.ts +1 -0
- package/lib/math/spotMarket.d.ts +1 -0
- package/lib/math/spotPosition.d.ts +1 -0
- package/lib/math/trade.d.ts +1 -0
- package/lib/math/utils.d.ts +1 -0
- package/lib/oracles/pythClient.d.ts +2 -1
- package/lib/oracles/types.d.ts +1 -0
- package/lib/orderParams.d.ts +1 -0
- package/lib/serum/serumSubscriber.d.ts +1 -0
- package/lib/tokenFaucet.d.ts +1 -0
- package/lib/types.d.ts +1 -0
- package/lib/user.d.ts +1 -0
- package/lib/userMap/userMap.js +0 -1
- package/package.json +1 -1
- package/src/constants/perpMarkets.ts +10 -0
- package/src/idl/drift.json +1 -1
- package/src/userMap/userMap.ts +0 -1
- package/src/assert/assert.js +0 -9
- package/src/token/index.js +0 -38
- 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/addresses/pda.d.ts
CHANGED
package/lib/adminClient.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
1
2
|
import { PublicKey, TransactionSignature } from '@solana/web3.js';
|
|
2
3
|
import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, MarketStatus, ContractTier, AssetTier, SpotFulfillmentConfigStatus } from './types';
|
|
3
4
|
import { BN } from '@coral-xyz/anchor';
|
|
@@ -1,60 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
17
|
-
export declare const
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
27
|
-
export declare const
|
|
28
|
-
export declare const
|
|
29
|
-
export declare const
|
|
30
|
-
export declare const
|
|
31
|
-
export declare const
|
|
32
|
-
export declare const
|
|
33
|
-
export declare const
|
|
34
|
-
export declare const
|
|
35
|
-
export declare const
|
|
36
|
-
export declare const
|
|
37
|
-
export declare const
|
|
38
|
-
export declare const
|
|
39
|
-
export declare const
|
|
40
|
-
export declare const
|
|
41
|
-
export declare const
|
|
42
|
-
export declare const
|
|
43
|
-
export declare const
|
|
44
|
-
export declare const
|
|
45
|
-
export declare const
|
|
46
|
-
export declare const
|
|
47
|
-
export declare const
|
|
48
|
-
export declare const
|
|
49
|
-
export declare const
|
|
50
|
-
export declare const
|
|
51
|
-
export declare const
|
|
52
|
-
export declare const
|
|
53
|
-
export declare const
|
|
54
|
-
export declare const
|
|
55
|
-
export declare const
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN } from '../';
|
|
3
|
+
export declare const ZERO: BN;
|
|
4
|
+
export declare const ONE: BN;
|
|
5
|
+
export declare const TWO: BN;
|
|
6
|
+
export declare const THREE: BN;
|
|
7
|
+
export declare const FOUR: BN;
|
|
8
|
+
export declare const FIVE: BN;
|
|
9
|
+
export declare const SIX: BN;
|
|
10
|
+
export declare const SEVEN: BN;
|
|
11
|
+
export declare const EIGHT: BN;
|
|
12
|
+
export declare const NINE: BN;
|
|
13
|
+
export declare const TEN: BN;
|
|
14
|
+
export declare const TEN_THOUSAND: BN;
|
|
15
|
+
export declare const BN_MAX: BN;
|
|
16
|
+
export declare const TEN_MILLION: BN;
|
|
17
|
+
export declare const MAX_LEVERAGE: BN;
|
|
18
|
+
export declare const MAX_LEVERAGE_ORDER_SIZE: BN;
|
|
19
|
+
export declare const PERCENTAGE_PRECISION_EXP: BN;
|
|
20
|
+
export declare const PERCENTAGE_PRECISION: BN;
|
|
21
|
+
export declare const CONCENTRATION_PRECISION: BN;
|
|
22
|
+
export declare const QUOTE_PRECISION_EXP: BN;
|
|
23
|
+
export declare const FUNDING_RATE_BUFFER_PRECISION_EXP: BN;
|
|
24
|
+
export declare const PRICE_PRECISION_EXP: BN;
|
|
25
|
+
export declare const FUNDING_RATE_PRECISION_EXP: BN;
|
|
26
|
+
export declare const PEG_PRECISION_EXP: BN;
|
|
27
|
+
export declare const AMM_RESERVE_PRECISION_EXP: BN;
|
|
28
|
+
export declare const SPOT_MARKET_RATE_PRECISION_EXP: BN;
|
|
29
|
+
export declare const SPOT_MARKET_RATE_PRECISION: BN;
|
|
30
|
+
export declare const SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION_EXP: BN;
|
|
31
|
+
export declare const SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION: BN;
|
|
32
|
+
export declare const SPOT_MARKET_UTILIZATION_PRECISION_EXP: BN;
|
|
33
|
+
export declare const SPOT_MARKET_UTILIZATION_PRECISION: BN;
|
|
34
|
+
export declare const SPOT_MARKET_WEIGHT_PRECISION: BN;
|
|
35
|
+
export declare const SPOT_MARKET_BALANCE_PRECISION_EXP: BN;
|
|
36
|
+
export declare const SPOT_MARKET_BALANCE_PRECISION: BN;
|
|
37
|
+
export declare const SPOT_MARKET_IMF_PRECISION_EXP: BN;
|
|
38
|
+
export declare const SPOT_MARKET_IMF_PRECISION: BN;
|
|
39
|
+
export declare const LIQUIDATION_FEE_PRECISION: BN;
|
|
40
|
+
export declare const QUOTE_PRECISION: BN;
|
|
41
|
+
export declare const PRICE_PRECISION: BN;
|
|
42
|
+
export declare const FUNDING_RATE_PRECISION: BN;
|
|
43
|
+
export declare const FUNDING_RATE_BUFFER_PRECISION: BN;
|
|
44
|
+
export declare const PEG_PRECISION: BN;
|
|
45
|
+
export declare const AMM_RESERVE_PRECISION: BN;
|
|
46
|
+
export declare const BASE_PRECISION: BN;
|
|
47
|
+
export declare const BASE_PRECISION_EXP: BN;
|
|
48
|
+
export declare const AMM_TO_QUOTE_PRECISION_RATIO: BN;
|
|
49
|
+
export declare const PRICE_DIV_PEG: BN;
|
|
50
|
+
export declare const PRICE_TO_QUOTE_PRECISION: BN;
|
|
51
|
+
export declare const AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO: BN;
|
|
52
|
+
export declare const MARGIN_PRECISION: BN;
|
|
53
|
+
export declare const BID_ASK_SPREAD_PRECISION: BN;
|
|
54
|
+
export declare const LIQUIDATION_PCT_PRECISION: BN;
|
|
55
|
+
export declare const FIVE_MINUTE: BN;
|
|
56
|
+
export declare const ONE_HOUR: BN;
|
|
57
|
+
export declare const ONE_YEAR: BN;
|
|
56
58
|
export declare const QUOTE_SPOT_MARKET_INDEX = 0;
|
|
57
|
-
export declare const LAMPORTS_PRECISION:
|
|
58
|
-
export declare const LAMPORTS_EXP:
|
|
59
|
-
export declare const OPEN_ORDER_MARGIN_REQUIREMENT:
|
|
60
|
-
export declare const DEFAULT_REVENUE_SINCE_LAST_FUNDING_SPREAD_RETREAT:
|
|
59
|
+
export declare const LAMPORTS_PRECISION: BN;
|
|
60
|
+
export declare const LAMPORTS_EXP: BN;
|
|
61
|
+
export declare const OPEN_ORDER_MARGIN_REQUIREMENT: BN;
|
|
62
|
+
export declare const DEFAULT_REVENUE_SINCE_LAST_FUNDING_SPREAD_RETREAT: BN;
|
|
@@ -84,6 +84,16 @@ exports.DevnetPerpMarkets = [
|
|
|
84
84
|
launchTs: 1680808053000,
|
|
85
85
|
oracleSource: __1.OracleSource.PYTH,
|
|
86
86
|
},
|
|
87
|
+
{
|
|
88
|
+
fullName: 'Binance Coin',
|
|
89
|
+
category: ['Exchange'],
|
|
90
|
+
symbol: 'BNB-PERP',
|
|
91
|
+
baseAssetSymbol: 'BNB',
|
|
92
|
+
marketIndex: 8,
|
|
93
|
+
oracle: new web3_js_1.PublicKey('GwzBgrXb4PG59zjce24SF2b9JXbLEjJJTBkmytuEZj1b'),
|
|
94
|
+
launchTs: 1680808053000,
|
|
95
|
+
oracleSource: __1.OracleSource.PYTH,
|
|
96
|
+
},
|
|
87
97
|
];
|
|
88
98
|
exports.MainnetPerpMarkets = [
|
|
89
99
|
{
|
package/lib/dlob/DLOB.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
1
2
|
import { NodeList } from './NodeList';
|
|
2
3
|
import { MarketType, BN, DriftClient, Order, SpotMarketAccount, PerpMarketAccount, OraclePriceData, SlotSubscriber, MarketTypeStr, StateAccount, UserMap, OrderRecord, OrderActionRecord } from '..';
|
|
3
4
|
import { PublicKey } from '@solana/web3.js';
|
package/lib/dlob/DLOBNode.d.ts
CHANGED
package/lib/dlob/NodeList.d.ts
CHANGED
package/lib/driftClient.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="bn.js" />
|
|
2
3
|
import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor';
|
|
3
4
|
import { StateAccount, IWallet, PositionDirection, UserAccount, PerpMarketAccount, OrderParams, Order, SpotMarketAccount, SpotPosition, MakerInfo, TakerInfo, OptionalOrderParams, ReferrerInfo, MarketType, TxParams, SerumV3FulfillmentConfigAccount, ReferrerNameAccount, OrderTriggerCondition, PerpMarketExtendedInfo, UserStatsAccount, ModifyOrderParams } from './types';
|
|
4
5
|
import * as anchor from '@coral-xyz/anchor';
|
package/lib/factory/bigNum.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
1
2
|
import { BN } from '@coral-xyz/anchor';
|
|
2
3
|
export declare class BigNum {
|
|
3
4
|
val: BN;
|
|
@@ -43,11 +44,11 @@ export declare class BigNum {
|
|
|
43
44
|
gte(bn: BigNum | BN, ignorePrecision?: boolean): boolean;
|
|
44
45
|
lte(bn: BigNum | BN, ignorePrecision?: boolean): boolean;
|
|
45
46
|
eq(bn: BigNum | BN, ignorePrecision?: boolean): boolean;
|
|
46
|
-
eqZero():
|
|
47
|
-
gtZero():
|
|
48
|
-
ltZero():
|
|
49
|
-
gteZero():
|
|
50
|
-
lteZero():
|
|
47
|
+
eqZero(): boolean;
|
|
48
|
+
gtZero(): boolean;
|
|
49
|
+
ltZero(): boolean;
|
|
50
|
+
gteZero(): boolean;
|
|
51
|
+
lteZero(): boolean;
|
|
51
52
|
abs(): BigNum;
|
|
52
53
|
neg(): BigNum;
|
|
53
54
|
toString: (base?: number | 'hex', length?: number) => string;
|
|
@@ -87,8 +88,8 @@ export declare class BigNum {
|
|
|
87
88
|
toNotional(useTradePrecision?: boolean, precisionOverride?: number): string;
|
|
88
89
|
toMillified(precision?: number, rounded?: boolean): string;
|
|
89
90
|
toJSON(): {
|
|
90
|
-
val:
|
|
91
|
-
precision:
|
|
91
|
+
val: string;
|
|
92
|
+
precision: string;
|
|
92
93
|
};
|
|
93
94
|
isNeg(): boolean;
|
|
94
95
|
isPos(): boolean;
|
package/lib/idl/drift.json
CHANGED
package/lib/math/amm.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
1
2
|
import { BN } from '@coral-xyz/anchor';
|
|
2
3
|
import { AMM, PositionDirection, SwapDirection, PerpMarketAccount } from '../types';
|
|
3
4
|
import { OraclePriceData } from '../oracles/types';
|
|
@@ -86,7 +87,7 @@ export declare function getSwapDirection(inputAssetType: AssetType, positionDire
|
|
|
86
87
|
* @param market
|
|
87
88
|
* @returns cost : Precision PRICE_PRECISION
|
|
88
89
|
*/
|
|
89
|
-
export declare function calculateTerminalPrice(market: PerpMarketAccount):
|
|
90
|
+
export declare function calculateTerminalPrice(market: PerpMarketAccount): BN;
|
|
90
91
|
export declare function calculateMaxBaseAssetAmountToTrade(amm: AMM, limit_price: BN, direction: PositionDirection, oraclePriceData?: OraclePriceData, now?: BN): [BN, PositionDirection];
|
|
91
92
|
export declare function calculateQuoteAssetAmountSwapped(quoteAssetReserves: BN, pegMultiplier: BN, swapDirection: SwapDirection): BN;
|
|
92
93
|
export declare function calculateMaxBaseAssetAmountFillable(amm: AMM, orderDirection: PositionDirection): BN;
|
package/lib/math/auction.d.ts
CHANGED
package/lib/math/conversion.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { BN } from '../';
|
|
2
|
+
export declare const convertToNumber: (bigNumber: BN, precision?: BN) => number;
|
package/lib/math/funding.d.ts
CHANGED
package/lib/math/insurance.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
1
2
|
import { BN } from '../index';
|
|
2
3
|
export declare function stakeAmountToShares(amount: BN, totalIfShares: BN, insuranceFundVaultBalance: BN): BN;
|
|
3
4
|
export declare function unstakeSharesToAmount(nShares: BN, totalIfShares: BN, insuranceFundVaultBalance: BN): BN;
|
package/lib/math/margin.d.ts
CHANGED
package/lib/math/market.d.ts
CHANGED
package/lib/math/oracles.d.ts
CHANGED
package/lib/math/orders.d.ts
CHANGED
package/lib/math/position.d.ts
CHANGED
package/lib/math/repeg.d.ts
CHANGED
package/lib/math/spotMarket.d.ts
CHANGED
package/lib/math/trade.d.ts
CHANGED
package/lib/math/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
1
2
|
/// <reference types="node" />
|
|
2
3
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
3
4
|
import { OracleClient, OraclePriceData } from './types';
|
|
@@ -6,7 +7,7 @@ export declare class PythClient implements OracleClient {
|
|
|
6
7
|
private connection;
|
|
7
8
|
private multiple;
|
|
8
9
|
private stableCoin;
|
|
9
|
-
constructor(connection: Connection, multiple?:
|
|
10
|
+
constructor(connection: Connection, multiple?: BN, stableCoin?: boolean);
|
|
10
11
|
getOraclePriceData(pricePublicKey: PublicKey): Promise<OraclePriceData>;
|
|
11
12
|
getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData;
|
|
12
13
|
}
|
package/lib/oracles/types.d.ts
CHANGED
package/lib/orderParams.d.ts
CHANGED
package/lib/tokenFaucet.d.ts
CHANGED
package/lib/types.d.ts
CHANGED
package/lib/user.d.ts
CHANGED
package/lib/userMap/userMap.js
CHANGED
package/package.json
CHANGED
|
@@ -94,6 +94,16 @@ export const DevnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
94
94
|
launchTs: 1680808053000,
|
|
95
95
|
oracleSource: OracleSource.PYTH,
|
|
96
96
|
},
|
|
97
|
+
{
|
|
98
|
+
fullName: 'Binance Coin',
|
|
99
|
+
category: ['Exchange'],
|
|
100
|
+
symbol: 'BNB-PERP',
|
|
101
|
+
baseAssetSymbol: 'BNB',
|
|
102
|
+
marketIndex: 8,
|
|
103
|
+
oracle: new PublicKey('GwzBgrXb4PG59zjce24SF2b9JXbLEjJJTBkmytuEZj1b'),
|
|
104
|
+
launchTs: 1680808053000,
|
|
105
|
+
oracleSource: OracleSource.PYTH,
|
|
106
|
+
},
|
|
97
107
|
];
|
|
98
108
|
|
|
99
109
|
export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
package/src/idl/drift.json
CHANGED
package/src/userMap/userMap.ts
CHANGED
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,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTokenAddress = void 0;
|
|
4
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
5
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
-
const getTokenAddress = (mintAddress, userPubKey) => {
|
|
7
|
-
return spl_token_1.Token.getAssociatedTokenAddress(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, new web3_js_1.PublicKey(mintAddress), new web3_js_1.PublicKey(userPubKey));
|
|
8
|
-
};
|
|
9
|
-
exports.getTokenAddress = getTokenAddress;
|
|
@@ -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;
|