@drift-labs/sdk 2.104.0-beta.3 → 2.104.0-beta.30
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/bun.lockb +0 -0
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.js +1 -0
- package/lib/browser/addresses/pda.d.ts +2 -0
- package/lib/browser/addresses/pda.js +18 -1
- package/lib/browser/adminClient.d.ts +6 -0
- package/lib/browser/adminClient.js +55 -2
- package/lib/browser/bankrun/bankrunConnection.d.ts +2 -1
- package/lib/browser/bankrun/bankrunConnection.js +14 -0
- package/lib/browser/config.d.ts +2 -2
- package/lib/browser/config.js +4 -3
- package/lib/browser/constants/perpMarkets.js +26 -4
- package/lib/browser/constants/spotMarkets.js +33 -1
- package/lib/browser/dlob/DLOB.d.ts +15 -13
- package/lib/browser/dlob/DLOB.js +46 -147
- package/lib/browser/dlob/DLOBNode.d.ts +11 -2
- package/lib/browser/dlob/DLOBNode.js +15 -2
- package/lib/browser/dlob/NodeList.d.ts +1 -3
- package/lib/browser/dlob/NodeList.js +1 -17
- package/lib/browser/driftClient.d.ts +13 -11
- package/lib/browser/driftClient.js +126 -88
- package/lib/browser/driftClientConfig.d.ts +0 -1
- package/lib/browser/factory/oracleClient.js +4 -0
- package/lib/browser/idl/drift.json +156 -34
- package/lib/browser/index.d.ts +2 -3
- package/lib/browser/index.js +2 -3
- package/lib/browser/isomorphic/grpc.d.ts +1 -1
- package/lib/browser/memcmp.d.ts +1 -0
- package/lib/browser/memcmp.js +10 -1
- package/lib/browser/oracles/oracleId.js +2 -0
- package/lib/browser/oracles/pythLazerClient.d.ts +16 -0
- package/lib/browser/oracles/pythLazerClient.js +61 -0
- package/lib/browser/tx/baseTxSender.d.ts +3 -1
- package/lib/browser/tx/baseTxSender.js +2 -1
- package/lib/browser/tx/whileValidTxSender.d.ts +2 -1
- package/lib/browser/tx/whileValidTxSender.js +3 -2
- package/lib/browser/types.d.ts +6 -5
- package/lib/browser/types.js +2 -0
- package/lib/browser/userMap/WebsocketSubscription.d.ts +4 -2
- package/lib/browser/userMap/WebsocketSubscription.js +5 -1
- package/lib/browser/userMap/grpcSubscription.d.ts +4 -1
- package/lib/browser/userMap/grpcSubscription.js +5 -1
- package/lib/browser/userMap/userMap.d.ts +1 -0
- package/lib/browser/userMap/userMap.js +4 -0
- package/lib/browser/userMap/userMapConfig.d.ts +2 -1
- package/lib/browser/util/computeUnits.js +2 -0
- package/lib/browser/util/digest.d.ts +1 -0
- package/lib/browser/util/digest.js +6 -1
- package/lib/browser/util/pythOracleUtils.d.ts +17 -0
- package/lib/browser/util/pythOracleUtils.js +107 -0
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.js +1 -0
- package/lib/node/addresses/pda.d.ts +2 -0
- package/lib/node/addresses/pda.js +18 -1
- package/lib/node/adminClient.d.ts +6 -0
- package/lib/node/adminClient.js +55 -2
- package/lib/node/bankrun/bankrunConnection.d.ts +2 -1
- package/lib/node/bankrun/bankrunConnection.js +14 -0
- package/lib/node/config.d.ts +2 -2
- package/lib/node/config.js +4 -3
- package/lib/node/constants/perpMarkets.js +26 -4
- package/lib/node/constants/spotMarkets.js +33 -1
- package/lib/node/dlob/DLOB.d.ts +15 -13
- package/lib/node/dlob/DLOB.js +46 -147
- package/lib/node/dlob/DLOBNode.d.ts +11 -2
- package/lib/node/dlob/DLOBNode.js +15 -2
- package/lib/node/dlob/NodeList.d.ts +1 -3
- package/lib/node/dlob/NodeList.js +1 -17
- package/lib/node/driftClient.d.ts +13 -11
- package/lib/node/driftClient.js +126 -88
- package/lib/node/driftClientConfig.d.ts +0 -1
- package/lib/node/factory/oracleClient.js +4 -0
- package/lib/node/idl/drift.json +156 -34
- package/lib/node/index.d.ts +2 -3
- package/lib/node/index.js +2 -3
- package/lib/node/isomorphic/grpc.d.ts +5 -1
- package/lib/node/memcmp.d.ts +1 -0
- package/lib/node/memcmp.js +10 -1
- package/lib/node/oracles/oracleId.js +2 -0
- package/lib/node/oracles/pythLazerClient.d.ts +16 -0
- package/lib/node/oracles/pythLazerClient.js +61 -0
- package/lib/node/tx/baseTxSender.d.ts +3 -1
- package/lib/node/tx/baseTxSender.js +2 -1
- package/lib/node/tx/whileValidTxSender.d.ts +2 -1
- package/lib/node/tx/whileValidTxSender.js +3 -2
- package/lib/node/types.d.ts +6 -5
- package/lib/node/types.js +2 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts +4 -2
- package/lib/node/userMap/WebsocketSubscription.js +5 -1
- package/lib/node/userMap/grpcSubscription.d.ts +4 -1
- package/lib/node/userMap/grpcSubscription.js +5 -1
- package/lib/node/userMap/userMap.d.ts +1 -0
- package/lib/node/userMap/userMap.js +4 -0
- package/lib/node/userMap/userMapConfig.d.ts +2 -1
- package/lib/node/util/computeUnits.js +2 -0
- package/lib/node/util/digest.d.ts +1 -0
- package/lib/node/util/digest.js +6 -1
- package/lib/node/util/pythOracleUtils.d.ts +17 -0
- package/lib/node/util/pythOracleUtils.js +107 -0
- package/package.json +29 -26
- package/scripts/postbuild.js +63 -29
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +1 -0
- package/src/addresses/pda.ts +31 -0
- package/src/adminClient.ts +104 -1
- package/src/bankrun/bankrunConnection.ts +21 -0
- package/src/config.ts +5 -3
- package/src/constants/perpMarkets.ts +28 -4
- package/src/constants/spotMarkets.ts +35 -1
- package/src/dlob/DLOB.ts +73 -228
- package/src/dlob/DLOBNode.ts +24 -1
- package/src/dlob/NodeList.ts +1 -19
- package/src/driftClient.ts +164 -79
- package/src/driftClientConfig.ts +0 -1
- package/src/factory/oracleClient.ts +5 -0
- package/src/idl/drift.json +156 -34
- package/src/index.ts +2 -3
- package/src/memcmp.ts +9 -0
- package/src/oracles/oracleId.ts +1 -0
- package/src/oracles/pythLazerClient.ts +102 -0
- package/src/tx/baseTxSender.ts +4 -0
- package/src/tx/whileValidTxSender.ts +4 -1
- package/src/types.ts +4 -6
- package/src/userMap/WebsocketSubscription.ts +8 -1
- package/src/userMap/grpcSubscription.ts +8 -1
- package/src/userMap/userMap.ts +6 -1
- package/src/userMap/userMapConfig.ts +3 -1
- package/src/util/computeUnits.ts +2 -0
- package/src/util/digest.ts +5 -0
- package/src/util/pythOracleUtils.ts +136 -0
- package/tests/dlob/test.ts +13 -184
- package/lib/browser/dlob/DLOBApiClient.d.ts +0 -14
- package/lib/browser/dlob/DLOBApiClient.js +0 -34
- package/lib/browser/dlob/DLOBOrders.d.ts +0 -17
- package/lib/browser/dlob/DLOBOrders.js +0 -40
- package/lib/browser/dlob/dlobIdl.json +0 -248
- package/lib/browser/isomorphic/grpc.node.d.ts +0 -5
- package/lib/browser/util/pythPullOracleUtils.d.ts +0 -2
- package/lib/browser/util/pythPullOracleUtils.js +0 -15
- package/lib/node/dlob/DLOBApiClient.d.ts +0 -14
- package/lib/node/dlob/DLOBApiClient.js +0 -34
- package/lib/node/dlob/DLOBOrders.d.ts +0 -17
- package/lib/node/dlob/DLOBOrders.js +0 -40
- package/lib/node/dlob/dlobIdl.json +0 -248
- package/lib/node/isomorphic/grpc.browser.d.ts +0 -1
- package/lib/node/util/pythPullOracleUtils.d.ts +0 -2
- package/lib/node/util/pythPullOracleUtils.js +0 -15
- package/src/dlob/DLOBApiClient.ts +0 -39
- package/src/dlob/DLOBOrders.ts +0 -49
- package/src/dlob/dlobIdl.json +0 -248
- package/src/util/pythPullOracleUtils.ts +0 -11
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.104.0-beta.
|
|
1
|
+
2.104.0-beta.30
|
package/bun.lockb
CHANGED
|
Binary file
|
|
@@ -244,6 +244,7 @@ class PollingDriftClientAccountSubscriber {
|
|
|
244
244
|
this.accountsToPoll.clear();
|
|
245
245
|
this.oraclesToPoll.clear();
|
|
246
246
|
this.isSubscribed = false;
|
|
247
|
+
this.accountLoader.accountsToLoad = new Map();
|
|
247
248
|
}
|
|
248
249
|
async addSpotMarket(marketIndex) {
|
|
249
250
|
const marketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex);
|
|
@@ -27,5 +27,7 @@ export declare function getReferrerNamePublicKeySync(programId: PublicKey, nameB
|
|
|
27
27
|
export declare function getProtocolIfSharesTransferConfigPublicKey(programId: PublicKey): PublicKey;
|
|
28
28
|
export declare function getPrelaunchOraclePublicKey(programId: PublicKey, marketIndex: number): PublicKey;
|
|
29
29
|
export declare function getPythPullOraclePublicKey(progarmId: PublicKey, feedId: Uint8Array): PublicKey;
|
|
30
|
+
export declare function getPythLazerOraclePublicKey(progarmId: PublicKey, feedId: number): PublicKey;
|
|
30
31
|
export declare function getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey;
|
|
31
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.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");
|
|
@@ -187,6 +187,17 @@ function getPythPullOraclePublicKey(progarmId, feedId) {
|
|
|
187
187
|
], progarmId)[0];
|
|
188
188
|
}
|
|
189
189
|
exports.getPythPullOraclePublicKey = getPythPullOraclePublicKey;
|
|
190
|
+
function getPythLazerOraclePublicKey(progarmId, feedId) {
|
|
191
|
+
const buffer = new ArrayBuffer(4);
|
|
192
|
+
const view = new DataView(buffer);
|
|
193
|
+
view.setUint32(0, feedId, true);
|
|
194
|
+
const feedIdBytes = new Uint8Array(buffer);
|
|
195
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
196
|
+
Buffer.from(anchor.utils.bytes.utf8.encode('pyth_lazer')),
|
|
197
|
+
Buffer.from(feedIdBytes),
|
|
198
|
+
], progarmId)[0];
|
|
199
|
+
}
|
|
200
|
+
exports.getPythLazerOraclePublicKey = getPythLazerOraclePublicKey;
|
|
190
201
|
function getTokenProgramForSpotMarket(spotMarketAccount) {
|
|
191
202
|
if (spotMarketAccount.tokenProgram === 1) {
|
|
192
203
|
return spl_token_1.TOKEN_2022_PROGRAM_ID;
|
|
@@ -198,3 +209,9 @@ function getHighLeverageModeConfigPublicKey(programId) {
|
|
|
198
209
|
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(anchor.utils.bytes.utf8.encode('high_leverage_mode_config'))], programId)[0];
|
|
199
210
|
}
|
|
200
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;
|
|
@@ -197,8 +197,14 @@ export declare class AdminClient extends DriftClient {
|
|
|
197
197
|
getInitUserFuelIx(user: PublicKey, authority: PublicKey, fuelBonusDeposits?: number, fuelBonusBorrows?: number, fuelBonusTaker?: number, fuelBonusMaker?: number, fuelBonusInsurance?: number): Promise<TransactionInstruction>;
|
|
198
198
|
initializePythPullOracle(feedId: string, isAdmin?: boolean): Promise<TransactionSignature>;
|
|
199
199
|
getInitializePythPullOracleIx(feedId: string, isAdmin?: boolean): Promise<TransactionInstruction>;
|
|
200
|
+
initializePythLazerOracle(feedId: number, isAdmin?: boolean): Promise<TransactionSignature>;
|
|
201
|
+
getInitializePythLazerOracleIx(feedId: number, isAdmin?: boolean): Promise<TransactionInstruction>;
|
|
200
202
|
initializeHighLeverageModeConfig(maxUsers: number): Promise<TransactionSignature>;
|
|
201
203
|
getInitializeHighLeverageModeConfigIx(maxUsers: number): Promise<TransactionInstruction>;
|
|
202
204
|
updateUpdateHighLeverageModeConfig(maxUsers: number, reduceOnly: boolean): Promise<TransactionSignature>;
|
|
203
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>;
|
|
204
210
|
}
|
|
@@ -38,7 +38,7 @@ const trade_1 = require("./math/trade");
|
|
|
38
38
|
const amm_1 = require("./math/amm");
|
|
39
39
|
const phoenix_sdk_1 = require("@ellipsis-labs/phoenix-sdk");
|
|
40
40
|
const config_1 = require("./config");
|
|
41
|
-
const
|
|
41
|
+
const pythOracleUtils_1 = require("./util/pythOracleUtils");
|
|
42
42
|
const OPENBOOK_PROGRAM_ID = new web3_js_1.PublicKey('opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb');
|
|
43
43
|
class AdminClient extends driftClient_1.DriftClient {
|
|
44
44
|
async initialize(usdcMint, _adminControlsPrices) {
|
|
@@ -1790,7 +1790,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1790
1790
|
return txSig;
|
|
1791
1791
|
}
|
|
1792
1792
|
async getInitializePythPullOracleIx(feedId, isAdmin = false) {
|
|
1793
|
-
const feedIdBuffer = (0,
|
|
1793
|
+
const feedIdBuffer = (0, pythOracleUtils_1.getFeedIdUint8Array)(feedId);
|
|
1794
1794
|
return await this.program.instruction.initializePythPullOracle(feedIdBuffer, {
|
|
1795
1795
|
accounts: {
|
|
1796
1796
|
admin: isAdmin ? this.getStateAccount().admin : this.wallet.publicKey,
|
|
@@ -1801,6 +1801,23 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1801
1801
|
},
|
|
1802
1802
|
});
|
|
1803
1803
|
}
|
|
1804
|
+
async initializePythLazerOracle(feedId, isAdmin = false) {
|
|
1805
|
+
const initializePythPullOracleIx = await this.getInitializePythLazerOracleIx(feedId, isAdmin);
|
|
1806
|
+
const tx = await this.buildTransaction(initializePythPullOracleIx);
|
|
1807
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1808
|
+
return txSig;
|
|
1809
|
+
}
|
|
1810
|
+
async getInitializePythLazerOracleIx(feedId, isAdmin = false) {
|
|
1811
|
+
return await this.program.instruction.initializePythLazerOracle(feedId, {
|
|
1812
|
+
accounts: {
|
|
1813
|
+
admin: isAdmin ? this.getStateAccount().admin : this.wallet.publicKey,
|
|
1814
|
+
state: await this.getStatePublicKey(),
|
|
1815
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
1816
|
+
lazerOracle: (0, pda_1.getPythLazerOraclePublicKey)(this.program.programId, feedId),
|
|
1817
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1818
|
+
},
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1804
1821
|
async initializeHighLeverageModeConfig(maxUsers) {
|
|
1805
1822
|
const initializeHighLeverageModeConfigIx = await this.getInitializeHighLeverageModeConfigIx(maxUsers);
|
|
1806
1823
|
const tx = await this.buildTransaction(initializeHighLeverageModeConfigIx);
|
|
@@ -1837,5 +1854,41 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1837
1854
|
},
|
|
1838
1855
|
});
|
|
1839
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
|
+
}
|
|
1840
1893
|
}
|
|
1841
1894
|
exports.AdminClient = AdminClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="bn.js" />
|
|
4
|
-
import { AccountInfo, Keypair, PublicKey, Transaction, RpcResponseAndContext, Commitment, TransactionSignature, SignatureStatusConfig, SignatureStatus, GetVersionedTransactionConfig, GetTransactionConfig, VersionedTransaction, SimulateTransactionConfig, SimulatedTransactionResponse, TransactionError, SignatureResultCallback, ClientSubscriptionId, Connection as SolanaConnection, Blockhash, LogsFilter, LogsCallback, AccountChangeCallback } from '@solana/web3.js';
|
|
4
|
+
import { AccountInfo, Keypair, PublicKey, Transaction, RpcResponseAndContext, Commitment, TransactionSignature, SignatureStatusConfig, SignatureStatus, GetVersionedTransactionConfig, GetTransactionConfig, VersionedTransaction, SimulateTransactionConfig, SimulatedTransactionResponse, TransactionError, SignatureResultCallback, ClientSubscriptionId, Connection as SolanaConnection, Blockhash, LogsFilter, LogsCallback, AccountChangeCallback, AddressLookupTableAccount } from '@solana/web3.js';
|
|
5
5
|
import { ProgramTestContext, BanksClient } from 'solana-bankrun';
|
|
6
6
|
import { BankrunProvider } from 'anchor-bankrun';
|
|
7
7
|
import { BN, Wallet } from '@coral-xyz/anchor';
|
|
@@ -54,6 +54,7 @@ export declare class BankrunConnection {
|
|
|
54
54
|
blockhash: string;
|
|
55
55
|
lastValidBlockHeight: number;
|
|
56
56
|
}>>;
|
|
57
|
+
getAddressLookupTable(accountKey: PublicKey): Promise<RpcResponseAndContext<null | AddressLookupTableAccount>>;
|
|
57
58
|
getSignatureStatus(signature: string, _config?: SignatureStatusConfig): Promise<RpcResponseAndContext<null | SignatureStatus>>;
|
|
58
59
|
/**
|
|
59
60
|
* There's really no direct equivalent to getTransaction exposed by SolanaProgramTest, so we do the best that we can here - it's a little hacky.
|
|
@@ -204,6 +204,20 @@ class BankrunConnection {
|
|
|
204
204
|
lastValidBlockHeight: Number(blockhashAndBlockheight[1]),
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
|
+
async getAddressLookupTable(accountKey) {
|
|
208
|
+
const { context, value: accountInfo } = await this.getParsedAccountInfo(accountKey);
|
|
209
|
+
let value = null;
|
|
210
|
+
if (accountInfo !== null) {
|
|
211
|
+
value = new web3_js_1.AddressLookupTableAccount({
|
|
212
|
+
key: accountKey,
|
|
213
|
+
state: web3_js_1.AddressLookupTableAccount.deserialize(accountInfo.data),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
context,
|
|
218
|
+
value,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
207
221
|
async getSignatureStatus(signature, _config) {
|
|
208
222
|
const transactionStatus = await this._banksClient.getTransactionStatus(signature);
|
|
209
223
|
if (transactionStatus === null) {
|
package/lib/browser/config.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ type DriftConfig = {
|
|
|
25
25
|
export type DriftEnv = 'devnet' | 'mainnet-beta';
|
|
26
26
|
export declare const DRIFT_PROGRAM_ID = "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH";
|
|
27
27
|
export declare const DRIFT_ORACLE_RECEIVER_ID = "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha";
|
|
28
|
-
export declare const
|
|
29
|
-
export declare const
|
|
28
|
+
export declare const PTYH_LAZER_PROGRAM_ID = "pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt";
|
|
29
|
+
export declare const PYTH_LAZER_STORAGE_ACCOUNT_KEY: PublicKey;
|
|
30
30
|
export declare const DEFAULT_CONFIRMATION_OPTS: ConfirmOptions;
|
|
31
31
|
export declare const configs: {
|
|
32
32
|
[key in DriftEnv]: DriftConfig;
|
package/lib/browser/config.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findAllMarketAndOracles = exports.getMarketsAndOraclesForSubscription = exports.initialize = exports.getConfig = exports.configs = exports.DEFAULT_CONFIRMATION_OPTS = exports.
|
|
3
|
+
exports.findAllMarketAndOracles = exports.getMarketsAndOraclesForSubscription = exports.initialize = exports.getConfig = exports.configs = exports.DEFAULT_CONFIRMATION_OPTS = exports.PYTH_LAZER_STORAGE_ACCOUNT_KEY = exports.PTYH_LAZER_PROGRAM_ID = exports.DRIFT_ORACLE_RECEIVER_ID = exports.DRIFT_PROGRAM_ID = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
4
5
|
const perpMarkets_1 = require("./constants/perpMarkets");
|
|
5
6
|
const spotMarkets_1 = require("./constants/spotMarkets");
|
|
6
7
|
const on_demand_1 = require("@switchboard-xyz/on-demand");
|
|
7
8
|
const oracleId_1 = require("./oracles/oracleId");
|
|
8
9
|
exports.DRIFT_PROGRAM_ID = 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH';
|
|
9
10
|
exports.DRIFT_ORACLE_RECEIVER_ID = 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha';
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
11
|
+
exports.PTYH_LAZER_PROGRAM_ID = 'pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt';
|
|
12
|
+
exports.PYTH_LAZER_STORAGE_ACCOUNT_KEY = new _1.PublicKey('3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL');
|
|
12
13
|
exports.DEFAULT_CONFIRMATION_OPTS = {
|
|
13
14
|
preflightCommitment: 'confirmed',
|
|
14
15
|
commitment: 'confirmed',
|
|
@@ -62,8 +62,8 @@ exports.DevnetPerpMarkets = [
|
|
|
62
62
|
{
|
|
63
63
|
fullName: 'Polygon',
|
|
64
64
|
category: ['L2', 'Infra'],
|
|
65
|
-
symbol: '
|
|
66
|
-
baseAssetSymbol: '
|
|
65
|
+
symbol: 'POL-PERP',
|
|
66
|
+
baseAssetSymbol: 'POL',
|
|
67
67
|
marketIndex: 5,
|
|
68
68
|
oracle: new web3_js_1.PublicKey('BrzyDgwELy4jjjsqLQpBeUxzrsueYyMhuWpYBaUYcXvi'),
|
|
69
69
|
launchTs: 1677690149000,
|
|
@@ -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,
|
|
@@ -979,6 +979,28 @@ exports.MainnetPerpMarkets = [
|
|
|
979
979
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
980
980
|
pythFeedId: '0x6e3f3fa8253588df9326580180233eb791e03b443a3ba7a1d892e73874e19a54',
|
|
981
981
|
},
|
|
982
|
+
{
|
|
983
|
+
fullName: 'Magic Eden',
|
|
984
|
+
category: ['DEX'],
|
|
985
|
+
symbol: 'ME-PERP',
|
|
986
|
+
baseAssetSymbol: 'ME',
|
|
987
|
+
marketIndex: 61,
|
|
988
|
+
oracle: new web3_js_1.PublicKey('FLQjrmEPGwbCKRYZ1eYM5FPccHBrCv2cN4GBu3mWfmPH'),
|
|
989
|
+
launchTs: 1733839936000,
|
|
990
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
991
|
+
pythFeedId: '0x91519e3e48571e1232a85a938e714da19fe5ce05107f3eebb8a870b2e8020169',
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
fullName: 'PENGU',
|
|
995
|
+
category: ['Meme'],
|
|
996
|
+
symbol: 'PENGU-PERP',
|
|
997
|
+
baseAssetSymbol: 'PENGU',
|
|
998
|
+
marketIndex: 62,
|
|
999
|
+
oracle: new web3_js_1.PublicKey('7vGHChuBJyFMYBqMLXRzBmRxWdSuwEmg8RvRm3RWQsxi'),
|
|
1000
|
+
launchTs: 1734444000000,
|
|
1001
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
1002
|
+
pythFeedId: '0xbed3097008b9b5e3c93bec20be79cb43986b85a996475589351a21e67bae9b61',
|
|
1003
|
+
},
|
|
982
1004
|
];
|
|
983
1005
|
exports.PerpMarkets = {
|
|
984
1006
|
devnet: exports.DevnetPerpMarkets,
|
|
@@ -80,7 +80,7 @@ exports.DevnetSpotMarkets = [
|
|
|
80
80
|
marketIndex: 6,
|
|
81
81
|
poolId: 1,
|
|
82
82
|
oracle: new web3_js_1.PublicKey('En8hkHLkRe9d9DraYmBTrus518BvmVH448YcvmrFM6Ce'),
|
|
83
|
-
oracleSource: __1.OracleSource.
|
|
83
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
84
84
|
mint: new web3_js_1.PublicKey('8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2'),
|
|
85
85
|
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
86
86
|
precisionExp: numericConstants_1.SIX,
|
|
@@ -442,6 +442,38 @@ exports.MainnetSpotMarkets = [
|
|
|
442
442
|
precisionExp: numericConstants_1.SIX,
|
|
443
443
|
pythFeedId: '0x77f0971af11cc8bac224917275c1bf55f2319ed5c654a1ca955c82fa2d297ea1',
|
|
444
444
|
},
|
|
445
|
+
{
|
|
446
|
+
symbol: 'META',
|
|
447
|
+
marketIndex: 29,
|
|
448
|
+
poolId: 0,
|
|
449
|
+
oracle: new web3_js_1.PublicKey('DwYF1yveo8XTF1oqfsqykj332rjSxAd7bR6Gu6i4iUET'),
|
|
450
|
+
oracleSource: __1.OracleSource.SWITCHBOARD_ON_DEMAND,
|
|
451
|
+
mint: new web3_js_1.PublicKey('METADDFL6wWMWEoKTFJwcThTbUmtarRJZjRpzUvkxhr'),
|
|
452
|
+
precision: new __1.BN(10).pow(numericConstants_1.NINE),
|
|
453
|
+
precisionExp: numericConstants_1.NINE,
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
symbol: 'ME',
|
|
457
|
+
marketIndex: 30,
|
|
458
|
+
poolId: 0,
|
|
459
|
+
oracle: new web3_js_1.PublicKey('FLQjrmEPGwbCKRYZ1eYM5FPccHBrCv2cN4GBu3mWfmPH'),
|
|
460
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
461
|
+
mint: new web3_js_1.PublicKey('MEFNBXixkEbait3xn9bkm8WsJzXtVsaJEn4c8Sam21u'),
|
|
462
|
+
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
463
|
+
precisionExp: numericConstants_1.SIX,
|
|
464
|
+
pythFeedId: '0x91519e3e48571e1232a85a938e714da19fe5ce05107f3eebb8a870b2e8020169',
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
symbol: 'PENGU',
|
|
468
|
+
marketIndex: 31,
|
|
469
|
+
poolId: 0,
|
|
470
|
+
oracle: new web3_js_1.PublicKey('7vGHChuBJyFMYBqMLXRzBmRxWdSuwEmg8RvRm3RWQsxi'),
|
|
471
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
472
|
+
mint: new web3_js_1.PublicKey('2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv'),
|
|
473
|
+
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
474
|
+
precisionExp: numericConstants_1.SIX,
|
|
475
|
+
pythFeedId: '0xbed3097008b9b5e3c93bec20be79cb43986b85a996475589351a21e67bae9b61',
|
|
476
|
+
},
|
|
445
477
|
];
|
|
446
478
|
exports.SpotMarkets = {
|
|
447
479
|
devnet: exports.DevnetSpotMarkets,
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { NodeList } from './NodeList';
|
|
3
|
-
import { BN, DLOBNode, DLOBNodeType, DriftClient, MarketType, MarketTypeStr, OraclePriceData, Order,
|
|
3
|
+
import { BN, DLOBNode, DLOBNodeType, DriftClient, MarketType, MarketTypeStr, OraclePriceData, Order, PerpMarketAccount, PositionDirection, SlotSubscriber, SpotMarketAccount, StateAccount, TriggerOrderNode, UserMap } from '..';
|
|
4
4
|
import { PublicKey } from '@solana/web3.js';
|
|
5
|
-
import { DLOBOrders } from './DLOBOrders';
|
|
6
5
|
import { L2OrderBook, L2OrderBookGenerator, L3OrderBook } from './orderBookLevels';
|
|
6
|
+
export type DLOBOrder = {
|
|
7
|
+
user: PublicKey;
|
|
8
|
+
order: Order;
|
|
9
|
+
};
|
|
10
|
+
export type DLOBOrders = DLOBOrder[];
|
|
7
11
|
export type MarketNodeLists = {
|
|
8
12
|
restingLimit: {
|
|
9
13
|
ask: NodeList<'restingLimit'>;
|
|
@@ -25,6 +29,10 @@ export type MarketNodeLists = {
|
|
|
25
29
|
above: NodeList<'trigger'>;
|
|
26
30
|
below: NodeList<'trigger'>;
|
|
27
31
|
};
|
|
32
|
+
swift: {
|
|
33
|
+
ask: NodeList<'swift'>;
|
|
34
|
+
bid: NodeList<'swift'>;
|
|
35
|
+
};
|
|
28
36
|
};
|
|
29
37
|
type OrderBookCallback = () => void;
|
|
30
38
|
/**
|
|
@@ -55,15 +63,10 @@ export declare class DLOB {
|
|
|
55
63
|
* @returns a promise that resolves when the DLOB is initialized
|
|
56
64
|
*/
|
|
57
65
|
initFromUserMap(userMap: UserMap, slot: number): Promise<boolean>;
|
|
58
|
-
initFromOrders(dlobOrders: DLOBOrders, slot: number): boolean;
|
|
59
|
-
handleOrderRecord(record: OrderRecord, slot: number): void;
|
|
60
|
-
handleOrderActionRecord(record: OrderActionRecord, slot: number): void;
|
|
61
66
|
insertOrder(order: Order, userAccount: string, slot: number, isUserProtectedMaker: boolean, onInsert?: OrderBookCallback): void;
|
|
67
|
+
insertSwiftOrder(order: Order, userAccount: string, isUserProtectedMaker: boolean, onInsert?: OrderBookCallback): void;
|
|
62
68
|
addOrderList(marketType: MarketTypeStr, marketIndex: number): void;
|
|
63
|
-
|
|
64
|
-
trigger(order: Order, userAccount: PublicKey, slot: number, isUserProtectedMaker: boolean, onTrigger?: OrderBookCallback): void;
|
|
65
|
-
delete(order: Order, userAccount: PublicKey, slot: number, onDelete?: OrderBookCallback): void;
|
|
66
|
-
getListForOrder(order: Order, slot: number): NodeList<any> | undefined;
|
|
69
|
+
getListForOnChainOrder(order: Order, slot: number): NodeList<any> | undefined;
|
|
67
70
|
updateRestingLimitOrders(slot: number): void;
|
|
68
71
|
updateRestingLimitOrdersForMarketType(slot: number, marketTypeStr: MarketTypeStr): void;
|
|
69
72
|
getOrder(orderId: number, userAccount: PublicKey): Order | undefined;
|
|
@@ -77,8 +80,7 @@ export declare class DLOB {
|
|
|
77
80
|
findTakingNodesToFill(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, isAmmPaused: boolean, minAuctionDuration: number, fallbackAsk: BN | undefined, fallbackBid?: BN | undefined): NodeToFill[];
|
|
78
81
|
findTakingNodesCrossingMakerNodes(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, takerNodeGenerator: Generator<DLOBNode>, makerNodeGeneratorFn: (marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData) => Generator<DLOBNode>, doesCross: (takerPrice: BN | undefined, makerPrice: BN) => boolean): NodeToFill[];
|
|
79
82
|
findNodesCrossingFallbackLiquidity(marketType: MarketType, slot: number, oraclePriceData: OraclePriceData, nodeGenerator: Generator<DLOBNode>, doesCross: (nodePrice: BN | undefined) => boolean, minAuctionDuration: number): NodeToFill[];
|
|
80
|
-
findExpiredNodesToFill(marketIndex: number, ts: number, marketType: MarketType): NodeToFill[];
|
|
81
|
-
findJitAuctionNodesToFill(marketIndex: number, slot: number, oraclePriceData: OraclePriceData, marketType: MarketType): NodeToFill[];
|
|
83
|
+
findExpiredNodesToFill(marketIndex: number, ts: number, marketType: MarketType, slot?: BN): NodeToFill[];
|
|
82
84
|
getTakingBids(marketIndex: number, marketType: MarketType, slot: number, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
|
|
83
85
|
getTakingAsks(marketIndex: number, marketType: MarketType, slot: number, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
|
|
84
86
|
protected getBestNode(generatorList: Array<Generator<DLOBNode>>, oraclePriceData: OraclePriceData, slot: number, compareFcn: (bestDLOBNode: DLOBNode, currentDLOBNode: DLOBNode, slot: number, oraclePriceData: OraclePriceData) => boolean, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
|
|
@@ -93,7 +95,7 @@ export declare class DLOB {
|
|
|
93
95
|
* @param oraclePriceData
|
|
94
96
|
* @param filterFcn
|
|
95
97
|
*/
|
|
96
|
-
getAsks(marketIndex: number,
|
|
98
|
+
getAsks(marketIndex: number, _fallbackAsk: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
|
|
97
99
|
/**
|
|
98
100
|
* This will look at both the taking and resting limit bids
|
|
99
101
|
* @param marketIndex
|
|
@@ -103,7 +105,7 @@ export declare class DLOB {
|
|
|
103
105
|
* @param oraclePriceData
|
|
104
106
|
* @param filterFcn
|
|
105
107
|
*/
|
|
106
|
-
getBids(marketIndex: number,
|
|
108
|
+
getBids(marketIndex: number, _fallbackBid: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
|
|
107
109
|
findCrossingRestingLimitOrders(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): NodeToFill[];
|
|
108
110
|
determineMakerAndTaker(askNode: DLOBNode, bidNode: DLOBNode): {
|
|
109
111
|
takerNode: DLOBNode;
|