@drift-labs/sdk 2.111.0-beta.1 → 2.111.0-beta.3
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 +2 -2
- package/lib/browser/constants/spotMarkets.js +4 -4
- package/lib/browser/driftClient.d.ts +17 -1
- package/lib/browser/driftClient.js +20 -1
- package/lib/node/constants/perpMarkets.js +2 -2
- package/lib/node/constants/spotMarkets.js +4 -4
- 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 +2 -2
- package/src/constants/spotMarkets.ts +4 -4
- 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.3
|
|
@@ -374,9 +374,9 @@ exports.MainnetPerpMarkets = [
|
|
|
374
374
|
symbol: 'ETH-PERP',
|
|
375
375
|
baseAssetSymbol: 'ETH',
|
|
376
376
|
marketIndex: 2,
|
|
377
|
-
oracle: new web3_js_1.PublicKey('
|
|
377
|
+
oracle: new web3_js_1.PublicKey('93FG52TzNKCnMiasV14Ba34BYcHDb9p4zK4GjZnLwqWR'),
|
|
378
378
|
launchTs: 1670347281000,
|
|
379
|
-
oracleSource: __1.OracleSource.
|
|
379
|
+
oracleSource: __1.OracleSource.PYTH_LAZER,
|
|
380
380
|
pythFeedId: '0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
|
|
381
381
|
pythLazerId: 2,
|
|
382
382
|
},
|
|
@@ -97,8 +97,8 @@ exports.MainnetSpotMarkets = [
|
|
|
97
97
|
symbol: 'USDC',
|
|
98
98
|
marketIndex: 0,
|
|
99
99
|
poolId: 0,
|
|
100
|
-
oracle: new web3_js_1.PublicKey('
|
|
101
|
-
oracleSource: __1.OracleSource.
|
|
100
|
+
oracle: new web3_js_1.PublicKey('9VCioxmni2gDLv11qufWzT3RDERhQE4iY5Gf7NTfYyAV'),
|
|
101
|
+
oracleSource: __1.OracleSource.PYTH_LAZER_STABLE_COIN,
|
|
102
102
|
mint: new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),
|
|
103
103
|
precision: numericConstants_1.QUOTE_PRECISION,
|
|
104
104
|
precisionExp: numericConstants_1.QUOTE_PRECISION_EXP,
|
|
@@ -136,8 +136,8 @@ exports.MainnetSpotMarkets = [
|
|
|
136
136
|
symbol: 'wBTC',
|
|
137
137
|
marketIndex: 3,
|
|
138
138
|
poolId: 0,
|
|
139
|
-
oracle: new web3_js_1.PublicKey('
|
|
140
|
-
oracleSource: __1.OracleSource.
|
|
139
|
+
oracle: new web3_js_1.PublicKey('fqPfDa6uQr9ndMvwaFp4mUBeUrHmLop8Jxfb1XJNmVm'),
|
|
140
|
+
oracleSource: __1.OracleSource.PYTH_LAZER,
|
|
141
141
|
mint: new web3_js_1.PublicKey('3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh'),
|
|
142
142
|
precision: new __1.BN(10).pow(numericConstants_1.EIGHT),
|
|
143
143
|
precisionExp: numericConstants_1.EIGHT,
|
|
@@ -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);
|
|
@@ -374,9 +374,9 @@ exports.MainnetPerpMarkets = [
|
|
|
374
374
|
symbol: 'ETH-PERP',
|
|
375
375
|
baseAssetSymbol: 'ETH',
|
|
376
376
|
marketIndex: 2,
|
|
377
|
-
oracle: new web3_js_1.PublicKey('
|
|
377
|
+
oracle: new web3_js_1.PublicKey('93FG52TzNKCnMiasV14Ba34BYcHDb9p4zK4GjZnLwqWR'),
|
|
378
378
|
launchTs: 1670347281000,
|
|
379
|
-
oracleSource: __1.OracleSource.
|
|
379
|
+
oracleSource: __1.OracleSource.PYTH_LAZER,
|
|
380
380
|
pythFeedId: '0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
|
|
381
381
|
pythLazerId: 2,
|
|
382
382
|
},
|
|
@@ -97,8 +97,8 @@ exports.MainnetSpotMarkets = [
|
|
|
97
97
|
symbol: 'USDC',
|
|
98
98
|
marketIndex: 0,
|
|
99
99
|
poolId: 0,
|
|
100
|
-
oracle: new web3_js_1.PublicKey('
|
|
101
|
-
oracleSource: __1.OracleSource.
|
|
100
|
+
oracle: new web3_js_1.PublicKey('9VCioxmni2gDLv11qufWzT3RDERhQE4iY5Gf7NTfYyAV'),
|
|
101
|
+
oracleSource: __1.OracleSource.PYTH_LAZER_STABLE_COIN,
|
|
102
102
|
mint: new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),
|
|
103
103
|
precision: numericConstants_1.QUOTE_PRECISION,
|
|
104
104
|
precisionExp: numericConstants_1.QUOTE_PRECISION_EXP,
|
|
@@ -136,8 +136,8 @@ exports.MainnetSpotMarkets = [
|
|
|
136
136
|
symbol: 'wBTC',
|
|
137
137
|
marketIndex: 3,
|
|
138
138
|
poolId: 0,
|
|
139
|
-
oracle: new web3_js_1.PublicKey('
|
|
140
|
-
oracleSource: __1.OracleSource.
|
|
139
|
+
oracle: new web3_js_1.PublicKey('fqPfDa6uQr9ndMvwaFp4mUBeUrHmLop8Jxfb1XJNmVm'),
|
|
140
|
+
oracleSource: __1.OracleSource.PYTH_LAZER,
|
|
141
141
|
mint: new web3_js_1.PublicKey('3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh'),
|
|
142
142
|
precision: new __1.BN(10).pow(numericConstants_1.EIGHT),
|
|
143
143
|
precisionExp: numericConstants_1.EIGHT,
|
|
@@ -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
|
@@ -415,9 +415,9 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
415
415
|
symbol: 'ETH-PERP',
|
|
416
416
|
baseAssetSymbol: 'ETH',
|
|
417
417
|
marketIndex: 2,
|
|
418
|
-
oracle: new PublicKey('
|
|
418
|
+
oracle: new PublicKey('93FG52TzNKCnMiasV14Ba34BYcHDb9p4zK4GjZnLwqWR'),
|
|
419
419
|
launchTs: 1670347281000,
|
|
420
|
-
oracleSource: OracleSource.
|
|
420
|
+
oracleSource: OracleSource.PYTH_LAZER,
|
|
421
421
|
pythFeedId:
|
|
422
422
|
'0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
|
|
423
423
|
pythLazerId: 2,
|
|
@@ -134,8 +134,8 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
|
|
|
134
134
|
symbol: 'USDC',
|
|
135
135
|
marketIndex: 0,
|
|
136
136
|
poolId: 0,
|
|
137
|
-
oracle: new PublicKey('
|
|
138
|
-
oracleSource: OracleSource.
|
|
137
|
+
oracle: new PublicKey('9VCioxmni2gDLv11qufWzT3RDERhQE4iY5Gf7NTfYyAV'),
|
|
138
|
+
oracleSource: OracleSource.PYTH_LAZER_STABLE_COIN,
|
|
139
139
|
mint: new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),
|
|
140
140
|
precision: QUOTE_PRECISION,
|
|
141
141
|
precisionExp: QUOTE_PRECISION_EXP,
|
|
@@ -180,8 +180,8 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
|
|
|
180
180
|
symbol: 'wBTC',
|
|
181
181
|
marketIndex: 3,
|
|
182
182
|
poolId: 0,
|
|
183
|
-
oracle: new PublicKey('
|
|
184
|
-
oracleSource: OracleSource.
|
|
183
|
+
oracle: new PublicKey('fqPfDa6uQr9ndMvwaFp4mUBeUrHmLop8Jxfb1XJNmVm'),
|
|
184
|
+
oracleSource: OracleSource.PYTH_LAZER,
|
|
185
185
|
mint: new PublicKey('3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh'),
|
|
186
186
|
precision: new BN(10).pow(EIGHT),
|
|
187
187
|
precisionExp: EIGHT,
|
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 () => {
|