@drift-labs/sdk-browser 2.107.0-beta.12 → 2.107.0-beta.14
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 +3 -2
- package/lib/browser/constants/spotMarkets.js +3 -2
- package/lib/browser/driftClient.js +7 -1
- package/lib/node/constants/perpMarkets.js +3 -2
- package/lib/node/constants/spotMarkets.js +3 -2
- package/lib/node/driftClient.js +7 -1
- package/package.json +1 -1
- package/src/constants/perpMarkets.ts +4 -2
- package/src/constants/spotMarkets.ts +4 -2
- package/src/driftClient.ts +10 -4
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.107.0-beta.
|
|
1
|
+
2.107.0-beta.14
|
|
@@ -1084,9 +1084,10 @@ exports.MainnetPerpMarkets = [
|
|
|
1084
1084
|
symbol: 'MELANIA-PERP',
|
|
1085
1085
|
baseAssetSymbol: 'MELANIA',
|
|
1086
1086
|
marketIndex: 65,
|
|
1087
|
-
oracle: new web3_js_1.PublicKey('
|
|
1087
|
+
oracle: new web3_js_1.PublicKey('28Zk42cxbg4MxiTewSwoedvW6MUgjoVHSTvTW7zQ7ESi'),
|
|
1088
1088
|
launchTs: 1737360280000,
|
|
1089
|
-
oracleSource: __1.OracleSource.
|
|
1089
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
1090
|
+
pythFeedId: '0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
|
|
1090
1091
|
},
|
|
1091
1092
|
];
|
|
1092
1093
|
exports.PerpMarkets = {
|
|
@@ -560,11 +560,12 @@ exports.MainnetSpotMarkets = [
|
|
|
560
560
|
symbol: 'MELANIA',
|
|
561
561
|
marketIndex: 37,
|
|
562
562
|
poolId: 0,
|
|
563
|
-
oracle: new web3_js_1.PublicKey('
|
|
564
|
-
oracleSource: __1.OracleSource.
|
|
563
|
+
oracle: new web3_js_1.PublicKey('28Zk42cxbg4MxiTewSwoedvW6MUgjoVHSTvTW7zQ7ESi'),
|
|
564
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
565
565
|
mint: new web3_js_1.PublicKey('FUAfBo2jgks6gB4Z4LfZkqSZgzNucisEHqnNebaRxM1P'),
|
|
566
566
|
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
567
567
|
precisionExp: numericConstants_1.SIX,
|
|
568
|
+
pythFeedId: '0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
|
|
568
569
|
launchTs: 1737360280000,
|
|
569
570
|
},
|
|
570
571
|
];
|
|
@@ -70,6 +70,7 @@ const on_demand_1 = require("@switchboard-xyz/on-demand");
|
|
|
70
70
|
const grpcDriftClientAccountSubscriber_1 = require("./accounts/grpcDriftClientAccountSubscriber");
|
|
71
71
|
const tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
72
72
|
const oracleId_1 = require("./oracles/oracleId");
|
|
73
|
+
const sha256_1 = require("@coral-xyz/anchor/dist/cjs/utils/sha256");
|
|
73
74
|
/**
|
|
74
75
|
* # DriftClient
|
|
75
76
|
* This class is the main way to interact with Drift Protocol. It allows you to subscribe to the various accounts where the Market's state is stored, as well as: opening positions, liquidating, settling funding, depositing & withdrawing, and more.
|
|
@@ -3185,7 +3186,12 @@ class DriftClient {
|
|
|
3185
3186
|
* Borsh encode swift taker order params
|
|
3186
3187
|
*/
|
|
3187
3188
|
encodeSwiftOrderParamsMessage(orderParamsMessage) {
|
|
3188
|
-
|
|
3189
|
+
const anchorIxName = 'global' + ':' + 'swiftOrderMessageParams';
|
|
3190
|
+
const prefix = Buffer.from((0, sha256_1.hash)(anchorIxName).slice(0, 8));
|
|
3191
|
+
return Buffer.concat([
|
|
3192
|
+
prefix,
|
|
3193
|
+
this.program.coder.types.encode('SwiftOrderParamsMessage', orderParamsMessage),
|
|
3194
|
+
]);
|
|
3189
3195
|
}
|
|
3190
3196
|
/*
|
|
3191
3197
|
* Decode swift taker order params from borsh buffer
|
|
@@ -1084,9 +1084,10 @@ exports.MainnetPerpMarkets = [
|
|
|
1084
1084
|
symbol: 'MELANIA-PERP',
|
|
1085
1085
|
baseAssetSymbol: 'MELANIA',
|
|
1086
1086
|
marketIndex: 65,
|
|
1087
|
-
oracle: new web3_js_1.PublicKey('
|
|
1087
|
+
oracle: new web3_js_1.PublicKey('28Zk42cxbg4MxiTewSwoedvW6MUgjoVHSTvTW7zQ7ESi'),
|
|
1088
1088
|
launchTs: 1737360280000,
|
|
1089
|
-
oracleSource: __1.OracleSource.
|
|
1089
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
1090
|
+
pythFeedId: '0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
|
|
1090
1091
|
},
|
|
1091
1092
|
];
|
|
1092
1093
|
exports.PerpMarkets = {
|
|
@@ -560,11 +560,12 @@ exports.MainnetSpotMarkets = [
|
|
|
560
560
|
symbol: 'MELANIA',
|
|
561
561
|
marketIndex: 37,
|
|
562
562
|
poolId: 0,
|
|
563
|
-
oracle: new web3_js_1.PublicKey('
|
|
564
|
-
oracleSource: __1.OracleSource.
|
|
563
|
+
oracle: new web3_js_1.PublicKey('28Zk42cxbg4MxiTewSwoedvW6MUgjoVHSTvTW7zQ7ESi'),
|
|
564
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
565
565
|
mint: new web3_js_1.PublicKey('FUAfBo2jgks6gB4Z4LfZkqSZgzNucisEHqnNebaRxM1P'),
|
|
566
566
|
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
567
567
|
precisionExp: numericConstants_1.SIX,
|
|
568
|
+
pythFeedId: '0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
|
|
568
569
|
launchTs: 1737360280000,
|
|
569
570
|
},
|
|
570
571
|
];
|
package/lib/node/driftClient.js
CHANGED
|
@@ -70,6 +70,7 @@ const on_demand_1 = require("@switchboard-xyz/on-demand");
|
|
|
70
70
|
const grpcDriftClientAccountSubscriber_1 = require("./accounts/grpcDriftClientAccountSubscriber");
|
|
71
71
|
const tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
72
72
|
const oracleId_1 = require("./oracles/oracleId");
|
|
73
|
+
const sha256_1 = require("@coral-xyz/anchor/dist/cjs/utils/sha256");
|
|
73
74
|
/**
|
|
74
75
|
* # DriftClient
|
|
75
76
|
* This class is the main way to interact with Drift Protocol. It allows you to subscribe to the various accounts where the Market's state is stored, as well as: opening positions, liquidating, settling funding, depositing & withdrawing, and more.
|
|
@@ -3185,7 +3186,12 @@ class DriftClient {
|
|
|
3185
3186
|
* Borsh encode swift taker order params
|
|
3186
3187
|
*/
|
|
3187
3188
|
encodeSwiftOrderParamsMessage(orderParamsMessage) {
|
|
3188
|
-
|
|
3189
|
+
const anchorIxName = 'global' + ':' + 'swiftOrderMessageParams';
|
|
3190
|
+
const prefix = Buffer.from((0, sha256_1.hash)(anchorIxName).slice(0, 8));
|
|
3191
|
+
return Buffer.concat([
|
|
3192
|
+
prefix,
|
|
3193
|
+
this.program.coder.types.encode('SwiftOrderParamsMessage', orderParamsMessage),
|
|
3194
|
+
]);
|
|
3189
3195
|
}
|
|
3190
3196
|
/*
|
|
3191
3197
|
* Decode swift taker order params from borsh buffer
|
package/package.json
CHANGED
|
@@ -1174,9 +1174,11 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
1174
1174
|
symbol: 'MELANIA-PERP',
|
|
1175
1175
|
baseAssetSymbol: 'MELANIA',
|
|
1176
1176
|
marketIndex: 65,
|
|
1177
|
-
oracle: new PublicKey('
|
|
1177
|
+
oracle: new PublicKey('28Zk42cxbg4MxiTewSwoedvW6MUgjoVHSTvTW7zQ7ESi'),
|
|
1178
1178
|
launchTs: 1737360280000,
|
|
1179
|
-
oracleSource: OracleSource.
|
|
1179
|
+
oracleSource: OracleSource.PYTH_PULL,
|
|
1180
|
+
pythFeedId:
|
|
1181
|
+
'0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
|
|
1180
1182
|
},
|
|
1181
1183
|
];
|
|
1182
1184
|
|
|
@@ -664,11 +664,13 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
|
|
|
664
664
|
symbol: 'MELANIA',
|
|
665
665
|
marketIndex: 37,
|
|
666
666
|
poolId: 0,
|
|
667
|
-
oracle: new PublicKey('
|
|
668
|
-
oracleSource: OracleSource.
|
|
667
|
+
oracle: new PublicKey('28Zk42cxbg4MxiTewSwoedvW6MUgjoVHSTvTW7zQ7ESi'),
|
|
668
|
+
oracleSource: OracleSource.PYTH_PULL,
|
|
669
669
|
mint: new PublicKey('FUAfBo2jgks6gB4Z4LfZkqSZgzNucisEHqnNebaRxM1P'),
|
|
670
670
|
precision: new BN(10).pow(SIX),
|
|
671
671
|
precisionExp: SIX,
|
|
672
|
+
pythFeedId:
|
|
673
|
+
'0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
|
|
672
674
|
launchTs: 1737360280000,
|
|
673
675
|
},
|
|
674
676
|
];
|
package/src/driftClient.ts
CHANGED
|
@@ -182,6 +182,7 @@ import nacl from 'tweetnacl';
|
|
|
182
182
|
import { Slothash } from './slot/SlothashSubscriber';
|
|
183
183
|
import { getOracleId } from './oracles/oracleId';
|
|
184
184
|
import { SignedSwiftOrderParams } from './swift/types';
|
|
185
|
+
import { hash } from '@coral-xyz/anchor/dist/cjs/utils/sha256';
|
|
185
186
|
|
|
186
187
|
type RemainingAccountParams = {
|
|
187
188
|
userAccounts: UserAccount[];
|
|
@@ -5882,10 +5883,15 @@ export class DriftClient {
|
|
|
5882
5883
|
public encodeSwiftOrderParamsMessage(
|
|
5883
5884
|
orderParamsMessage: SwiftOrderParamsMessage
|
|
5884
5885
|
): Buffer {
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5886
|
+
const anchorIxName = 'global' + ':' + 'swiftOrderMessageParams';
|
|
5887
|
+
const prefix = Buffer.from(hash(anchorIxName).slice(0, 8));
|
|
5888
|
+
return Buffer.concat([
|
|
5889
|
+
prefix,
|
|
5890
|
+
this.program.coder.types.encode(
|
|
5891
|
+
'SwiftOrderParamsMessage',
|
|
5892
|
+
orderParamsMessage
|
|
5893
|
+
),
|
|
5894
|
+
]);
|
|
5889
5895
|
}
|
|
5890
5896
|
|
|
5891
5897
|
/*
|