@drift-labs/sdk 2.103.0-beta.2 → 2.103.0-beta.4
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/browser/adminClient.d.ts +2 -0
- package/lib/browser/adminClient.js +17 -0
- package/lib/browser/constants/spotMarkets.js +1 -0
- package/lib/browser/driftClient.d.ts +5 -0
- package/lib/browser/driftClient.js +17 -0
- package/lib/browser/idl/drift.json +67 -3
- package/lib/browser/types.d.ts +1 -0
- package/lib/node/adminClient.d.ts +2 -0
- package/lib/node/adminClient.js +17 -0
- package/lib/node/constants/spotMarkets.js +1 -0
- package/lib/node/driftClient.d.ts +5 -0
- package/lib/node/driftClient.js +17 -0
- package/lib/node/idl/drift.json +67 -3
- package/lib/node/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/adminClient.ts +34 -0
- package/src/constants/spotMarkets.ts +3 -0
- package/src/driftClient.ts +34 -0
- package/src/idl/drift.json +67 -3
- package/src/types.ts +2 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.103.0-beta.
|
|
1
|
+
2.103.0-beta.4
|
|
@@ -67,6 +67,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
67
67
|
getUpdatePerpMarketNameIx(perpMarketIndex: number, name: string): Promise<TransactionInstruction>;
|
|
68
68
|
updateSpotMarketName(spotMarketIndex: number, name: string): Promise<TransactionSignature>;
|
|
69
69
|
getUpdateSpotMarketNameIx(spotMarketIndex: number, name: string): Promise<TransactionInstruction>;
|
|
70
|
+
updateSpotMarketPoolId(spotMarketIndex: number, poolId: number): Promise<TransactionSignature>;
|
|
71
|
+
getUpdateSpotMarketPoolIdIx(spotMarketIndex: number, poolId: number): Promise<TransactionInstruction>;
|
|
70
72
|
updatePerpMarketPerLpBase(perpMarketIndex: number, perLpBase: number): Promise<TransactionSignature>;
|
|
71
73
|
getUpdatePerpMarketPerLpBaseIx(perpMarketIndex: number, perLpBase: number): Promise<TransactionInstruction>;
|
|
72
74
|
updatePerpMarketMaxSpread(perpMarketIndex: number, maxSpread: number): Promise<TransactionSignature>;
|
|
@@ -665,6 +665,23 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
665
665
|
},
|
|
666
666
|
});
|
|
667
667
|
}
|
|
668
|
+
async updateSpotMarketPoolId(spotMarketIndex, poolId) {
|
|
669
|
+
const updateSpotMarketPoolIdIx = await this.getUpdateSpotMarketPoolIdIx(spotMarketIndex, poolId);
|
|
670
|
+
const tx = await this.buildTransaction(updateSpotMarketPoolIdIx);
|
|
671
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
672
|
+
return txSig;
|
|
673
|
+
}
|
|
674
|
+
async getUpdateSpotMarketPoolIdIx(spotMarketIndex, poolId) {
|
|
675
|
+
return await this.program.instruction.updateSpotMarketPoolId(poolId, {
|
|
676
|
+
accounts: {
|
|
677
|
+
admin: this.isSubscribed
|
|
678
|
+
? this.getStateAccount().admin
|
|
679
|
+
: this.wallet.publicKey,
|
|
680
|
+
state: await this.getStatePublicKey(),
|
|
681
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
}
|
|
668
685
|
async updatePerpMarketPerLpBase(perpMarketIndex, perLpBase) {
|
|
669
686
|
const updatePerpMarketPerLpBaseIx = await this.getUpdatePerpMarketPerLpBaseIx(perpMarketIndex, perLpBase);
|
|
670
687
|
const tx = await this.buildTransaction(updatePerpMarketPerLpBaseIx);
|
|
@@ -363,6 +363,7 @@ exports.MainnetSpotMarkets = [
|
|
|
363
363
|
mint: new web3_js_1.PublicKey('cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij'),
|
|
364
364
|
precision: new __1.BN(10).pow(numericConstants_1.EIGHT),
|
|
365
365
|
precisionExp: numericConstants_1.EIGHT,
|
|
366
|
+
openbookMarket: new web3_js_1.PublicKey('2HXgKaXKsMUEzQaSBZiXSd54eMHaS3roiefyGWtkW97W'),
|
|
366
367
|
pythFeedId: '0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
|
|
367
368
|
},
|
|
368
369
|
{
|
|
@@ -171,6 +171,11 @@ export declare class DriftClient {
|
|
|
171
171
|
subAccountId: number;
|
|
172
172
|
}[]): Promise<TransactionSignature>;
|
|
173
173
|
getUpdateUserReduceOnlyIx(reduceOnly: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
|
|
174
|
+
updateUserPoolId(updates: {
|
|
175
|
+
poolId: number;
|
|
176
|
+
subAccountId: number;
|
|
177
|
+
}[]): Promise<TransactionSignature>;
|
|
178
|
+
getUpdateUserPoolIdIx(poolId: number, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
|
|
174
179
|
fetchAllUserAccounts(includeIdle?: boolean): Promise<ProgramAccount<UserAccount>[]>;
|
|
175
180
|
getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>;
|
|
176
181
|
getUserAccountsAndAddressesForAuthority(authority: PublicKey): Promise<ProgramAccount<UserAccount>[]>;
|
|
@@ -824,6 +824,23 @@ class DriftClient {
|
|
|
824
824
|
});
|
|
825
825
|
return ix;
|
|
826
826
|
}
|
|
827
|
+
async updateUserPoolId(updates) {
|
|
828
|
+
const ixs = await Promise.all(updates.map(async ({ poolId, subAccountId }) => {
|
|
829
|
+
return await this.getUpdateUserPoolIdIx(poolId, subAccountId);
|
|
830
|
+
}));
|
|
831
|
+
const tx = await this.buildTransaction(ixs, this.txParams);
|
|
832
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
833
|
+
return txSig;
|
|
834
|
+
}
|
|
835
|
+
async getUpdateUserPoolIdIx(poolId, subAccountId) {
|
|
836
|
+
const ix = await this.program.instruction.updateUserPoolId(subAccountId, poolId, {
|
|
837
|
+
accounts: {
|
|
838
|
+
user: (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId),
|
|
839
|
+
authority: this.wallet.publicKey,
|
|
840
|
+
},
|
|
841
|
+
});
|
|
842
|
+
return ix;
|
|
843
|
+
}
|
|
827
844
|
async fetchAllUserAccounts(includeIdle = true) {
|
|
828
845
|
let filters = undefined;
|
|
829
846
|
if (!includeIdle) {
|
|
@@ -1357,6 +1357,31 @@
|
|
|
1357
1357
|
}
|
|
1358
1358
|
]
|
|
1359
1359
|
},
|
|
1360
|
+
{
|
|
1361
|
+
"name": "updateUserPoolId",
|
|
1362
|
+
"accounts": [
|
|
1363
|
+
{
|
|
1364
|
+
"name": "user",
|
|
1365
|
+
"isMut": true,
|
|
1366
|
+
"isSigner": false
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
"name": "authority",
|
|
1370
|
+
"isMut": false,
|
|
1371
|
+
"isSigner": true
|
|
1372
|
+
}
|
|
1373
|
+
],
|
|
1374
|
+
"args": [
|
|
1375
|
+
{
|
|
1376
|
+
"name": "subAccountId",
|
|
1377
|
+
"type": "u16"
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
"name": "poolId",
|
|
1381
|
+
"type": "u8"
|
|
1382
|
+
}
|
|
1383
|
+
]
|
|
1384
|
+
},
|
|
1360
1385
|
{
|
|
1361
1386
|
"name": "updateUserDelegate",
|
|
1362
1387
|
"accounts": [
|
|
@@ -4500,6 +4525,32 @@
|
|
|
4500
4525
|
}
|
|
4501
4526
|
]
|
|
4502
4527
|
},
|
|
4528
|
+
{
|
|
4529
|
+
"name": "updateSpotMarketPoolId",
|
|
4530
|
+
"accounts": [
|
|
4531
|
+
{
|
|
4532
|
+
"name": "admin",
|
|
4533
|
+
"isMut": false,
|
|
4534
|
+
"isSigner": true
|
|
4535
|
+
},
|
|
4536
|
+
{
|
|
4537
|
+
"name": "state",
|
|
4538
|
+
"isMut": false,
|
|
4539
|
+
"isSigner": false
|
|
4540
|
+
},
|
|
4541
|
+
{
|
|
4542
|
+
"name": "spotMarket",
|
|
4543
|
+
"isMut": true,
|
|
4544
|
+
"isSigner": false
|
|
4545
|
+
}
|
|
4546
|
+
],
|
|
4547
|
+
"args": [
|
|
4548
|
+
{
|
|
4549
|
+
"name": "poolId",
|
|
4550
|
+
"type": "u8"
|
|
4551
|
+
}
|
|
4552
|
+
]
|
|
4553
|
+
},
|
|
4503
4554
|
{
|
|
4504
4555
|
"name": "updateSpotMarketLiquidationFee",
|
|
4505
4556
|
"accounts": [
|
|
@@ -7039,7 +7090,7 @@
|
|
|
7039
7090
|
"type": "u8"
|
|
7040
7091
|
},
|
|
7041
7092
|
{
|
|
7042
|
-
"name": "
|
|
7093
|
+
"name": "poolId",
|
|
7043
7094
|
"type": "u8"
|
|
7044
7095
|
},
|
|
7045
7096
|
{
|
|
@@ -7575,12 +7626,16 @@
|
|
|
7575
7626
|
"name": "tokenProgram",
|
|
7576
7627
|
"type": "u8"
|
|
7577
7628
|
},
|
|
7629
|
+
{
|
|
7630
|
+
"name": "poolId",
|
|
7631
|
+
"type": "u8"
|
|
7632
|
+
},
|
|
7578
7633
|
{
|
|
7579
7634
|
"name": "padding",
|
|
7580
7635
|
"type": {
|
|
7581
7636
|
"array": [
|
|
7582
7637
|
"u8",
|
|
7583
|
-
|
|
7638
|
+
40
|
|
7584
7639
|
]
|
|
7585
7640
|
}
|
|
7586
7641
|
}
|
|
@@ -7961,12 +8016,16 @@
|
|
|
7961
8016
|
"defined": "MarginMode"
|
|
7962
8017
|
}
|
|
7963
8018
|
},
|
|
8019
|
+
{
|
|
8020
|
+
"name": "poolId",
|
|
8021
|
+
"type": "u8"
|
|
8022
|
+
},
|
|
7964
8023
|
{
|
|
7965
8024
|
"name": "padding1",
|
|
7966
8025
|
"type": {
|
|
7967
8026
|
"array": [
|
|
7968
8027
|
"u8",
|
|
7969
|
-
|
|
8028
|
+
3
|
|
7970
8029
|
]
|
|
7971
8030
|
}
|
|
7972
8031
|
},
|
|
@@ -14089,6 +14148,11 @@
|
|
|
14089
14148
|
"code": 6301,
|
|
14090
14149
|
"name": "InvalidSwiftOrderId",
|
|
14091
14150
|
"msg": "Swift order id cannot be 0s"
|
|
14151
|
+
},
|
|
14152
|
+
{
|
|
14153
|
+
"code": 6302,
|
|
14154
|
+
"name": "InvalidPoolId",
|
|
14155
|
+
"msg": "Invalid pool id"
|
|
14092
14156
|
}
|
|
14093
14157
|
],
|
|
14094
14158
|
"metadata": {
|
package/lib/browser/types.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
67
67
|
getUpdatePerpMarketNameIx(perpMarketIndex: number, name: string): Promise<TransactionInstruction>;
|
|
68
68
|
updateSpotMarketName(spotMarketIndex: number, name: string): Promise<TransactionSignature>;
|
|
69
69
|
getUpdateSpotMarketNameIx(spotMarketIndex: number, name: string): Promise<TransactionInstruction>;
|
|
70
|
+
updateSpotMarketPoolId(spotMarketIndex: number, poolId: number): Promise<TransactionSignature>;
|
|
71
|
+
getUpdateSpotMarketPoolIdIx(spotMarketIndex: number, poolId: number): Promise<TransactionInstruction>;
|
|
70
72
|
updatePerpMarketPerLpBase(perpMarketIndex: number, perLpBase: number): Promise<TransactionSignature>;
|
|
71
73
|
getUpdatePerpMarketPerLpBaseIx(perpMarketIndex: number, perLpBase: number): Promise<TransactionInstruction>;
|
|
72
74
|
updatePerpMarketMaxSpread(perpMarketIndex: number, maxSpread: number): Promise<TransactionSignature>;
|
package/lib/node/adminClient.js
CHANGED
|
@@ -665,6 +665,23 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
665
665
|
},
|
|
666
666
|
});
|
|
667
667
|
}
|
|
668
|
+
async updateSpotMarketPoolId(spotMarketIndex, poolId) {
|
|
669
|
+
const updateSpotMarketPoolIdIx = await this.getUpdateSpotMarketPoolIdIx(spotMarketIndex, poolId);
|
|
670
|
+
const tx = await this.buildTransaction(updateSpotMarketPoolIdIx);
|
|
671
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
672
|
+
return txSig;
|
|
673
|
+
}
|
|
674
|
+
async getUpdateSpotMarketPoolIdIx(spotMarketIndex, poolId) {
|
|
675
|
+
return await this.program.instruction.updateSpotMarketPoolId(poolId, {
|
|
676
|
+
accounts: {
|
|
677
|
+
admin: this.isSubscribed
|
|
678
|
+
? this.getStateAccount().admin
|
|
679
|
+
: this.wallet.publicKey,
|
|
680
|
+
state: await this.getStatePublicKey(),
|
|
681
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
}
|
|
668
685
|
async updatePerpMarketPerLpBase(perpMarketIndex, perLpBase) {
|
|
669
686
|
const updatePerpMarketPerLpBaseIx = await this.getUpdatePerpMarketPerLpBaseIx(perpMarketIndex, perLpBase);
|
|
670
687
|
const tx = await this.buildTransaction(updatePerpMarketPerLpBaseIx);
|
|
@@ -363,6 +363,7 @@ exports.MainnetSpotMarkets = [
|
|
|
363
363
|
mint: new web3_js_1.PublicKey('cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij'),
|
|
364
364
|
precision: new __1.BN(10).pow(numericConstants_1.EIGHT),
|
|
365
365
|
precisionExp: numericConstants_1.EIGHT,
|
|
366
|
+
openbookMarket: new web3_js_1.PublicKey('2HXgKaXKsMUEzQaSBZiXSd54eMHaS3roiefyGWtkW97W'),
|
|
366
367
|
pythFeedId: '0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
|
|
367
368
|
},
|
|
368
369
|
{
|
|
@@ -171,6 +171,11 @@ export declare class DriftClient {
|
|
|
171
171
|
subAccountId: number;
|
|
172
172
|
}[]): Promise<TransactionSignature>;
|
|
173
173
|
getUpdateUserReduceOnlyIx(reduceOnly: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
|
|
174
|
+
updateUserPoolId(updates: {
|
|
175
|
+
poolId: number;
|
|
176
|
+
subAccountId: number;
|
|
177
|
+
}[]): Promise<TransactionSignature>;
|
|
178
|
+
getUpdateUserPoolIdIx(poolId: number, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
|
|
174
179
|
fetchAllUserAccounts(includeIdle?: boolean): Promise<ProgramAccount<UserAccount>[]>;
|
|
175
180
|
getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>;
|
|
176
181
|
getUserAccountsAndAddressesForAuthority(authority: PublicKey): Promise<ProgramAccount<UserAccount>[]>;
|
package/lib/node/driftClient.js
CHANGED
|
@@ -824,6 +824,23 @@ class DriftClient {
|
|
|
824
824
|
});
|
|
825
825
|
return ix;
|
|
826
826
|
}
|
|
827
|
+
async updateUserPoolId(updates) {
|
|
828
|
+
const ixs = await Promise.all(updates.map(async ({ poolId, subAccountId }) => {
|
|
829
|
+
return await this.getUpdateUserPoolIdIx(poolId, subAccountId);
|
|
830
|
+
}));
|
|
831
|
+
const tx = await this.buildTransaction(ixs, this.txParams);
|
|
832
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
833
|
+
return txSig;
|
|
834
|
+
}
|
|
835
|
+
async getUpdateUserPoolIdIx(poolId, subAccountId) {
|
|
836
|
+
const ix = await this.program.instruction.updateUserPoolId(subAccountId, poolId, {
|
|
837
|
+
accounts: {
|
|
838
|
+
user: (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId),
|
|
839
|
+
authority: this.wallet.publicKey,
|
|
840
|
+
},
|
|
841
|
+
});
|
|
842
|
+
return ix;
|
|
843
|
+
}
|
|
827
844
|
async fetchAllUserAccounts(includeIdle = true) {
|
|
828
845
|
let filters = undefined;
|
|
829
846
|
if (!includeIdle) {
|
package/lib/node/idl/drift.json
CHANGED
|
@@ -1357,6 +1357,31 @@
|
|
|
1357
1357
|
}
|
|
1358
1358
|
]
|
|
1359
1359
|
},
|
|
1360
|
+
{
|
|
1361
|
+
"name": "updateUserPoolId",
|
|
1362
|
+
"accounts": [
|
|
1363
|
+
{
|
|
1364
|
+
"name": "user",
|
|
1365
|
+
"isMut": true,
|
|
1366
|
+
"isSigner": false
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
"name": "authority",
|
|
1370
|
+
"isMut": false,
|
|
1371
|
+
"isSigner": true
|
|
1372
|
+
}
|
|
1373
|
+
],
|
|
1374
|
+
"args": [
|
|
1375
|
+
{
|
|
1376
|
+
"name": "subAccountId",
|
|
1377
|
+
"type": "u16"
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
"name": "poolId",
|
|
1381
|
+
"type": "u8"
|
|
1382
|
+
}
|
|
1383
|
+
]
|
|
1384
|
+
},
|
|
1360
1385
|
{
|
|
1361
1386
|
"name": "updateUserDelegate",
|
|
1362
1387
|
"accounts": [
|
|
@@ -4500,6 +4525,32 @@
|
|
|
4500
4525
|
}
|
|
4501
4526
|
]
|
|
4502
4527
|
},
|
|
4528
|
+
{
|
|
4529
|
+
"name": "updateSpotMarketPoolId",
|
|
4530
|
+
"accounts": [
|
|
4531
|
+
{
|
|
4532
|
+
"name": "admin",
|
|
4533
|
+
"isMut": false,
|
|
4534
|
+
"isSigner": true
|
|
4535
|
+
},
|
|
4536
|
+
{
|
|
4537
|
+
"name": "state",
|
|
4538
|
+
"isMut": false,
|
|
4539
|
+
"isSigner": false
|
|
4540
|
+
},
|
|
4541
|
+
{
|
|
4542
|
+
"name": "spotMarket",
|
|
4543
|
+
"isMut": true,
|
|
4544
|
+
"isSigner": false
|
|
4545
|
+
}
|
|
4546
|
+
],
|
|
4547
|
+
"args": [
|
|
4548
|
+
{
|
|
4549
|
+
"name": "poolId",
|
|
4550
|
+
"type": "u8"
|
|
4551
|
+
}
|
|
4552
|
+
]
|
|
4553
|
+
},
|
|
4503
4554
|
{
|
|
4504
4555
|
"name": "updateSpotMarketLiquidationFee",
|
|
4505
4556
|
"accounts": [
|
|
@@ -7039,7 +7090,7 @@
|
|
|
7039
7090
|
"type": "u8"
|
|
7040
7091
|
},
|
|
7041
7092
|
{
|
|
7042
|
-
"name": "
|
|
7093
|
+
"name": "poolId",
|
|
7043
7094
|
"type": "u8"
|
|
7044
7095
|
},
|
|
7045
7096
|
{
|
|
@@ -7575,12 +7626,16 @@
|
|
|
7575
7626
|
"name": "tokenProgram",
|
|
7576
7627
|
"type": "u8"
|
|
7577
7628
|
},
|
|
7629
|
+
{
|
|
7630
|
+
"name": "poolId",
|
|
7631
|
+
"type": "u8"
|
|
7632
|
+
},
|
|
7578
7633
|
{
|
|
7579
7634
|
"name": "padding",
|
|
7580
7635
|
"type": {
|
|
7581
7636
|
"array": [
|
|
7582
7637
|
"u8",
|
|
7583
|
-
|
|
7638
|
+
40
|
|
7584
7639
|
]
|
|
7585
7640
|
}
|
|
7586
7641
|
}
|
|
@@ -7961,12 +8016,16 @@
|
|
|
7961
8016
|
"defined": "MarginMode"
|
|
7962
8017
|
}
|
|
7963
8018
|
},
|
|
8019
|
+
{
|
|
8020
|
+
"name": "poolId",
|
|
8021
|
+
"type": "u8"
|
|
8022
|
+
},
|
|
7964
8023
|
{
|
|
7965
8024
|
"name": "padding1",
|
|
7966
8025
|
"type": {
|
|
7967
8026
|
"array": [
|
|
7968
8027
|
"u8",
|
|
7969
|
-
|
|
8028
|
+
3
|
|
7970
8029
|
]
|
|
7971
8030
|
}
|
|
7972
8031
|
},
|
|
@@ -14089,6 +14148,11 @@
|
|
|
14089
14148
|
"code": 6301,
|
|
14090
14149
|
"name": "InvalidSwiftOrderId",
|
|
14091
14150
|
"msg": "Swift order id cannot be 0s"
|
|
14151
|
+
},
|
|
14152
|
+
{
|
|
14153
|
+
"code": 6302,
|
|
14154
|
+
"name": "InvalidPoolId",
|
|
14155
|
+
"msg": "Invalid pool id"
|
|
14092
14156
|
}
|
|
14093
14157
|
],
|
|
14094
14158
|
"metadata": {
|
package/lib/node/types.d.ts
CHANGED
package/package.json
CHANGED
package/src/adminClient.ts
CHANGED
|
@@ -1497,6 +1497,40 @@ export class AdminClient extends DriftClient {
|
|
|
1497
1497
|
});
|
|
1498
1498
|
}
|
|
1499
1499
|
|
|
1500
|
+
public async updateSpotMarketPoolId(
|
|
1501
|
+
spotMarketIndex: number,
|
|
1502
|
+
poolId: number
|
|
1503
|
+
): Promise<TransactionSignature> {
|
|
1504
|
+
const updateSpotMarketPoolIdIx = await this.getUpdateSpotMarketPoolIdIx(
|
|
1505
|
+
spotMarketIndex,
|
|
1506
|
+
poolId
|
|
1507
|
+
);
|
|
1508
|
+
|
|
1509
|
+
const tx = await this.buildTransaction(updateSpotMarketPoolIdIx);
|
|
1510
|
+
|
|
1511
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1512
|
+
|
|
1513
|
+
return txSig;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
public async getUpdateSpotMarketPoolIdIx(
|
|
1517
|
+
spotMarketIndex: number,
|
|
1518
|
+
poolId: number
|
|
1519
|
+
): Promise<TransactionInstruction> {
|
|
1520
|
+
return await this.program.instruction.updateSpotMarketPoolId(poolId, {
|
|
1521
|
+
accounts: {
|
|
1522
|
+
admin: this.isSubscribed
|
|
1523
|
+
? this.getStateAccount().admin
|
|
1524
|
+
: this.wallet.publicKey,
|
|
1525
|
+
state: await this.getStatePublicKey(),
|
|
1526
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1527
|
+
this.program.programId,
|
|
1528
|
+
spotMarketIndex
|
|
1529
|
+
),
|
|
1530
|
+
},
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1500
1534
|
public async updatePerpMarketPerLpBase(
|
|
1501
1535
|
perpMarketIndex: number,
|
|
1502
1536
|
perLpBase: number
|
|
@@ -447,6 +447,9 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
|
|
|
447
447
|
mint: new PublicKey('cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij'),
|
|
448
448
|
precision: new BN(10).pow(EIGHT),
|
|
449
449
|
precisionExp: EIGHT,
|
|
450
|
+
openbookMarket: new PublicKey(
|
|
451
|
+
'2HXgKaXKsMUEzQaSBZiXSd54eMHaS3roiefyGWtkW97W'
|
|
452
|
+
),
|
|
450
453
|
pythFeedId:
|
|
451
454
|
'0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
|
|
452
455
|
},
|
package/src/driftClient.ts
CHANGED
|
@@ -1440,6 +1440,40 @@ export class DriftClient {
|
|
|
1440
1440
|
return ix;
|
|
1441
1441
|
}
|
|
1442
1442
|
|
|
1443
|
+
public async updateUserPoolId(
|
|
1444
|
+
updates: { poolId: number; subAccountId: number }[]
|
|
1445
|
+
): Promise<TransactionSignature> {
|
|
1446
|
+
const ixs = await Promise.all(
|
|
1447
|
+
updates.map(async ({ poolId, subAccountId }) => {
|
|
1448
|
+
return await this.getUpdateUserPoolIdIx(poolId, subAccountId);
|
|
1449
|
+
})
|
|
1450
|
+
);
|
|
1451
|
+
|
|
1452
|
+
const tx = await this.buildTransaction(ixs, this.txParams);
|
|
1453
|
+
|
|
1454
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1455
|
+
return txSig;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
public async getUpdateUserPoolIdIx(poolId: number, subAccountId: number) {
|
|
1459
|
+
const ix = await this.program.instruction.updateUserPoolId(
|
|
1460
|
+
subAccountId,
|
|
1461
|
+
poolId,
|
|
1462
|
+
{
|
|
1463
|
+
accounts: {
|
|
1464
|
+
user: getUserAccountPublicKeySync(
|
|
1465
|
+
this.program.programId,
|
|
1466
|
+
this.wallet.publicKey,
|
|
1467
|
+
subAccountId
|
|
1468
|
+
),
|
|
1469
|
+
authority: this.wallet.publicKey,
|
|
1470
|
+
},
|
|
1471
|
+
}
|
|
1472
|
+
);
|
|
1473
|
+
|
|
1474
|
+
return ix;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1443
1477
|
public async fetchAllUserAccounts(
|
|
1444
1478
|
includeIdle = true
|
|
1445
1479
|
): Promise<ProgramAccount<UserAccount>[]> {
|
package/src/idl/drift.json
CHANGED
|
@@ -1357,6 +1357,31 @@
|
|
|
1357
1357
|
}
|
|
1358
1358
|
]
|
|
1359
1359
|
},
|
|
1360
|
+
{
|
|
1361
|
+
"name": "updateUserPoolId",
|
|
1362
|
+
"accounts": [
|
|
1363
|
+
{
|
|
1364
|
+
"name": "user",
|
|
1365
|
+
"isMut": true,
|
|
1366
|
+
"isSigner": false
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
"name": "authority",
|
|
1370
|
+
"isMut": false,
|
|
1371
|
+
"isSigner": true
|
|
1372
|
+
}
|
|
1373
|
+
],
|
|
1374
|
+
"args": [
|
|
1375
|
+
{
|
|
1376
|
+
"name": "subAccountId",
|
|
1377
|
+
"type": "u16"
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
"name": "poolId",
|
|
1381
|
+
"type": "u8"
|
|
1382
|
+
}
|
|
1383
|
+
]
|
|
1384
|
+
},
|
|
1360
1385
|
{
|
|
1361
1386
|
"name": "updateUserDelegate",
|
|
1362
1387
|
"accounts": [
|
|
@@ -4500,6 +4525,32 @@
|
|
|
4500
4525
|
}
|
|
4501
4526
|
]
|
|
4502
4527
|
},
|
|
4528
|
+
{
|
|
4529
|
+
"name": "updateSpotMarketPoolId",
|
|
4530
|
+
"accounts": [
|
|
4531
|
+
{
|
|
4532
|
+
"name": "admin",
|
|
4533
|
+
"isMut": false,
|
|
4534
|
+
"isSigner": true
|
|
4535
|
+
},
|
|
4536
|
+
{
|
|
4537
|
+
"name": "state",
|
|
4538
|
+
"isMut": false,
|
|
4539
|
+
"isSigner": false
|
|
4540
|
+
},
|
|
4541
|
+
{
|
|
4542
|
+
"name": "spotMarket",
|
|
4543
|
+
"isMut": true,
|
|
4544
|
+
"isSigner": false
|
|
4545
|
+
}
|
|
4546
|
+
],
|
|
4547
|
+
"args": [
|
|
4548
|
+
{
|
|
4549
|
+
"name": "poolId",
|
|
4550
|
+
"type": "u8"
|
|
4551
|
+
}
|
|
4552
|
+
]
|
|
4553
|
+
},
|
|
4503
4554
|
{
|
|
4504
4555
|
"name": "updateSpotMarketLiquidationFee",
|
|
4505
4556
|
"accounts": [
|
|
@@ -7039,7 +7090,7 @@
|
|
|
7039
7090
|
"type": "u8"
|
|
7040
7091
|
},
|
|
7041
7092
|
{
|
|
7042
|
-
"name": "
|
|
7093
|
+
"name": "poolId",
|
|
7043
7094
|
"type": "u8"
|
|
7044
7095
|
},
|
|
7045
7096
|
{
|
|
@@ -7575,12 +7626,16 @@
|
|
|
7575
7626
|
"name": "tokenProgram",
|
|
7576
7627
|
"type": "u8"
|
|
7577
7628
|
},
|
|
7629
|
+
{
|
|
7630
|
+
"name": "poolId",
|
|
7631
|
+
"type": "u8"
|
|
7632
|
+
},
|
|
7578
7633
|
{
|
|
7579
7634
|
"name": "padding",
|
|
7580
7635
|
"type": {
|
|
7581
7636
|
"array": [
|
|
7582
7637
|
"u8",
|
|
7583
|
-
|
|
7638
|
+
40
|
|
7584
7639
|
]
|
|
7585
7640
|
}
|
|
7586
7641
|
}
|
|
@@ -7961,12 +8016,16 @@
|
|
|
7961
8016
|
"defined": "MarginMode"
|
|
7962
8017
|
}
|
|
7963
8018
|
},
|
|
8019
|
+
{
|
|
8020
|
+
"name": "poolId",
|
|
8021
|
+
"type": "u8"
|
|
8022
|
+
},
|
|
7964
8023
|
{
|
|
7965
8024
|
"name": "padding1",
|
|
7966
8025
|
"type": {
|
|
7967
8026
|
"array": [
|
|
7968
8027
|
"u8",
|
|
7969
|
-
|
|
8028
|
+
3
|
|
7970
8029
|
]
|
|
7971
8030
|
}
|
|
7972
8031
|
},
|
|
@@ -14089,6 +14148,11 @@
|
|
|
14089
14148
|
"code": 6301,
|
|
14090
14149
|
"name": "InvalidSwiftOrderId",
|
|
14091
14150
|
"msg": "Swift order id cannot be 0s"
|
|
14151
|
+
},
|
|
14152
|
+
{
|
|
14153
|
+
"code": 6302,
|
|
14154
|
+
"name": "InvalidPoolId",
|
|
14155
|
+
"msg": "Invalid pool id"
|
|
14092
14156
|
}
|
|
14093
14157
|
],
|
|
14094
14158
|
"metadata": {
|