@drift-labs/sdk 2.111.0-beta.2 → 2.111.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/constants/perpMarkets.js +11 -0
- package/lib/browser/driftClient.d.ts +17 -1
- package/lib/browser/driftClient.js +20 -1
- package/lib/node/constants/perpMarkets.js +11 -0
- package/lib/node/driftClient.d.ts +17 -1
- package/lib/node/driftClient.js +20 -1
- package/package.json +1 -1
- package/src/constants/perpMarkets.ts +12 -0
- package/src/driftClient.ts +33 -6
- package/tests/ci/verifyConstants.ts +4 -3
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.111.0-beta.
|
|
1
|
+
2.111.0-beta.4
|
|
@@ -1139,6 +1139,17 @@ exports.MainnetPerpMarkets = [
|
|
|
1139
1139
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
1140
1140
|
pythFeedId: '0x7302dee641a08507c297a7b0c8b3efa74a48a3baa6c040acab1e5209692b7e59',
|
|
1141
1141
|
},
|
|
1142
|
+
{
|
|
1143
|
+
fullName: 'Story Protocol',
|
|
1144
|
+
category: ['L1'],
|
|
1145
|
+
symbol: 'IP-PERP',
|
|
1146
|
+
baseAssetSymbol: 'IP',
|
|
1147
|
+
marketIndex: 70,
|
|
1148
|
+
oracle: new web3_js_1.PublicKey('E8A2iky96tzM8YuNNcJateE8S4e5N8FYspg17XHLp2aY'),
|
|
1149
|
+
launchTs: 1740150623000,
|
|
1150
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
1151
|
+
pythFeedId: '0xb620ba83044577029da7e4ded7a2abccf8e6afc2a0d4d26d89ccdd39ec109025',
|
|
1152
|
+
},
|
|
1142
1153
|
];
|
|
1143
1154
|
exports.PerpMarkets = {
|
|
1144
1155
|
devnet: exports.DevnetPerpMarkets,
|
|
@@ -146,6 +146,22 @@ export declare class DriftClient {
|
|
|
146
146
|
* Adds and subscribes to users based on params set by the constructor or by updateWallet.
|
|
147
147
|
*/
|
|
148
148
|
addAndSubscribeToUsers(authority?: PublicKey): Promise<boolean>;
|
|
149
|
+
/**
|
|
150
|
+
* Returns the instructions to initialize a user account and the public key of the user account.
|
|
151
|
+
* @param subAccountId
|
|
152
|
+
* @param name
|
|
153
|
+
* @param referrerInfo
|
|
154
|
+
* @returns [instructions, userAccountPublicKey]
|
|
155
|
+
*/
|
|
156
|
+
getInitializeUserAccountIxs(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[TransactionInstruction[], PublicKey]>;
|
|
157
|
+
/**
|
|
158
|
+
* Initializes a user account and returns the transaction signature and the public key of the user account.
|
|
159
|
+
* @param subAccountId
|
|
160
|
+
* @param name
|
|
161
|
+
* @param referrerInfo
|
|
162
|
+
* @param txParams
|
|
163
|
+
* @returns [transactionSignature, userAccountPublicKey]
|
|
164
|
+
*/
|
|
149
165
|
initializeUserAccount(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
150
166
|
getInitializeUserStatsIx(): Promise<TransactionInstruction>;
|
|
151
167
|
initializeSignedMsgUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
@@ -156,7 +172,7 @@ export declare class DriftClient {
|
|
|
156
172
|
getInitializeFuelOverflowIx(authority?: PublicKey): Promise<TransactionInstruction>;
|
|
157
173
|
sweepFuel(authority?: PublicKey): Promise<TransactionSignature>;
|
|
158
174
|
getSweepFuelIx(authority?: PublicKey): Promise<TransactionInstruction>;
|
|
159
|
-
getInitializeUserInstructions
|
|
175
|
+
private getInitializeUserInstructions;
|
|
160
176
|
getNextSubAccountId(): Promise<number>;
|
|
161
177
|
initializeReferrerName(name: string): Promise<TransactionSignature>;
|
|
162
178
|
updateUserName(name: string, subAccountId?: number): Promise<TransactionSignature>;
|
|
@@ -578,7 +578,14 @@ class DriftClient {
|
|
|
578
578
|
}
|
|
579
579
|
return result;
|
|
580
580
|
}
|
|
581
|
-
|
|
581
|
+
/**
|
|
582
|
+
* Returns the instructions to initialize a user account and the public key of the user account.
|
|
583
|
+
* @param subAccountId
|
|
584
|
+
* @param name
|
|
585
|
+
* @param referrerInfo
|
|
586
|
+
* @returns [instructions, userAccountPublicKey]
|
|
587
|
+
*/
|
|
588
|
+
async getInitializeUserAccountIxs(subAccountId = 0, name, referrerInfo) {
|
|
582
589
|
const initializeIxs = [];
|
|
583
590
|
const [userAccountPublicKey, initializeUserAccountIx] = await this.getInitializeUserInstructions(subAccountId, name, referrerInfo);
|
|
584
591
|
if (subAccountId === 0) {
|
|
@@ -587,6 +594,18 @@ class DriftClient {
|
|
|
587
594
|
}
|
|
588
595
|
}
|
|
589
596
|
initializeIxs.push(initializeUserAccountIx);
|
|
597
|
+
return [initializeIxs, userAccountPublicKey];
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Initializes a user account and returns the transaction signature and the public key of the user account.
|
|
601
|
+
* @param subAccountId
|
|
602
|
+
* @param name
|
|
603
|
+
* @param referrerInfo
|
|
604
|
+
* @param txParams
|
|
605
|
+
* @returns [transactionSignature, userAccountPublicKey]
|
|
606
|
+
*/
|
|
607
|
+
async initializeUserAccount(subAccountId = 0, name, referrerInfo, txParams) {
|
|
608
|
+
const [initializeIxs, userAccountPublicKey] = await this.getInitializeUserAccountIxs(subAccountId, name, referrerInfo);
|
|
590
609
|
const tx = await this.buildTransaction(initializeIxs, txParams);
|
|
591
610
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
592
611
|
await this.addUser(subAccountId);
|
|
@@ -1139,6 +1139,17 @@ exports.MainnetPerpMarkets = [
|
|
|
1139
1139
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
1140
1140
|
pythFeedId: '0x7302dee641a08507c297a7b0c8b3efa74a48a3baa6c040acab1e5209692b7e59',
|
|
1141
1141
|
},
|
|
1142
|
+
{
|
|
1143
|
+
fullName: 'Story Protocol',
|
|
1144
|
+
category: ['L1'],
|
|
1145
|
+
symbol: 'IP-PERP',
|
|
1146
|
+
baseAssetSymbol: 'IP',
|
|
1147
|
+
marketIndex: 70,
|
|
1148
|
+
oracle: new web3_js_1.PublicKey('E8A2iky96tzM8YuNNcJateE8S4e5N8FYspg17XHLp2aY'),
|
|
1149
|
+
launchTs: 1740150623000,
|
|
1150
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
1151
|
+
pythFeedId: '0xb620ba83044577029da7e4ded7a2abccf8e6afc2a0d4d26d89ccdd39ec109025',
|
|
1152
|
+
},
|
|
1142
1153
|
];
|
|
1143
1154
|
exports.PerpMarkets = {
|
|
1144
1155
|
devnet: exports.DevnetPerpMarkets,
|
|
@@ -146,6 +146,22 @@ export declare class DriftClient {
|
|
|
146
146
|
* Adds and subscribes to users based on params set by the constructor or by updateWallet.
|
|
147
147
|
*/
|
|
148
148
|
addAndSubscribeToUsers(authority?: PublicKey): Promise<boolean>;
|
|
149
|
+
/**
|
|
150
|
+
* Returns the instructions to initialize a user account and the public key of the user account.
|
|
151
|
+
* @param subAccountId
|
|
152
|
+
* @param name
|
|
153
|
+
* @param referrerInfo
|
|
154
|
+
* @returns [instructions, userAccountPublicKey]
|
|
155
|
+
*/
|
|
156
|
+
getInitializeUserAccountIxs(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[TransactionInstruction[], PublicKey]>;
|
|
157
|
+
/**
|
|
158
|
+
* Initializes a user account and returns the transaction signature and the public key of the user account.
|
|
159
|
+
* @param subAccountId
|
|
160
|
+
* @param name
|
|
161
|
+
* @param referrerInfo
|
|
162
|
+
* @param txParams
|
|
163
|
+
* @returns [transactionSignature, userAccountPublicKey]
|
|
164
|
+
*/
|
|
149
165
|
initializeUserAccount(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
150
166
|
getInitializeUserStatsIx(): Promise<TransactionInstruction>;
|
|
151
167
|
initializeSignedMsgUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
@@ -156,7 +172,7 @@ export declare class DriftClient {
|
|
|
156
172
|
getInitializeFuelOverflowIx(authority?: PublicKey): Promise<TransactionInstruction>;
|
|
157
173
|
sweepFuel(authority?: PublicKey): Promise<TransactionSignature>;
|
|
158
174
|
getSweepFuelIx(authority?: PublicKey): Promise<TransactionInstruction>;
|
|
159
|
-
getInitializeUserInstructions
|
|
175
|
+
private getInitializeUserInstructions;
|
|
160
176
|
getNextSubAccountId(): Promise<number>;
|
|
161
177
|
initializeReferrerName(name: string): Promise<TransactionSignature>;
|
|
162
178
|
updateUserName(name: string, subAccountId?: number): Promise<TransactionSignature>;
|
package/lib/node/driftClient.js
CHANGED
|
@@ -578,7 +578,14 @@ class DriftClient {
|
|
|
578
578
|
}
|
|
579
579
|
return result;
|
|
580
580
|
}
|
|
581
|
-
|
|
581
|
+
/**
|
|
582
|
+
* Returns the instructions to initialize a user account and the public key of the user account.
|
|
583
|
+
* @param subAccountId
|
|
584
|
+
* @param name
|
|
585
|
+
* @param referrerInfo
|
|
586
|
+
* @returns [instructions, userAccountPublicKey]
|
|
587
|
+
*/
|
|
588
|
+
async getInitializeUserAccountIxs(subAccountId = 0, name, referrerInfo) {
|
|
582
589
|
const initializeIxs = [];
|
|
583
590
|
const [userAccountPublicKey, initializeUserAccountIx] = await this.getInitializeUserInstructions(subAccountId, name, referrerInfo);
|
|
584
591
|
if (subAccountId === 0) {
|
|
@@ -587,6 +594,18 @@ class DriftClient {
|
|
|
587
594
|
}
|
|
588
595
|
}
|
|
589
596
|
initializeIxs.push(initializeUserAccountIx);
|
|
597
|
+
return [initializeIxs, userAccountPublicKey];
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Initializes a user account and returns the transaction signature and the public key of the user account.
|
|
601
|
+
* @param subAccountId
|
|
602
|
+
* @param name
|
|
603
|
+
* @param referrerInfo
|
|
604
|
+
* @param txParams
|
|
605
|
+
* @returns [transactionSignature, userAccountPublicKey]
|
|
606
|
+
*/
|
|
607
|
+
async initializeUserAccount(subAccountId = 0, name, referrerInfo, txParams) {
|
|
608
|
+
const [initializeIxs, userAccountPublicKey] = await this.getInitializeUserAccountIxs(subAccountId, name, referrerInfo);
|
|
590
609
|
const tx = await this.buildTransaction(initializeIxs, txParams);
|
|
591
610
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
592
611
|
await this.addUser(subAccountId);
|
package/package.json
CHANGED
|
@@ -1232,6 +1232,18 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
1232
1232
|
pythFeedId:
|
|
1233
1233
|
'0x7302dee641a08507c297a7b0c8b3efa74a48a3baa6c040acab1e5209692b7e59',
|
|
1234
1234
|
},
|
|
1235
|
+
{
|
|
1236
|
+
fullName: 'Story Protocol',
|
|
1237
|
+
category: ['L1'],
|
|
1238
|
+
symbol: 'IP-PERP',
|
|
1239
|
+
baseAssetSymbol: 'IP',
|
|
1240
|
+
marketIndex: 70,
|
|
1241
|
+
oracle: new PublicKey('E8A2iky96tzM8YuNNcJateE8S4e5N8FYspg17XHLp2aY'),
|
|
1242
|
+
launchTs: 1740150623000,
|
|
1243
|
+
oracleSource: OracleSource.PYTH_PULL,
|
|
1244
|
+
pythFeedId:
|
|
1245
|
+
'0xb620ba83044577029da7e4ded7a2abccf8e6afc2a0d4d26d89ccdd39ec109025',
|
|
1246
|
+
},
|
|
1235
1247
|
];
|
|
1236
1248
|
|
|
1237
1249
|
export const PerpMarkets: { [key in DriftEnv]: PerpMarketConfig[] } = {
|
package/src/driftClient.ts
CHANGED
|
@@ -996,13 +996,19 @@ export class DriftClient {
|
|
|
996
996
|
return result;
|
|
997
997
|
}
|
|
998
998
|
|
|
999
|
-
|
|
999
|
+
/**
|
|
1000
|
+
* Returns the instructions to initialize a user account and the public key of the user account.
|
|
1001
|
+
* @param subAccountId
|
|
1002
|
+
* @param name
|
|
1003
|
+
* @param referrerInfo
|
|
1004
|
+
* @returns [instructions, userAccountPublicKey]
|
|
1005
|
+
*/
|
|
1006
|
+
public async getInitializeUserAccountIxs(
|
|
1000
1007
|
subAccountId = 0,
|
|
1001
1008
|
name?: string,
|
|
1002
|
-
referrerInfo?: ReferrerInfo
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
const initializeIxs = [];
|
|
1009
|
+
referrerInfo?: ReferrerInfo
|
|
1010
|
+
): Promise<[TransactionInstruction[], PublicKey]> {
|
|
1011
|
+
const initializeIxs: TransactionInstruction[] = [];
|
|
1006
1012
|
|
|
1007
1013
|
const [userAccountPublicKey, initializeUserAccountIx] =
|
|
1008
1014
|
await this.getInitializeUserInstructions(
|
|
@@ -1020,6 +1026,27 @@ export class DriftClient {
|
|
|
1020
1026
|
}
|
|
1021
1027
|
|
|
1022
1028
|
initializeIxs.push(initializeUserAccountIx);
|
|
1029
|
+
|
|
1030
|
+
return [initializeIxs, userAccountPublicKey];
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Initializes a user account and returns the transaction signature and the public key of the user account.
|
|
1035
|
+
* @param subAccountId
|
|
1036
|
+
* @param name
|
|
1037
|
+
* @param referrerInfo
|
|
1038
|
+
* @param txParams
|
|
1039
|
+
* @returns [transactionSignature, userAccountPublicKey]
|
|
1040
|
+
*/
|
|
1041
|
+
public async initializeUserAccount(
|
|
1042
|
+
subAccountId = 0,
|
|
1043
|
+
name?: string,
|
|
1044
|
+
referrerInfo?: ReferrerInfo,
|
|
1045
|
+
txParams?: TxParams
|
|
1046
|
+
): Promise<[TransactionSignature, PublicKey]> {
|
|
1047
|
+
const [initializeIxs, userAccountPublicKey] =
|
|
1048
|
+
await this.getInitializeUserAccountIxs(subAccountId, name, referrerInfo);
|
|
1049
|
+
|
|
1023
1050
|
const tx = await this.buildTransaction(initializeIxs, txParams);
|
|
1024
1051
|
|
|
1025
1052
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
@@ -1172,7 +1199,7 @@ export class DriftClient {
|
|
|
1172
1199
|
});
|
|
1173
1200
|
}
|
|
1174
1201
|
|
|
1175
|
-
async getInitializeUserInstructions(
|
|
1202
|
+
private async getInitializeUserInstructions(
|
|
1176
1203
|
subAccountId = 0,
|
|
1177
1204
|
name?: string,
|
|
1178
1205
|
referrerInfo?: ReferrerInfo
|
|
@@ -68,9 +68,10 @@ describe('Verify Constants', function () {
|
|
|
68
68
|
await devnetDriftClient.subscribe();
|
|
69
69
|
await mainnetDriftClient.subscribe();
|
|
70
70
|
|
|
71
|
-
const lookupTables =
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
const lookupTables = await mainnetDriftClient.fetchAllLookupTableAccounts();
|
|
72
|
+
lutAccounts = lookupTables
|
|
73
|
+
.map((lut) => lut.state.addresses.map((x) => x.toBase58()))
|
|
74
|
+
.flat();
|
|
74
75
|
});
|
|
75
76
|
|
|
76
77
|
after(async () => {
|