@drift-labs/sdk 2.104.0-beta.22 → 2.104.0-beta.24
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/addresses/pda.d.ts +1 -0
- package/lib/browser/addresses/pda.js +7 -1
- package/lib/browser/adminClient.d.ts +4 -0
- package/lib/browser/adminClient.js +36 -0
- package/lib/browser/constants/perpMarkets.js +2 -2
- package/lib/browser/driftClient.js +8 -4
- package/lib/node/addresses/pda.d.ts +1 -0
- package/lib/node/addresses/pda.js +7 -1
- package/lib/node/adminClient.d.ts +4 -0
- package/lib/node/adminClient.js +36 -0
- package/lib/node/constants/perpMarkets.js +2 -2
- package/lib/node/driftClient.js +8 -4
- package/package.json +1 -1
- package/src/addresses/pda.ts +13 -0
- package/src/adminClient.ts +72 -0
- package/src/constants/perpMarkets.ts +2 -2
- package/src/driftClient.ts +10 -4
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.104.0-beta.
|
|
1
|
+
2.104.0-beta.24
|
|
@@ -30,3 +30,4 @@ export declare function getPythPullOraclePublicKey(progarmId: PublicKey, feedId:
|
|
|
30
30
|
export declare function getPythLazerOraclePublicKey(progarmId: PublicKey, feedId: number): PublicKey;
|
|
31
31
|
export declare function getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey;
|
|
32
32
|
export declare function getHighLeverageModeConfigPublicKey(programId: PublicKey): PublicKey;
|
|
33
|
+
export declare function getProtectedMakerModeConfigPublicKey(programId: PublicKey): PublicKey;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSwiftUserAccountPublicKey = exports.getRFQUserAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
|
|
26
|
+
exports.getProtectedMakerModeConfigPublicKey = exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSwiftUserAccountPublicKey = exports.getRFQUserAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
|
|
27
27
|
const web3_js_1 = require("@solana/web3.js");
|
|
28
28
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
29
29
|
const spl_token_1 = require("@solana/spl-token");
|
|
@@ -209,3 +209,9 @@ function getHighLeverageModeConfigPublicKey(programId) {
|
|
|
209
209
|
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(anchor.utils.bytes.utf8.encode('high_leverage_mode_config'))], programId)[0];
|
|
210
210
|
}
|
|
211
211
|
exports.getHighLeverageModeConfigPublicKey = getHighLeverageModeConfigPublicKey;
|
|
212
|
+
function getProtectedMakerModeConfigPublicKey(programId) {
|
|
213
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
214
|
+
Buffer.from(anchor.utils.bytes.utf8.encode('protected_maker_mode_config')),
|
|
215
|
+
], programId)[0];
|
|
216
|
+
}
|
|
217
|
+
exports.getProtectedMakerModeConfigPublicKey = getProtectedMakerModeConfigPublicKey;
|
|
@@ -203,4 +203,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
203
203
|
getInitializeHighLeverageModeConfigIx(maxUsers: number): Promise<TransactionInstruction>;
|
|
204
204
|
updateUpdateHighLeverageModeConfig(maxUsers: number, reduceOnly: boolean): Promise<TransactionSignature>;
|
|
205
205
|
getUpdateHighLeverageModeConfigIx(maxUsers: number, reduceOnly: boolean): Promise<TransactionInstruction>;
|
|
206
|
+
initializeProtectedMakerModeConfig(maxUsers: number): Promise<TransactionSignature>;
|
|
207
|
+
getInitializeProtectedMakerModeConfigIx(maxUsers: number): Promise<TransactionInstruction>;
|
|
208
|
+
updateProtectedMakerModeConfig(maxUsers: number, reduceOnly: boolean): Promise<TransactionSignature>;
|
|
209
|
+
getUpdateProtectedMakerModeConfigIx(maxUsers: number, reduceOnly: boolean): Promise<TransactionInstruction>;
|
|
206
210
|
}
|
|
@@ -1854,5 +1854,41 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1854
1854
|
},
|
|
1855
1855
|
});
|
|
1856
1856
|
}
|
|
1857
|
+
async initializeProtectedMakerModeConfig(maxUsers) {
|
|
1858
|
+
const initializeProtectedMakerModeConfigIx = await this.getInitializeProtectedMakerModeConfigIx(maxUsers);
|
|
1859
|
+
const tx = await this.buildTransaction(initializeProtectedMakerModeConfigIx);
|
|
1860
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1861
|
+
return txSig;
|
|
1862
|
+
}
|
|
1863
|
+
async getInitializeProtectedMakerModeConfigIx(maxUsers) {
|
|
1864
|
+
return await this.program.instruction.initializeProtectedMakerModeConfig(maxUsers, {
|
|
1865
|
+
accounts: {
|
|
1866
|
+
admin: this.isSubscribed
|
|
1867
|
+
? this.getStateAccount().admin
|
|
1868
|
+
: this.wallet.publicKey,
|
|
1869
|
+
state: await this.getStatePublicKey(),
|
|
1870
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1871
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1872
|
+
protectedMakerModeConfig: (0, pda_1.getProtectedMakerModeConfigPublicKey)(this.program.programId),
|
|
1873
|
+
},
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
async updateProtectedMakerModeConfig(maxUsers, reduceOnly) {
|
|
1877
|
+
const updateProtectedMakerModeConfigIx = await this.getUpdateProtectedMakerModeConfigIx(maxUsers, reduceOnly);
|
|
1878
|
+
const tx = await this.buildTransaction(updateProtectedMakerModeConfigIx);
|
|
1879
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1880
|
+
return txSig;
|
|
1881
|
+
}
|
|
1882
|
+
async getUpdateProtectedMakerModeConfigIx(maxUsers, reduceOnly) {
|
|
1883
|
+
return await this.program.instruction.updateProtectedMakerModeConfig(maxUsers, reduceOnly, {
|
|
1884
|
+
accounts: {
|
|
1885
|
+
admin: this.isSubscribed
|
|
1886
|
+
? this.getStateAccount().admin
|
|
1887
|
+
: this.wallet.publicKey,
|
|
1888
|
+
state: await this.getStatePublicKey(),
|
|
1889
|
+
protectedMakerModeConfig: (0, pda_1.getProtectedMakerModeConfigPublicKey)(this.program.programId),
|
|
1890
|
+
},
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1857
1893
|
}
|
|
1858
1894
|
exports.AdminClient = AdminClient;
|
|
@@ -380,8 +380,8 @@ exports.MainnetPerpMarkets = [
|
|
|
380
380
|
{
|
|
381
381
|
fullName: 'Polygon',
|
|
382
382
|
category: ['L2', 'Infra'],
|
|
383
|
-
symbol: '
|
|
384
|
-
baseAssetSymbol: '
|
|
383
|
+
symbol: 'POL-PERP',
|
|
384
|
+
baseAssetSymbol: 'POL',
|
|
385
385
|
marketIndex: 5,
|
|
386
386
|
oracle: new web3_js_1.PublicKey('BrzyDgwELy4jjjsqLQpBeUxzrsueYyMhuWpYBaUYcXvi'),
|
|
387
387
|
launchTs: 1677690149000,
|
|
@@ -429,13 +429,17 @@ class DriftClient {
|
|
|
429
429
|
userStatsAccountPublicKey: this.getUserStatsAccountPublicKey(),
|
|
430
430
|
accountSubscription: this.userStatsAccountSubscriptionConfig,
|
|
431
431
|
});
|
|
432
|
-
|
|
432
|
+
const subscriptionPromises = [this.userStats.subscribe()];
|
|
433
433
|
let success = true;
|
|
434
434
|
if (this.isSubscribed) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
435
|
+
const reSubscribeUsersPromise = async () => {
|
|
436
|
+
await Promise.all(this.unsubscribeUsers());
|
|
437
|
+
this.users.clear();
|
|
438
|
+
success = await this.addAndSubscribeToUsers();
|
|
439
|
+
};
|
|
440
|
+
subscriptionPromises.push(reSubscribeUsersPromise());
|
|
438
441
|
}
|
|
442
|
+
await Promise.all(subscriptionPromises);
|
|
439
443
|
return success;
|
|
440
444
|
}
|
|
441
445
|
/**
|
|
@@ -30,3 +30,4 @@ export declare function getPythPullOraclePublicKey(progarmId: PublicKey, feedId:
|
|
|
30
30
|
export declare function getPythLazerOraclePublicKey(progarmId: PublicKey, feedId: number): PublicKey;
|
|
31
31
|
export declare function getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey;
|
|
32
32
|
export declare function getHighLeverageModeConfigPublicKey(programId: PublicKey): PublicKey;
|
|
33
|
+
export declare function getProtectedMakerModeConfigPublicKey(programId: PublicKey): PublicKey;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSwiftUserAccountPublicKey = exports.getRFQUserAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
|
|
26
|
+
exports.getProtectedMakerModeConfigPublicKey = exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSwiftUserAccountPublicKey = exports.getRFQUserAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
|
|
27
27
|
const web3_js_1 = require("@solana/web3.js");
|
|
28
28
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
29
29
|
const spl_token_1 = require("@solana/spl-token");
|
|
@@ -209,3 +209,9 @@ function getHighLeverageModeConfigPublicKey(programId) {
|
|
|
209
209
|
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(anchor.utils.bytes.utf8.encode('high_leverage_mode_config'))], programId)[0];
|
|
210
210
|
}
|
|
211
211
|
exports.getHighLeverageModeConfigPublicKey = getHighLeverageModeConfigPublicKey;
|
|
212
|
+
function getProtectedMakerModeConfigPublicKey(programId) {
|
|
213
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
214
|
+
Buffer.from(anchor.utils.bytes.utf8.encode('protected_maker_mode_config')),
|
|
215
|
+
], programId)[0];
|
|
216
|
+
}
|
|
217
|
+
exports.getProtectedMakerModeConfigPublicKey = getProtectedMakerModeConfigPublicKey;
|
|
@@ -203,4 +203,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
203
203
|
getInitializeHighLeverageModeConfigIx(maxUsers: number): Promise<TransactionInstruction>;
|
|
204
204
|
updateUpdateHighLeverageModeConfig(maxUsers: number, reduceOnly: boolean): Promise<TransactionSignature>;
|
|
205
205
|
getUpdateHighLeverageModeConfigIx(maxUsers: number, reduceOnly: boolean): Promise<TransactionInstruction>;
|
|
206
|
+
initializeProtectedMakerModeConfig(maxUsers: number): Promise<TransactionSignature>;
|
|
207
|
+
getInitializeProtectedMakerModeConfigIx(maxUsers: number): Promise<TransactionInstruction>;
|
|
208
|
+
updateProtectedMakerModeConfig(maxUsers: number, reduceOnly: boolean): Promise<TransactionSignature>;
|
|
209
|
+
getUpdateProtectedMakerModeConfigIx(maxUsers: number, reduceOnly: boolean): Promise<TransactionInstruction>;
|
|
206
210
|
}
|
package/lib/node/adminClient.js
CHANGED
|
@@ -1854,5 +1854,41 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1854
1854
|
},
|
|
1855
1855
|
});
|
|
1856
1856
|
}
|
|
1857
|
+
async initializeProtectedMakerModeConfig(maxUsers) {
|
|
1858
|
+
const initializeProtectedMakerModeConfigIx = await this.getInitializeProtectedMakerModeConfigIx(maxUsers);
|
|
1859
|
+
const tx = await this.buildTransaction(initializeProtectedMakerModeConfigIx);
|
|
1860
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1861
|
+
return txSig;
|
|
1862
|
+
}
|
|
1863
|
+
async getInitializeProtectedMakerModeConfigIx(maxUsers) {
|
|
1864
|
+
return await this.program.instruction.initializeProtectedMakerModeConfig(maxUsers, {
|
|
1865
|
+
accounts: {
|
|
1866
|
+
admin: this.isSubscribed
|
|
1867
|
+
? this.getStateAccount().admin
|
|
1868
|
+
: this.wallet.publicKey,
|
|
1869
|
+
state: await this.getStatePublicKey(),
|
|
1870
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1871
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1872
|
+
protectedMakerModeConfig: (0, pda_1.getProtectedMakerModeConfigPublicKey)(this.program.programId),
|
|
1873
|
+
},
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
async updateProtectedMakerModeConfig(maxUsers, reduceOnly) {
|
|
1877
|
+
const updateProtectedMakerModeConfigIx = await this.getUpdateProtectedMakerModeConfigIx(maxUsers, reduceOnly);
|
|
1878
|
+
const tx = await this.buildTransaction(updateProtectedMakerModeConfigIx);
|
|
1879
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1880
|
+
return txSig;
|
|
1881
|
+
}
|
|
1882
|
+
async getUpdateProtectedMakerModeConfigIx(maxUsers, reduceOnly) {
|
|
1883
|
+
return await this.program.instruction.updateProtectedMakerModeConfig(maxUsers, reduceOnly, {
|
|
1884
|
+
accounts: {
|
|
1885
|
+
admin: this.isSubscribed
|
|
1886
|
+
? this.getStateAccount().admin
|
|
1887
|
+
: this.wallet.publicKey,
|
|
1888
|
+
state: await this.getStatePublicKey(),
|
|
1889
|
+
protectedMakerModeConfig: (0, pda_1.getProtectedMakerModeConfigPublicKey)(this.program.programId),
|
|
1890
|
+
},
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1857
1893
|
}
|
|
1858
1894
|
exports.AdminClient = AdminClient;
|
|
@@ -380,8 +380,8 @@ exports.MainnetPerpMarkets = [
|
|
|
380
380
|
{
|
|
381
381
|
fullName: 'Polygon',
|
|
382
382
|
category: ['L2', 'Infra'],
|
|
383
|
-
symbol: '
|
|
384
|
-
baseAssetSymbol: '
|
|
383
|
+
symbol: 'POL-PERP',
|
|
384
|
+
baseAssetSymbol: 'POL',
|
|
385
385
|
marketIndex: 5,
|
|
386
386
|
oracle: new web3_js_1.PublicKey('BrzyDgwELy4jjjsqLQpBeUxzrsueYyMhuWpYBaUYcXvi'),
|
|
387
387
|
launchTs: 1677690149000,
|
package/lib/node/driftClient.js
CHANGED
|
@@ -429,13 +429,17 @@ class DriftClient {
|
|
|
429
429
|
userStatsAccountPublicKey: this.getUserStatsAccountPublicKey(),
|
|
430
430
|
accountSubscription: this.userStatsAccountSubscriptionConfig,
|
|
431
431
|
});
|
|
432
|
-
|
|
432
|
+
const subscriptionPromises = [this.userStats.subscribe()];
|
|
433
433
|
let success = true;
|
|
434
434
|
if (this.isSubscribed) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
435
|
+
const reSubscribeUsersPromise = async () => {
|
|
436
|
+
await Promise.all(this.unsubscribeUsers());
|
|
437
|
+
this.users.clear();
|
|
438
|
+
success = await this.addAndSubscribeToUsers();
|
|
439
|
+
};
|
|
440
|
+
subscriptionPromises.push(reSubscribeUsersPromise());
|
|
438
441
|
}
|
|
442
|
+
await Promise.all(subscriptionPromises);
|
|
439
443
|
return success;
|
|
440
444
|
}
|
|
441
445
|
/**
|
package/package.json
CHANGED
package/src/addresses/pda.ts
CHANGED
|
@@ -353,3 +353,16 @@ export function getHighLeverageModeConfigPublicKey(
|
|
|
353
353
|
programId
|
|
354
354
|
)[0];
|
|
355
355
|
}
|
|
356
|
+
|
|
357
|
+
export function getProtectedMakerModeConfigPublicKey(
|
|
358
|
+
programId: PublicKey
|
|
359
|
+
): PublicKey {
|
|
360
|
+
return PublicKey.findProgramAddressSync(
|
|
361
|
+
[
|
|
362
|
+
Buffer.from(
|
|
363
|
+
anchor.utils.bytes.utf8.encode('protected_maker_mode_config')
|
|
364
|
+
),
|
|
365
|
+
],
|
|
366
|
+
programId
|
|
367
|
+
)[0];
|
|
368
|
+
}
|
package/src/adminClient.ts
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
getUserStatsAccountPublicKey,
|
|
35
35
|
getHighLeverageModeConfigPublicKey,
|
|
36
36
|
getPythLazerOraclePublicKey,
|
|
37
|
+
getProtectedMakerModeConfigPublicKey,
|
|
37
38
|
} from './addresses/pda';
|
|
38
39
|
import { squareRootBN } from './math/utils';
|
|
39
40
|
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
@@ -4027,4 +4028,75 @@ export class AdminClient extends DriftClient {
|
|
|
4027
4028
|
}
|
|
4028
4029
|
);
|
|
4029
4030
|
}
|
|
4031
|
+
|
|
4032
|
+
public async initializeProtectedMakerModeConfig(
|
|
4033
|
+
maxUsers: number
|
|
4034
|
+
): Promise<TransactionSignature> {
|
|
4035
|
+
const initializeProtectedMakerModeConfigIx =
|
|
4036
|
+
await this.getInitializeProtectedMakerModeConfigIx(maxUsers);
|
|
4037
|
+
|
|
4038
|
+
const tx = await this.buildTransaction(
|
|
4039
|
+
initializeProtectedMakerModeConfigIx
|
|
4040
|
+
);
|
|
4041
|
+
|
|
4042
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4043
|
+
|
|
4044
|
+
return txSig;
|
|
4045
|
+
}
|
|
4046
|
+
|
|
4047
|
+
public async getInitializeProtectedMakerModeConfigIx(
|
|
4048
|
+
maxUsers: number
|
|
4049
|
+
): Promise<TransactionInstruction> {
|
|
4050
|
+
return await this.program.instruction.initializeProtectedMakerModeConfig(
|
|
4051
|
+
maxUsers,
|
|
4052
|
+
{
|
|
4053
|
+
accounts: {
|
|
4054
|
+
admin: this.isSubscribed
|
|
4055
|
+
? this.getStateAccount().admin
|
|
4056
|
+
: this.wallet.publicKey,
|
|
4057
|
+
state: await this.getStatePublicKey(),
|
|
4058
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
4059
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
4060
|
+
protectedMakerModeConfig: getProtectedMakerModeConfigPublicKey(
|
|
4061
|
+
this.program.programId
|
|
4062
|
+
),
|
|
4063
|
+
},
|
|
4064
|
+
}
|
|
4065
|
+
);
|
|
4066
|
+
}
|
|
4067
|
+
|
|
4068
|
+
public async updateProtectedMakerModeConfig(
|
|
4069
|
+
maxUsers: number,
|
|
4070
|
+
reduceOnly: boolean
|
|
4071
|
+
): Promise<TransactionSignature> {
|
|
4072
|
+
const updateProtectedMakerModeConfigIx =
|
|
4073
|
+
await this.getUpdateProtectedMakerModeConfigIx(maxUsers, reduceOnly);
|
|
4074
|
+
|
|
4075
|
+
const tx = await this.buildTransaction(updateProtectedMakerModeConfigIx);
|
|
4076
|
+
|
|
4077
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4078
|
+
|
|
4079
|
+
return txSig;
|
|
4080
|
+
}
|
|
4081
|
+
|
|
4082
|
+
public async getUpdateProtectedMakerModeConfigIx(
|
|
4083
|
+
maxUsers: number,
|
|
4084
|
+
reduceOnly: boolean
|
|
4085
|
+
): Promise<TransactionInstruction> {
|
|
4086
|
+
return await this.program.instruction.updateProtectedMakerModeConfig(
|
|
4087
|
+
maxUsers,
|
|
4088
|
+
reduceOnly,
|
|
4089
|
+
{
|
|
4090
|
+
accounts: {
|
|
4091
|
+
admin: this.isSubscribed
|
|
4092
|
+
? this.getStateAccount().admin
|
|
4093
|
+
: this.wallet.publicKey,
|
|
4094
|
+
state: await this.getStatePublicKey(),
|
|
4095
|
+
protectedMakerModeConfig: getProtectedMakerModeConfigPublicKey(
|
|
4096
|
+
this.program.programId
|
|
4097
|
+
),
|
|
4098
|
+
},
|
|
4099
|
+
}
|
|
4100
|
+
);
|
|
4101
|
+
}
|
|
4030
4102
|
}
|
|
@@ -423,8 +423,8 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
423
423
|
{
|
|
424
424
|
fullName: 'Polygon',
|
|
425
425
|
category: ['L2', 'Infra'],
|
|
426
|
-
symbol: '
|
|
427
|
-
baseAssetSymbol: '
|
|
426
|
+
symbol: 'POL-PERP',
|
|
427
|
+
baseAssetSymbol: 'POL',
|
|
428
428
|
marketIndex: 5,
|
|
429
429
|
oracle: new PublicKey('BrzyDgwELy4jjjsqLQpBeUxzrsueYyMhuWpYBaUYcXvi'),
|
|
430
430
|
launchTs: 1677690149000, //todo
|
package/src/driftClient.ts
CHANGED
|
@@ -776,16 +776,22 @@ export class DriftClient {
|
|
|
776
776
|
accountSubscription: this.userStatsAccountSubscriptionConfig,
|
|
777
777
|
});
|
|
778
778
|
|
|
779
|
-
|
|
779
|
+
const subscriptionPromises: Promise<any>[] = [this.userStats.subscribe()];
|
|
780
780
|
|
|
781
781
|
let success = true;
|
|
782
782
|
|
|
783
783
|
if (this.isSubscribed) {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
784
|
+
const reSubscribeUsersPromise = async () => {
|
|
785
|
+
await Promise.all(this.unsubscribeUsers());
|
|
786
|
+
this.users.clear();
|
|
787
|
+
success = await this.addAndSubscribeToUsers();
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
subscriptionPromises.push(reSubscribeUsersPromise());
|
|
787
791
|
}
|
|
788
792
|
|
|
793
|
+
await Promise.all(subscriptionPromises);
|
|
794
|
+
|
|
789
795
|
return success;
|
|
790
796
|
}
|
|
791
797
|
|