@drift-labs/sdk 2.87.0-beta.8 → 2.88.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/adminClient.d.ts +2 -0
- package/lib/adminClient.js +24 -0
- package/lib/config.d.ts +1 -0
- package/lib/config.js +2 -0
- package/lib/constants/numericConstants.js +1 -1
- package/lib/constants/spotMarkets.d.ts +1 -0
- package/lib/driftClient.d.ts +1 -0
- package/lib/driftClient.js +15 -10
- package/lib/events/types.d.ts +3 -2
- package/lib/events/types.js +1 -0
- package/lib/idl/drift.json +106 -1
- package/lib/openbook/openbookV2Subscriber.d.ts +2 -2
- package/lib/openbook/openbookV2Subscriber.js +4 -6
- package/lib/types.d.ts +9 -0
- package/package.json +1 -1
- package/src/adminClient.ts +43 -0
- package/src/config.ts +3 -0
- package/src/constants/numericConstants.ts +1 -1
- package/src/constants/spotMarkets.ts +1 -0
- package/src/driftClient.ts +19 -10
- package/src/events/types.ts +5 -1
- package/src/idl/drift.json +107 -2
- package/src/openbook/openbookV2Subscriber.ts +4 -6
- package/src/types.ts +10 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.88.0-beta.0
|
package/lib/adminClient.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
41
41
|
getResetPerpMarketAmmOracleTwapIx(perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
42
42
|
depositIntoPerpMarketFeePool(perpMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionSignature>;
|
|
43
43
|
getDepositIntoPerpMarketFeePoolIx(perpMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionInstruction>;
|
|
44
|
+
depositIntoSpotMarketVault(spotMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionSignature>;
|
|
45
|
+
getDepositIntoSpotMarketVaultIx(spotMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionInstruction>;
|
|
44
46
|
updateAdmin(admin: PublicKey): Promise<TransactionSignature>;
|
|
45
47
|
getUpdateAdminIx(admin: PublicKey): Promise<TransactionInstruction>;
|
|
46
48
|
updatePerpMarketCurveUpdateIntensity(perpMarketIndex: number, curveUpdateIntensity: number): Promise<TransactionSignature>;
|
package/lib/adminClient.js
CHANGED
|
@@ -433,6 +433,30 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
433
433
|
},
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
|
+
async depositIntoSpotMarketVault(spotMarketIndex, amount, sourceVault) {
|
|
437
|
+
const depositIntoPerpMarketFeePoolIx = await this.getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault);
|
|
438
|
+
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
439
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
440
|
+
return txSig;
|
|
441
|
+
}
|
|
442
|
+
async getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault) {
|
|
443
|
+
const spotMarket = this.getSpotMarketAccount(spotMarketIndex);
|
|
444
|
+
const remainingAccounts = [];
|
|
445
|
+
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
446
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
447
|
+
return await this.program.instruction.depositIntoSpotMarketVault(amount, {
|
|
448
|
+
accounts: {
|
|
449
|
+
admin: this.isSubscribed
|
|
450
|
+
? this.getStateAccount().admin
|
|
451
|
+
: this.wallet.publicKey,
|
|
452
|
+
state: await this.getStatePublicKey(),
|
|
453
|
+
sourceVault,
|
|
454
|
+
spotMarket: spotMarket.pubkey,
|
|
455
|
+
spotMarketVault: spotMarket.vault,
|
|
456
|
+
tokenProgram,
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
}
|
|
436
460
|
async updateAdmin(admin) {
|
|
437
461
|
const updateAdminIx = await this.getUpdateAdminIx(admin);
|
|
438
462
|
const tx = await this.buildTransaction(updateAdminIx);
|
package/lib/config.d.ts
CHANGED
package/lib/config.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.configs = {
|
|
|
14
14
|
USDC_MINT_ADDRESS: '8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2',
|
|
15
15
|
SERUM_V3: 'DESVgJVGajEgKGXhb6XmqDHGz3VjdgP7rEVESBgxmroY',
|
|
16
16
|
PHOENIX: 'PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY',
|
|
17
|
+
OPENBOOK: 'opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb',
|
|
17
18
|
V2_ALPHA_TICKET_MINT_ADDRESS: 'DeEiGWfCMP9psnLGkxGrBBMEAW5Jv8bBGMN8DCtFRCyB',
|
|
18
19
|
PERP_MARKETS: perpMarkets_1.DevnetPerpMarkets,
|
|
19
20
|
SPOT_MARKETS: spotMarkets_1.DevnetSpotMarkets,
|
|
@@ -28,6 +29,7 @@ exports.configs = {
|
|
|
28
29
|
USDC_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
29
30
|
SERUM_V3: 'srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX',
|
|
30
31
|
PHOENIX: 'PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY',
|
|
32
|
+
OPENBOOK: 'opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb',
|
|
31
33
|
V2_ALPHA_TICKET_MINT_ADDRESS: 'Cmvhycb6LQvvzaShGw4iDHRLzeSSryioAsU98DSSkMNa',
|
|
32
34
|
PERP_MARKETS: perpMarkets_1.MainnetPerpMarkets,
|
|
33
35
|
SPOT_MARKETS: spotMarkets_1.MainnetSpotMarkets,
|
|
@@ -71,4 +71,4 @@ exports.IDLE_TIME_SLOTS = 9000;
|
|
|
71
71
|
exports.SLOT_TIME_ESTIMATE_MS = 400;
|
|
72
72
|
exports.DUST_POSITION_SIZE = exports.QUOTE_PRECISION.divn(100); // Dust position is any position smaller than 1c
|
|
73
73
|
exports.FUEL_WINDOW = new __1.BN(60 * 60 * 24 * 28); // 28 days
|
|
74
|
-
exports.FUEL_START_TS = new __1.BN(
|
|
74
|
+
exports.FUEL_START_TS = new __1.BN(1723075200); // unix timestamp
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -250,6 +250,7 @@ export declare class DriftClient {
|
|
|
250
250
|
signers: Signer[];
|
|
251
251
|
pubkey: PublicKey;
|
|
252
252
|
}>;
|
|
253
|
+
getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey;
|
|
253
254
|
addTokenMintToRemainingAccounts(spotMarketAccount: SpotMarketAccount, remainingAccounts: AccountMeta[]): void;
|
|
254
255
|
getAssociatedTokenAccountCreationIx(tokenMintAddress: PublicKey, associatedTokenAddress: PublicKey): anchor.web3.TransactionInstruction;
|
|
255
256
|
createInitializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, txParams?: TxParams, customMaxMarginRatio?: number): Promise<[Transaction | VersionedTransaction, PublicKey]>;
|
package/lib/driftClient.js
CHANGED
|
@@ -52,7 +52,6 @@ const spotPosition_1 = require("./math/spotPosition");
|
|
|
52
52
|
const market_1 = require("./math/market");
|
|
53
53
|
const fetch_1 = require("./accounts/fetch");
|
|
54
54
|
const spotMarket_1 = require("./math/spotMarket");
|
|
55
|
-
const pda_2 = require("./addresses/pda");
|
|
56
55
|
const memcmp_1 = require("./memcmp");
|
|
57
56
|
const marinade_1 = require("./marinade");
|
|
58
57
|
const orderParams_1 = require("./orderParams");
|
|
@@ -1135,7 +1134,7 @@ class DriftClient {
|
|
|
1135
1134
|
}
|
|
1136
1135
|
const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
|
|
1137
1136
|
this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
|
|
1138
|
-
const tokenProgram =
|
|
1137
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
1139
1138
|
return await this.program.instruction.deposit(marketIndex, amount, reduceOnly, {
|
|
1140
1139
|
accounts: {
|
|
1141
1140
|
state: await this.getStatePublicKey(),
|
|
@@ -1187,6 +1186,12 @@ class DriftClient {
|
|
|
1187
1186
|
result.ixs.push((0, spl_token_1.createInitializeAccountInstruction)(wrappedSolAccount, spotMarkets_1.WRAPPED_SOL_MINT, authority));
|
|
1188
1187
|
return result;
|
|
1189
1188
|
}
|
|
1189
|
+
getTokenProgramForSpotMarket(spotMarketAccount) {
|
|
1190
|
+
if (spotMarketAccount.tokenProgram === 1) {
|
|
1191
|
+
return spl_token_1.TOKEN_2022_PROGRAM_ID;
|
|
1192
|
+
}
|
|
1193
|
+
return spl_token_1.TOKEN_PROGRAM_ID;
|
|
1194
|
+
}
|
|
1190
1195
|
addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts) {
|
|
1191
1196
|
if (spotMarketAccount.tokenProgram === 1) {
|
|
1192
1197
|
remainingAccounts.push({
|
|
@@ -1360,7 +1365,7 @@ class DriftClient {
|
|
|
1360
1365
|
});
|
|
1361
1366
|
const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
|
|
1362
1367
|
this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
|
|
1363
|
-
const tokenProgram =
|
|
1368
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
1364
1369
|
return await this.program.instruction.withdraw(marketIndex, amount, reduceOnly, {
|
|
1365
1370
|
accounts: {
|
|
1366
1371
|
state: await this.getStatePublicKey(),
|
|
@@ -2371,7 +2376,7 @@ class DriftClient {
|
|
|
2371
2376
|
outAssociatedTokenAccount = await this.getAssociatedTokenAccount(outMarket.marketIndex, false);
|
|
2372
2377
|
const accountInfo = await this.connection.getAccountInfo(outAssociatedTokenAccount);
|
|
2373
2378
|
if (!accountInfo) {
|
|
2374
|
-
const tokenProgram =
|
|
2379
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(outMarket);
|
|
2375
2380
|
preInstructions.push(this.createAssociatedTokenAccountIdempotentInstruction(outAssociatedTokenAccount, this.provider.wallet.publicKey, this.provider.wallet.publicKey, outMarket.mint, tokenProgram));
|
|
2376
2381
|
}
|
|
2377
2382
|
}
|
|
@@ -2379,7 +2384,7 @@ class DriftClient {
|
|
|
2379
2384
|
inAssociatedTokenAccount = await this.getAssociatedTokenAccount(inMarket.marketIndex, false);
|
|
2380
2385
|
const accountInfo = await this.connection.getAccountInfo(inAssociatedTokenAccount);
|
|
2381
2386
|
if (!accountInfo) {
|
|
2382
|
-
const tokenProgram =
|
|
2387
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(outMarket);
|
|
2383
2388
|
preInstructions.push(this.createAssociatedTokenAccountIdempotentInstruction(inAssociatedTokenAccount, this.provider.wallet.publicKey, this.provider.wallet.publicKey, inMarket.mint, tokenProgram));
|
|
2384
2389
|
}
|
|
2385
2390
|
}
|
|
@@ -2495,8 +2500,8 @@ class DriftClient {
|
|
|
2495
2500
|
});
|
|
2496
2501
|
const outSpotMarket = this.getSpotMarketAccount(outMarketIndex);
|
|
2497
2502
|
const inSpotMarket = this.getSpotMarketAccount(inMarketIndex);
|
|
2498
|
-
const outTokenProgram =
|
|
2499
|
-
const inTokenProgram =
|
|
2503
|
+
const outTokenProgram = this.getTokenProgramForSpotMarket(outSpotMarket);
|
|
2504
|
+
const inTokenProgram = this.getTokenProgramForSpotMarket(inSpotMarket);
|
|
2500
2505
|
if (!outTokenProgram.equals(inTokenProgram)) {
|
|
2501
2506
|
remainingAccounts.push({
|
|
2502
2507
|
pubkey: outTokenProgram,
|
|
@@ -3525,7 +3530,7 @@ class DriftClient {
|
|
|
3525
3530
|
const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
3526
3531
|
const remainingAccounts = [];
|
|
3527
3532
|
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
3528
|
-
const tokenProgram =
|
|
3533
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
3529
3534
|
const ix = this.program.instruction.addInsuranceFundStake(marketIndex, amount, {
|
|
3530
3535
|
accounts: {
|
|
3531
3536
|
state: await this.getStatePublicKey(),
|
|
@@ -3642,7 +3647,7 @@ class DriftClient {
|
|
|
3642
3647
|
}
|
|
3643
3648
|
const remainingAccounts = [];
|
|
3644
3649
|
this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
|
|
3645
|
-
const tokenProgram =
|
|
3650
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
3646
3651
|
const removeStakeIx = await this.program.instruction.removeInsuranceFundStake(marketIndex, {
|
|
3647
3652
|
accounts: {
|
|
3648
3653
|
state: await this.getStatePublicKey(),
|
|
@@ -3716,7 +3721,7 @@ class DriftClient {
|
|
|
3716
3721
|
const spotMarket = await this.getSpotMarketAccount(marketIndex);
|
|
3717
3722
|
const remainingAccounts = [];
|
|
3718
3723
|
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
3719
|
-
const tokenProgram =
|
|
3724
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
3720
3725
|
const ix = await this.program.instruction.depositIntoSpotMarketRevenuePool(amount, {
|
|
3721
3726
|
accounts: {
|
|
3722
3727
|
state: await this.getStatePublicKey(),
|
package/lib/events/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Commitment, PublicKey, TransactionSignature } from '@solana/web3.js';
|
|
3
|
-
import { DepositRecord, FundingPaymentRecord, FundingRateRecord, LiquidationRecord, NewUserRecord, OrderActionRecord, OrderRecord, SettlePnlRecord, LPRecord, InsuranceFundRecord, SpotInterestRecord, InsuranceFundStakeRecord, CurveRecord, SwapRecord } from '../index';
|
|
3
|
+
import { DepositRecord, FundingPaymentRecord, FundingRateRecord, LiquidationRecord, NewUserRecord, OrderActionRecord, OrderRecord, SettlePnlRecord, LPRecord, InsuranceFundRecord, SpotInterestRecord, InsuranceFundStakeRecord, CurveRecord, SwapRecord, SpotMarketVaultDepositRecord } from '../index';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
export type EventSubscriptionOptions = {
|
|
6
6
|
address?: PublicKey;
|
|
@@ -40,9 +40,10 @@ export type EventMap = {
|
|
|
40
40
|
InsuranceFundStakeRecord: Event<InsuranceFundStakeRecord>;
|
|
41
41
|
CurveRecord: Event<CurveRecord>;
|
|
42
42
|
SwapRecord: Event<SwapRecord>;
|
|
43
|
+
SpotMarketVaultDepositRecord: Event<SpotMarketVaultDepositRecord>;
|
|
43
44
|
};
|
|
44
45
|
export type EventType = keyof EventMap;
|
|
45
|
-
export type DriftEvent = Event<DepositRecord> | Event<FundingPaymentRecord> | Event<LiquidationRecord> | Event<FundingRateRecord> | Event<OrderRecord> | Event<OrderActionRecord> | Event<SettlePnlRecord> | Event<NewUserRecord> | Event<LPRecord> | Event<InsuranceFundRecord> | Event<SpotInterestRecord> | Event<InsuranceFundStakeRecord> | Event<CurveRecord> | Event<SwapRecord>;
|
|
46
|
+
export type DriftEvent = Event<DepositRecord> | Event<FundingPaymentRecord> | Event<LiquidationRecord> | Event<FundingRateRecord> | Event<OrderRecord> | Event<OrderActionRecord> | Event<SettlePnlRecord> | Event<NewUserRecord> | Event<LPRecord> | Event<InsuranceFundRecord> | Event<SpotInterestRecord> | Event<InsuranceFundStakeRecord> | Event<CurveRecord> | Event<SwapRecord> | Event<SpotMarketVaultDepositRecord>;
|
|
46
47
|
export interface EventSubscriberEvents {
|
|
47
48
|
newEvent: (event: WrappedEvent<EventType>) => void;
|
|
48
49
|
}
|
package/lib/events/types.js
CHANGED
package/lib/idl/drift.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.87.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -3403,6 +3403,27 @@
|
|
|
3403
3403
|
}
|
|
3404
3404
|
]
|
|
3405
3405
|
},
|
|
3406
|
+
{
|
|
3407
|
+
"name": "initializePredictionMarket",
|
|
3408
|
+
"accounts": [
|
|
3409
|
+
{
|
|
3410
|
+
"name": "admin",
|
|
3411
|
+
"isMut": false,
|
|
3412
|
+
"isSigner": true
|
|
3413
|
+
},
|
|
3414
|
+
{
|
|
3415
|
+
"name": "state",
|
|
3416
|
+
"isMut": false,
|
|
3417
|
+
"isSigner": false
|
|
3418
|
+
},
|
|
3419
|
+
{
|
|
3420
|
+
"name": "perpMarket",
|
|
3421
|
+
"isMut": true,
|
|
3422
|
+
"isSigner": false
|
|
3423
|
+
}
|
|
3424
|
+
],
|
|
3425
|
+
"args": []
|
|
3426
|
+
},
|
|
3406
3427
|
{
|
|
3407
3428
|
"name": "deleteInitializedPerpMarket",
|
|
3408
3429
|
"accounts": [
|
|
@@ -3634,6 +3655,47 @@
|
|
|
3634
3655
|
}
|
|
3635
3656
|
]
|
|
3636
3657
|
},
|
|
3658
|
+
{
|
|
3659
|
+
"name": "depositIntoSpotMarketVault",
|
|
3660
|
+
"accounts": [
|
|
3661
|
+
{
|
|
3662
|
+
"name": "state",
|
|
3663
|
+
"isMut": false,
|
|
3664
|
+
"isSigner": false
|
|
3665
|
+
},
|
|
3666
|
+
{
|
|
3667
|
+
"name": "spotMarket",
|
|
3668
|
+
"isMut": true,
|
|
3669
|
+
"isSigner": false
|
|
3670
|
+
},
|
|
3671
|
+
{
|
|
3672
|
+
"name": "admin",
|
|
3673
|
+
"isMut": false,
|
|
3674
|
+
"isSigner": true
|
|
3675
|
+
},
|
|
3676
|
+
{
|
|
3677
|
+
"name": "sourceVault",
|
|
3678
|
+
"isMut": true,
|
|
3679
|
+
"isSigner": false
|
|
3680
|
+
},
|
|
3681
|
+
{
|
|
3682
|
+
"name": "spotMarketVault",
|
|
3683
|
+
"isMut": true,
|
|
3684
|
+
"isSigner": false
|
|
3685
|
+
},
|
|
3686
|
+
{
|
|
3687
|
+
"name": "tokenProgram",
|
|
3688
|
+
"isMut": false,
|
|
3689
|
+
"isSigner": false
|
|
3690
|
+
}
|
|
3691
|
+
],
|
|
3692
|
+
"args": [
|
|
3693
|
+
{
|
|
3694
|
+
"name": "amount",
|
|
3695
|
+
"type": "u64"
|
|
3696
|
+
}
|
|
3697
|
+
]
|
|
3698
|
+
},
|
|
3637
3699
|
{
|
|
3638
3700
|
"name": "depositIntoSpotMarketRevenuePool",
|
|
3639
3701
|
"accounts": [
|
|
@@ -10148,6 +10210,9 @@
|
|
|
10148
10210
|
},
|
|
10149
10211
|
{
|
|
10150
10212
|
"name": "Future"
|
|
10213
|
+
},
|
|
10214
|
+
{
|
|
10215
|
+
"name": "Prediction"
|
|
10151
10216
|
}
|
|
10152
10217
|
]
|
|
10153
10218
|
}
|
|
@@ -11400,6 +11465,46 @@
|
|
|
11400
11465
|
"index": false
|
|
11401
11466
|
}
|
|
11402
11467
|
]
|
|
11468
|
+
},
|
|
11469
|
+
{
|
|
11470
|
+
"name": "SpotMarketVaultDepositRecord",
|
|
11471
|
+
"fields": [
|
|
11472
|
+
{
|
|
11473
|
+
"name": "ts",
|
|
11474
|
+
"type": "i64",
|
|
11475
|
+
"index": false
|
|
11476
|
+
},
|
|
11477
|
+
{
|
|
11478
|
+
"name": "marketIndex",
|
|
11479
|
+
"type": "u16",
|
|
11480
|
+
"index": false
|
|
11481
|
+
},
|
|
11482
|
+
{
|
|
11483
|
+
"name": "depositBalance",
|
|
11484
|
+
"type": "u128",
|
|
11485
|
+
"index": false
|
|
11486
|
+
},
|
|
11487
|
+
{
|
|
11488
|
+
"name": "cumulativeDepositInterestBefore",
|
|
11489
|
+
"type": "u128",
|
|
11490
|
+
"index": false
|
|
11491
|
+
},
|
|
11492
|
+
{
|
|
11493
|
+
"name": "cumulativeDepositInterestAfter",
|
|
11494
|
+
"type": "u128",
|
|
11495
|
+
"index": false
|
|
11496
|
+
},
|
|
11497
|
+
{
|
|
11498
|
+
"name": "depositTokenAmountBefore",
|
|
11499
|
+
"type": "u64",
|
|
11500
|
+
"index": false
|
|
11501
|
+
},
|
|
11502
|
+
{
|
|
11503
|
+
"name": "amount",
|
|
11504
|
+
"type": "u64",
|
|
11505
|
+
"index": false
|
|
11506
|
+
}
|
|
11507
|
+
]
|
|
11403
11508
|
}
|
|
11404
11509
|
],
|
|
11405
11510
|
"errors": [
|
|
@@ -27,8 +27,8 @@ export declare class OpenbookV2Subscriber implements L2OrderBookGenerator {
|
|
|
27
27
|
client: OpenBookV2Client;
|
|
28
28
|
constructor(config: OpenbookV2SubscriberConfig);
|
|
29
29
|
subscribe(): Promise<void>;
|
|
30
|
-
getBestBid():
|
|
31
|
-
getBestAsk():
|
|
30
|
+
getBestBid(): BN | undefined;
|
|
31
|
+
getBestAsk(): BN | undefined;
|
|
32
32
|
getL2Bids(): Generator<L2Level>;
|
|
33
33
|
getL2Asks(): Generator<L2Level>;
|
|
34
34
|
getL2Levels(side: 'bids' | 'asks'): Generator<L2Level>;
|
|
@@ -50,17 +50,15 @@ class OpenbookV2Subscriber {
|
|
|
50
50
|
}
|
|
51
51
|
this.subscribed = true;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
const bestBid = bids.best();
|
|
53
|
+
getBestBid() {
|
|
54
|
+
const bestBid = this.market.bids.best();
|
|
56
55
|
if (bestBid === undefined) {
|
|
57
56
|
return undefined;
|
|
58
57
|
}
|
|
59
58
|
return new anchor_1.BN(Math.floor(bestBid.price * numericConstants_1.PRICE_PRECISION.toNumber()));
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const bestAsk = asks.best();
|
|
60
|
+
getBestAsk() {
|
|
61
|
+
const bestAsk = this.market.asks.best();
|
|
64
62
|
if (bestAsk === undefined) {
|
|
65
63
|
return undefined;
|
|
66
64
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -674,6 +674,15 @@ export type SwapRecord = {
|
|
|
674
674
|
inOraclePrice: BN;
|
|
675
675
|
fee: BN;
|
|
676
676
|
};
|
|
677
|
+
export type SpotMarketVaultDepositRecord = {
|
|
678
|
+
ts: BN;
|
|
679
|
+
marketIndex: number;
|
|
680
|
+
depositBalance: BN;
|
|
681
|
+
cumulativeDepositInterestBefore: BN;
|
|
682
|
+
cumulativeDepositInterestAfter: BN;
|
|
683
|
+
depositTokenAmountBefore: BN;
|
|
684
|
+
amount: BN;
|
|
685
|
+
};
|
|
677
686
|
export type StateAccount = {
|
|
678
687
|
admin: PublicKey;
|
|
679
688
|
exchangeStatus: number;
|
package/package.json
CHANGED
package/src/adminClient.ts
CHANGED
|
@@ -999,6 +999,49 @@ export class AdminClient extends DriftClient {
|
|
|
999
999
|
});
|
|
1000
1000
|
}
|
|
1001
1001
|
|
|
1002
|
+
public async depositIntoSpotMarketVault(
|
|
1003
|
+
spotMarketIndex: number,
|
|
1004
|
+
amount: BN,
|
|
1005
|
+
sourceVault: PublicKey
|
|
1006
|
+
): Promise<TransactionSignature> {
|
|
1007
|
+
const depositIntoPerpMarketFeePoolIx =
|
|
1008
|
+
await this.getDepositIntoSpotMarketVaultIx(
|
|
1009
|
+
spotMarketIndex,
|
|
1010
|
+
amount,
|
|
1011
|
+
sourceVault
|
|
1012
|
+
);
|
|
1013
|
+
|
|
1014
|
+
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
1015
|
+
|
|
1016
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1017
|
+
|
|
1018
|
+
return txSig;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
public async getDepositIntoSpotMarketVaultIx(
|
|
1022
|
+
spotMarketIndex: number,
|
|
1023
|
+
amount: BN,
|
|
1024
|
+
sourceVault: PublicKey
|
|
1025
|
+
): Promise<TransactionInstruction> {
|
|
1026
|
+
const spotMarket = this.getSpotMarketAccount(spotMarketIndex);
|
|
1027
|
+
|
|
1028
|
+
const remainingAccounts = [];
|
|
1029
|
+
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
1030
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
1031
|
+
return await this.program.instruction.depositIntoSpotMarketVault(amount, {
|
|
1032
|
+
accounts: {
|
|
1033
|
+
admin: this.isSubscribed
|
|
1034
|
+
? this.getStateAccount().admin
|
|
1035
|
+
: this.wallet.publicKey,
|
|
1036
|
+
state: await this.getStatePublicKey(),
|
|
1037
|
+
sourceVault,
|
|
1038
|
+
spotMarket: spotMarket.pubkey,
|
|
1039
|
+
spotMarketVault: spotMarket.vault,
|
|
1040
|
+
tokenProgram,
|
|
1041
|
+
},
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1002
1045
|
public async updateAdmin(admin: PublicKey): Promise<TransactionSignature> {
|
|
1003
1046
|
const updateAdminIx = await this.getUpdateAdminIx(admin);
|
|
1004
1047
|
|
package/src/config.ts
CHANGED
|
@@ -23,6 +23,7 @@ type DriftConfig = {
|
|
|
23
23
|
USDC_MINT_ADDRESS: string;
|
|
24
24
|
SERUM_V3: string;
|
|
25
25
|
PHOENIX: string;
|
|
26
|
+
OPENBOOK: string;
|
|
26
27
|
V2_ALPHA_TICKET_MINT_ADDRESS: string;
|
|
27
28
|
PERP_MARKETS: PerpMarketConfig[];
|
|
28
29
|
SPOT_MARKETS: SpotMarketConfig[];
|
|
@@ -46,6 +47,7 @@ export const configs: { [key in DriftEnv]: DriftConfig } = {
|
|
|
46
47
|
USDC_MINT_ADDRESS: '8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2',
|
|
47
48
|
SERUM_V3: 'DESVgJVGajEgKGXhb6XmqDHGz3VjdgP7rEVESBgxmroY',
|
|
48
49
|
PHOENIX: 'PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY',
|
|
50
|
+
OPENBOOK: 'opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb',
|
|
49
51
|
V2_ALPHA_TICKET_MINT_ADDRESS:
|
|
50
52
|
'DeEiGWfCMP9psnLGkxGrBBMEAW5Jv8bBGMN8DCtFRCyB',
|
|
51
53
|
PERP_MARKETS: DevnetPerpMarkets,
|
|
@@ -61,6 +63,7 @@ export const configs: { [key in DriftEnv]: DriftConfig } = {
|
|
|
61
63
|
USDC_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
62
64
|
SERUM_V3: 'srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX',
|
|
63
65
|
PHOENIX: 'PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY',
|
|
66
|
+
OPENBOOK: 'opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb',
|
|
64
67
|
V2_ALPHA_TICKET_MINT_ADDRESS:
|
|
65
68
|
'Cmvhycb6LQvvzaShGw4iDHRLzeSSryioAsU98DSSkMNa',
|
|
66
69
|
PERP_MARKETS: MainnetPerpMarkets,
|
|
@@ -108,4 +108,4 @@ export const SLOT_TIME_ESTIMATE_MS = 400;
|
|
|
108
108
|
export const DUST_POSITION_SIZE = QUOTE_PRECISION.divn(100); // Dust position is any position smaller than 1c
|
|
109
109
|
|
|
110
110
|
export const FUEL_WINDOW = new BN(60 * 60 * 24 * 28); // 28 days
|
|
111
|
-
export const FUEL_START_TS = new BN(
|
|
111
|
+
export const FUEL_START_TS = new BN(1723075200); // unix timestamp
|
package/src/driftClient.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
createInitializeAccountInstruction,
|
|
15
15
|
getAssociatedTokenAddress,
|
|
16
16
|
TOKEN_PROGRAM_ID,
|
|
17
|
+
TOKEN_2022_PROGRAM_ID,
|
|
17
18
|
} from '@solana/spl-token';
|
|
18
19
|
import {
|
|
19
20
|
StateAccount,
|
|
@@ -119,7 +120,6 @@ import { isSpotPositionAvailable } from './math/spotPosition';
|
|
|
119
120
|
import { calculateMarketMaxAvailableInsurance } from './math/market';
|
|
120
121
|
import { fetchUserStatsAccount } from './accounts/fetch';
|
|
121
122
|
import { castNumberToSpotPrecision } from './math/spotMarket';
|
|
122
|
-
import { getTokenProgramForSpotMarket } from './addresses/pda';
|
|
123
123
|
import {
|
|
124
124
|
JupiterClient,
|
|
125
125
|
QuoteResponse,
|
|
@@ -1973,7 +1973,7 @@ export class DriftClient {
|
|
|
1973
1973
|
const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
|
|
1974
1974
|
|
|
1975
1975
|
this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
|
|
1976
|
-
const tokenProgram = getTokenProgramForSpotMarket(spotMarketAccount);
|
|
1976
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
1977
1977
|
return await this.program.instruction.deposit(
|
|
1978
1978
|
marketIndex,
|
|
1979
1979
|
amount,
|
|
@@ -2060,6 +2060,15 @@ export class DriftClient {
|
|
|
2060
2060
|
return result;
|
|
2061
2061
|
}
|
|
2062
2062
|
|
|
2063
|
+
public getTokenProgramForSpotMarket(
|
|
2064
|
+
spotMarketAccount: SpotMarketAccount
|
|
2065
|
+
): PublicKey {
|
|
2066
|
+
if (spotMarketAccount.tokenProgram === 1) {
|
|
2067
|
+
return TOKEN_2022_PROGRAM_ID;
|
|
2068
|
+
}
|
|
2069
|
+
return TOKEN_PROGRAM_ID;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2063
2072
|
public addTokenMintToRemainingAccounts(
|
|
2064
2073
|
spotMarketAccount: SpotMarketAccount,
|
|
2065
2074
|
remainingAccounts: AccountMeta[]
|
|
@@ -2486,7 +2495,7 @@ export class DriftClient {
|
|
|
2486
2495
|
const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
|
|
2487
2496
|
|
|
2488
2497
|
this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
|
|
2489
|
-
const tokenProgram = getTokenProgramForSpotMarket(spotMarketAccount);
|
|
2498
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
2490
2499
|
|
|
2491
2500
|
return await this.program.instruction.withdraw(
|
|
2492
2501
|
marketIndex,
|
|
@@ -4250,7 +4259,7 @@ export class DriftClient {
|
|
|
4250
4259
|
outAssociatedTokenAccount
|
|
4251
4260
|
);
|
|
4252
4261
|
if (!accountInfo) {
|
|
4253
|
-
const tokenProgram = getTokenProgramForSpotMarket(outMarket);
|
|
4262
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(outMarket);
|
|
4254
4263
|
|
|
4255
4264
|
preInstructions.push(
|
|
4256
4265
|
this.createAssociatedTokenAccountIdempotentInstruction(
|
|
@@ -4274,7 +4283,7 @@ export class DriftClient {
|
|
|
4274
4283
|
inAssociatedTokenAccount
|
|
4275
4284
|
);
|
|
4276
4285
|
if (!accountInfo) {
|
|
4277
|
-
const tokenProgram = getTokenProgramForSpotMarket(outMarket);
|
|
4286
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(outMarket);
|
|
4278
4287
|
|
|
4279
4288
|
preInstructions.push(
|
|
4280
4289
|
this.createAssociatedTokenAccountIdempotentInstruction(
|
|
@@ -4497,8 +4506,8 @@ export class DriftClient {
|
|
|
4497
4506
|
const outSpotMarket = this.getSpotMarketAccount(outMarketIndex);
|
|
4498
4507
|
const inSpotMarket = this.getSpotMarketAccount(inMarketIndex);
|
|
4499
4508
|
|
|
4500
|
-
const outTokenProgram = getTokenProgramForSpotMarket(outSpotMarket);
|
|
4501
|
-
const inTokenProgram = getTokenProgramForSpotMarket(inSpotMarket);
|
|
4509
|
+
const outTokenProgram = this.getTokenProgramForSpotMarket(outSpotMarket);
|
|
4510
|
+
const inTokenProgram = this.getTokenProgramForSpotMarket(inSpotMarket);
|
|
4502
4511
|
|
|
4503
4512
|
if (!outTokenProgram.equals(inTokenProgram)) {
|
|
4504
4513
|
remainingAccounts.push({
|
|
@@ -6651,7 +6660,7 @@ export class DriftClient {
|
|
|
6651
6660
|
|
|
6652
6661
|
const remainingAccounts = [];
|
|
6653
6662
|
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
6654
|
-
const tokenProgram = getTokenProgramForSpotMarket(spotMarket);
|
|
6663
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
6655
6664
|
const ix = this.program.instruction.addInsuranceFundStake(
|
|
6656
6665
|
marketIndex,
|
|
6657
6666
|
amount,
|
|
@@ -6891,7 +6900,7 @@ export class DriftClient {
|
|
|
6891
6900
|
|
|
6892
6901
|
const remainingAccounts = [];
|
|
6893
6902
|
this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
|
|
6894
|
-
const tokenProgram = getTokenProgramForSpotMarket(spotMarketAccount);
|
|
6903
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
6895
6904
|
const removeStakeIx =
|
|
6896
6905
|
await this.program.instruction.removeInsuranceFundStake(marketIndex, {
|
|
6897
6906
|
accounts: {
|
|
@@ -7022,7 +7031,7 @@ export class DriftClient {
|
|
|
7022
7031
|
|
|
7023
7032
|
const remainingAccounts = [];
|
|
7024
7033
|
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
7025
|
-
const tokenProgram = getTokenProgramForSpotMarket(spotMarket);
|
|
7034
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
7026
7035
|
const ix = await this.program.instruction.depositIntoSpotMarketRevenuePool(
|
|
7027
7036
|
amount,
|
|
7028
7037
|
{
|
package/src/events/types.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
InsuranceFundStakeRecord,
|
|
15
15
|
CurveRecord,
|
|
16
16
|
SwapRecord,
|
|
17
|
+
SpotMarketVaultDepositRecord,
|
|
17
18
|
} from '../index';
|
|
18
19
|
import { EventEmitter } from 'events';
|
|
19
20
|
|
|
@@ -47,6 +48,7 @@ export const DefaultEventSubscriptionOptions: EventSubscriptionOptions = {
|
|
|
47
48
|
'InsuranceFundStakeRecord',
|
|
48
49
|
'CurveRecord',
|
|
49
50
|
'SwapRecord',
|
|
51
|
+
'SpotMarketVaultDepositRecord',
|
|
50
52
|
],
|
|
51
53
|
maxEventsPerType: 4096,
|
|
52
54
|
orderBy: 'blockchain',
|
|
@@ -89,6 +91,7 @@ export type EventMap = {
|
|
|
89
91
|
InsuranceFundStakeRecord: Event<InsuranceFundStakeRecord>;
|
|
90
92
|
CurveRecord: Event<CurveRecord>;
|
|
91
93
|
SwapRecord: Event<SwapRecord>;
|
|
94
|
+
SpotMarketVaultDepositRecord: Event<SpotMarketVaultDepositRecord>;
|
|
92
95
|
};
|
|
93
96
|
|
|
94
97
|
export type EventType = keyof EventMap;
|
|
@@ -107,7 +110,8 @@ export type DriftEvent =
|
|
|
107
110
|
| Event<SpotInterestRecord>
|
|
108
111
|
| Event<InsuranceFundStakeRecord>
|
|
109
112
|
| Event<CurveRecord>
|
|
110
|
-
| Event<SwapRecord
|
|
113
|
+
| Event<SwapRecord>
|
|
114
|
+
| Event<SpotMarketVaultDepositRecord>;
|
|
111
115
|
|
|
112
116
|
export interface EventSubscriberEvents {
|
|
113
117
|
newEvent: (event: WrappedEvent<EventType>) => void;
|
package/src/idl/drift.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.87.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -3403,6 +3403,27 @@
|
|
|
3403
3403
|
}
|
|
3404
3404
|
]
|
|
3405
3405
|
},
|
|
3406
|
+
{
|
|
3407
|
+
"name": "initializePredictionMarket",
|
|
3408
|
+
"accounts": [
|
|
3409
|
+
{
|
|
3410
|
+
"name": "admin",
|
|
3411
|
+
"isMut": false,
|
|
3412
|
+
"isSigner": true
|
|
3413
|
+
},
|
|
3414
|
+
{
|
|
3415
|
+
"name": "state",
|
|
3416
|
+
"isMut": false,
|
|
3417
|
+
"isSigner": false
|
|
3418
|
+
},
|
|
3419
|
+
{
|
|
3420
|
+
"name": "perpMarket",
|
|
3421
|
+
"isMut": true,
|
|
3422
|
+
"isSigner": false
|
|
3423
|
+
}
|
|
3424
|
+
],
|
|
3425
|
+
"args": []
|
|
3426
|
+
},
|
|
3406
3427
|
{
|
|
3407
3428
|
"name": "deleteInitializedPerpMarket",
|
|
3408
3429
|
"accounts": [
|
|
@@ -3634,6 +3655,47 @@
|
|
|
3634
3655
|
}
|
|
3635
3656
|
]
|
|
3636
3657
|
},
|
|
3658
|
+
{
|
|
3659
|
+
"name": "depositIntoSpotMarketVault",
|
|
3660
|
+
"accounts": [
|
|
3661
|
+
{
|
|
3662
|
+
"name": "state",
|
|
3663
|
+
"isMut": false,
|
|
3664
|
+
"isSigner": false
|
|
3665
|
+
},
|
|
3666
|
+
{
|
|
3667
|
+
"name": "spotMarket",
|
|
3668
|
+
"isMut": true,
|
|
3669
|
+
"isSigner": false
|
|
3670
|
+
},
|
|
3671
|
+
{
|
|
3672
|
+
"name": "admin",
|
|
3673
|
+
"isMut": false,
|
|
3674
|
+
"isSigner": true
|
|
3675
|
+
},
|
|
3676
|
+
{
|
|
3677
|
+
"name": "sourceVault",
|
|
3678
|
+
"isMut": true,
|
|
3679
|
+
"isSigner": false
|
|
3680
|
+
},
|
|
3681
|
+
{
|
|
3682
|
+
"name": "spotMarketVault",
|
|
3683
|
+
"isMut": true,
|
|
3684
|
+
"isSigner": false
|
|
3685
|
+
},
|
|
3686
|
+
{
|
|
3687
|
+
"name": "tokenProgram",
|
|
3688
|
+
"isMut": false,
|
|
3689
|
+
"isSigner": false
|
|
3690
|
+
}
|
|
3691
|
+
],
|
|
3692
|
+
"args": [
|
|
3693
|
+
{
|
|
3694
|
+
"name": "amount",
|
|
3695
|
+
"type": "u64"
|
|
3696
|
+
}
|
|
3697
|
+
]
|
|
3698
|
+
},
|
|
3637
3699
|
{
|
|
3638
3700
|
"name": "depositIntoSpotMarketRevenuePool",
|
|
3639
3701
|
"accounts": [
|
|
@@ -10148,6 +10210,9 @@
|
|
|
10148
10210
|
},
|
|
10149
10211
|
{
|
|
10150
10212
|
"name": "Future"
|
|
10213
|
+
},
|
|
10214
|
+
{
|
|
10215
|
+
"name": "Prediction"
|
|
10151
10216
|
}
|
|
10152
10217
|
]
|
|
10153
10218
|
}
|
|
@@ -11400,6 +11465,46 @@
|
|
|
11400
11465
|
"index": false
|
|
11401
11466
|
}
|
|
11402
11467
|
]
|
|
11468
|
+
},
|
|
11469
|
+
{
|
|
11470
|
+
"name": "SpotMarketVaultDepositRecord",
|
|
11471
|
+
"fields": [
|
|
11472
|
+
{
|
|
11473
|
+
"name": "ts",
|
|
11474
|
+
"type": "i64",
|
|
11475
|
+
"index": false
|
|
11476
|
+
},
|
|
11477
|
+
{
|
|
11478
|
+
"name": "marketIndex",
|
|
11479
|
+
"type": "u16",
|
|
11480
|
+
"index": false
|
|
11481
|
+
},
|
|
11482
|
+
{
|
|
11483
|
+
"name": "depositBalance",
|
|
11484
|
+
"type": "u128",
|
|
11485
|
+
"index": false
|
|
11486
|
+
},
|
|
11487
|
+
{
|
|
11488
|
+
"name": "cumulativeDepositInterestBefore",
|
|
11489
|
+
"type": "u128",
|
|
11490
|
+
"index": false
|
|
11491
|
+
},
|
|
11492
|
+
{
|
|
11493
|
+
"name": "cumulativeDepositInterestAfter",
|
|
11494
|
+
"type": "u128",
|
|
11495
|
+
"index": false
|
|
11496
|
+
},
|
|
11497
|
+
{
|
|
11498
|
+
"name": "depositTokenAmountBefore",
|
|
11499
|
+
"type": "u64",
|
|
11500
|
+
"index": false
|
|
11501
|
+
},
|
|
11502
|
+
{
|
|
11503
|
+
"name": "amount",
|
|
11504
|
+
"type": "u64",
|
|
11505
|
+
"index": false
|
|
11506
|
+
}
|
|
11507
|
+
]
|
|
11403
11508
|
}
|
|
11404
11509
|
],
|
|
11405
11510
|
"errors": [
|
|
@@ -12827,4 +12932,4 @@
|
|
|
12827
12932
|
"metadata": {
|
|
12828
12933
|
"address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
|
|
12829
12934
|
}
|
|
12830
|
-
}
|
|
12935
|
+
}
|
|
@@ -95,9 +95,8 @@ export class OpenbookV2Subscriber implements L2OrderBookGenerator {
|
|
|
95
95
|
this.subscribed = true;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
public
|
|
99
|
-
const
|
|
100
|
-
const bestBid = bids.best();
|
|
98
|
+
public getBestBid(): BN | undefined {
|
|
99
|
+
const bestBid = this.market.bids.best();
|
|
101
100
|
|
|
102
101
|
if (bestBid === undefined) {
|
|
103
102
|
return undefined;
|
|
@@ -106,9 +105,8 @@ export class OpenbookV2Subscriber implements L2OrderBookGenerator {
|
|
|
106
105
|
return new BN(Math.floor(bestBid.price * PRICE_PRECISION.toNumber()));
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
public
|
|
110
|
-
const
|
|
111
|
-
const bestAsk = asks.best();
|
|
108
|
+
public getBestAsk(): BN | undefined {
|
|
109
|
+
const bestAsk = this.market.asks.best();
|
|
112
110
|
|
|
113
111
|
if (bestAsk === undefined) {
|
|
114
112
|
return undefined;
|
package/src/types.ts
CHANGED
|
@@ -576,6 +576,16 @@ export type SwapRecord = {
|
|
|
576
576
|
fee: BN;
|
|
577
577
|
};
|
|
578
578
|
|
|
579
|
+
export type SpotMarketVaultDepositRecord = {
|
|
580
|
+
ts: BN;
|
|
581
|
+
marketIndex: number;
|
|
582
|
+
depositBalance: BN;
|
|
583
|
+
cumulativeDepositInterestBefore: BN;
|
|
584
|
+
cumulativeDepositInterestAfter: BN;
|
|
585
|
+
depositTokenAmountBefore: BN;
|
|
586
|
+
amount: BN;
|
|
587
|
+
};
|
|
588
|
+
|
|
579
589
|
export type StateAccount = {
|
|
580
590
|
admin: PublicKey;
|
|
581
591
|
exchangeStatus: number;
|