@drift-labs/sdk-browser 2.108.0-beta.3 → 2.108.0-beta.5

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 CHANGED
@@ -1 +1 @@
1
- 2.108.0-beta.3
1
+ 2.108.0-beta.5
@@ -197,10 +197,8 @@ 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): Promise<TransactionSignature>;
199
199
  getInitializePythPullOracleIx(feedId: string): Promise<TransactionInstruction>;
200
- initializePythLazerOracle(feedId: number, exponent: number): Promise<TransactionSignature>;
201
- getInitializePythLazerOracleIx(feedId: number, exponent: number): Promise<TransactionInstruction>;
202
- updatePythLazerOracleExponent(feedId: number, exponent: number): Promise<TransactionSignature>;
203
- getUpdatePythLazerOracleExponentIx(feedId: number, exponent: number): Promise<TransactionInstruction>;
200
+ initializePythLazerOracle(feedId: number): Promise<TransactionSignature>;
201
+ getInitializePythLazerOracleIx(feedId: number): Promise<TransactionInstruction>;
204
202
  initializeHighLeverageModeConfig(maxUsers: number): Promise<TransactionSignature>;
205
203
  getInitializeHighLeverageModeConfigIx(maxUsers: number): Promise<TransactionInstruction>;
206
204
  updateUpdateHighLeverageModeConfig(maxUsers: number, reduceOnly: boolean): Promise<TransactionSignature>;
@@ -1809,14 +1809,14 @@ class AdminClient extends driftClient_1.DriftClient {
1809
1809
  },
1810
1810
  });
1811
1811
  }
1812
- async initializePythLazerOracle(feedId, exponent) {
1813
- const initializePythPullOracleIx = await this.getInitializePythLazerOracleIx(feedId, exponent);
1812
+ async initializePythLazerOracle(feedId) {
1813
+ const initializePythPullOracleIx = await this.getInitializePythLazerOracleIx(feedId);
1814
1814
  const tx = await this.buildTransaction(initializePythPullOracleIx);
1815
1815
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1816
1816
  return txSig;
1817
1817
  }
1818
- async getInitializePythLazerOracleIx(feedId, exponent) {
1819
- return await this.program.instruction.initializePythLazerOracle(feedId, exponent, {
1818
+ async getInitializePythLazerOracleIx(feedId) {
1819
+ return await this.program.instruction.initializePythLazerOracle(feedId, {
1820
1820
  accounts: {
1821
1821
  admin: this.useHotWalletAdmin
1822
1822
  ? this.wallet.publicKey
@@ -1828,23 +1828,6 @@ class AdminClient extends driftClient_1.DriftClient {
1828
1828
  },
1829
1829
  });
1830
1830
  }
1831
- async updatePythLazerOracleExponent(feedId, exponent) {
1832
- const initializePythPullOracleIx = await this.getUpdatePythLazerOracleExponentIx(feedId, exponent);
1833
- const tx = await this.buildTransaction(initializePythPullOracleIx);
1834
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
1835
- return txSig;
1836
- }
1837
- async getUpdatePythLazerOracleExponentIx(feedId, exponent) {
1838
- return await this.program.instruction.updatePythLazerOracleExponent(feedId, exponent, {
1839
- accounts: {
1840
- admin: this.useHotWalletAdmin
1841
- ? this.wallet.publicKey
1842
- : this.getStateAccount().admin,
1843
- state: await this.getStatePublicKey(),
1844
- lazerOracle: (0, pda_1.getPythLazerOraclePublicKey)(this.program.programId, feedId),
1845
- },
1846
- });
1847
- }
1848
1831
  async initializeHighLeverageModeConfig(maxUsers) {
1849
1832
  const initializeHighLeverageModeConfigIx = await this.getInitializeHighLeverageModeConfigIx(maxUsers);
1850
1833
  const tx = await this.buildTransaction(initializeHighLeverageModeConfigIx);
@@ -6667,40 +6667,6 @@
6667
6667
  {
6668
6668
  "name": "feedId",
6669
6669
  "type": "u32"
6670
- },
6671
- {
6672
- "name": "exponent",
6673
- "type": "i32"
6674
- }
6675
- ]
6676
- },
6677
- {
6678
- "name": "updatePythLazerOracleExponent",
6679
- "accounts": [
6680
- {
6681
- "name": "admin",
6682
- "isMut": true,
6683
- "isSigner": true
6684
- },
6685
- {
6686
- "name": "lazerOracle",
6687
- "isMut": true,
6688
- "isSigner": false
6689
- },
6690
- {
6691
- "name": "state",
6692
- "isMut": false,
6693
- "isSigner": false
6694
- }
6695
- ],
6696
- "args": [
6697
- {
6698
- "name": "feedId",
6699
- "type": "u32"
6700
- },
6701
- {
6702
- "name": "exponent",
6703
- "type": "i32"
6704
6670
  }
6705
6671
  ]
6706
6672
  },
@@ -11393,7 +11359,8 @@
11393
11359
  "name": "Match",
11394
11360
  "fields": [
11395
11361
  "publicKey",
11396
- "u16"
11362
+ "u16",
11363
+ "u64"
11397
11364
  ]
11398
11365
  }
11399
11366
  ]
@@ -72,7 +72,7 @@ class SwiftOrderSubscriber {
72
72
  if (message['order']) {
73
73
  const order = JSON.parse(message['order']);
74
74
  const swiftOrderParamsBuf = Buffer.from(order['order_message'], 'hex');
75
- const swiftOrderParamsMessage = this.driftClient.program.coder.types.decode('SwiftOrderParamsMessage', swiftOrderParamsBuf);
75
+ const swiftOrderParamsMessage = this.driftClient.decodeSwiftOrderParamsMessage(swiftOrderParamsBuf);
76
76
  if (!swiftOrderParamsMessage.swiftOrderParams.price) {
77
77
  console.error(`order has no price: ${JSON.stringify(swiftOrderParamsMessage.swiftOrderParams)}`);
78
78
  return;
@@ -38,6 +38,7 @@ function getFeedIdUint8Array(feedId) {
38
38
  return Uint8Array.from(Buffer.from(trimmedFeedId, 'hex'));
39
39
  }
40
40
  exports.getFeedIdUint8Array = getFeedIdUint8Array;
41
+ const ED25519_INSTRUCTION_LEN = 16;
41
42
  const SIGNATURE_LEN = 64;
42
43
  const PUBKEY_LEN = 32;
43
44
  const MAGIC_LEN = 4;
@@ -95,7 +96,7 @@ function createMinimalEd25519VerifyIx(customInstructionIndex, messageOffset, cus
95
96
  const messageDataSizeOffset = publicKeyOffset + PUBKEY_LEN;
96
97
  const messageDataOffset = messageDataSizeOffset + MESSAGE_SIZE_LEN;
97
98
  const messageDataSize = readUint16LE(customInstructionData, messageDataSizeOffset - messageOffset);
98
- const instructionData = Buffer.alloc(16);
99
+ const instructionData = Buffer.alloc(ED25519_INSTRUCTION_LEN);
99
100
  ED25519_INSTRUCTION_LAYOUT.encode({
100
101
  numSignatures: 1,
101
102
  padding: 0,
@@ -197,10 +197,8 @@ 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): Promise<TransactionSignature>;
199
199
  getInitializePythPullOracleIx(feedId: string): Promise<TransactionInstruction>;
200
- initializePythLazerOracle(feedId: number, exponent: number): Promise<TransactionSignature>;
201
- getInitializePythLazerOracleIx(feedId: number, exponent: number): Promise<TransactionInstruction>;
202
- updatePythLazerOracleExponent(feedId: number, exponent: number): Promise<TransactionSignature>;
203
- getUpdatePythLazerOracleExponentIx(feedId: number, exponent: number): Promise<TransactionInstruction>;
200
+ initializePythLazerOracle(feedId: number): Promise<TransactionSignature>;
201
+ getInitializePythLazerOracleIx(feedId: number): Promise<TransactionInstruction>;
204
202
  initializeHighLeverageModeConfig(maxUsers: number): Promise<TransactionSignature>;
205
203
  getInitializeHighLeverageModeConfigIx(maxUsers: number): Promise<TransactionInstruction>;
206
204
  updateUpdateHighLeverageModeConfig(maxUsers: number, reduceOnly: boolean): Promise<TransactionSignature>;
@@ -1809,14 +1809,14 @@ class AdminClient extends driftClient_1.DriftClient {
1809
1809
  },
1810
1810
  });
1811
1811
  }
1812
- async initializePythLazerOracle(feedId, exponent) {
1813
- const initializePythPullOracleIx = await this.getInitializePythLazerOracleIx(feedId, exponent);
1812
+ async initializePythLazerOracle(feedId) {
1813
+ const initializePythPullOracleIx = await this.getInitializePythLazerOracleIx(feedId);
1814
1814
  const tx = await this.buildTransaction(initializePythPullOracleIx);
1815
1815
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1816
1816
  return txSig;
1817
1817
  }
1818
- async getInitializePythLazerOracleIx(feedId, exponent) {
1819
- return await this.program.instruction.initializePythLazerOracle(feedId, exponent, {
1818
+ async getInitializePythLazerOracleIx(feedId) {
1819
+ return await this.program.instruction.initializePythLazerOracle(feedId, {
1820
1820
  accounts: {
1821
1821
  admin: this.useHotWalletAdmin
1822
1822
  ? this.wallet.publicKey
@@ -1828,23 +1828,6 @@ class AdminClient extends driftClient_1.DriftClient {
1828
1828
  },
1829
1829
  });
1830
1830
  }
1831
- async updatePythLazerOracleExponent(feedId, exponent) {
1832
- const initializePythPullOracleIx = await this.getUpdatePythLazerOracleExponentIx(feedId, exponent);
1833
- const tx = await this.buildTransaction(initializePythPullOracleIx);
1834
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
1835
- return txSig;
1836
- }
1837
- async getUpdatePythLazerOracleExponentIx(feedId, exponent) {
1838
- return await this.program.instruction.updatePythLazerOracleExponent(feedId, exponent, {
1839
- accounts: {
1840
- admin: this.useHotWalletAdmin
1841
- ? this.wallet.publicKey
1842
- : this.getStateAccount().admin,
1843
- state: await this.getStatePublicKey(),
1844
- lazerOracle: (0, pda_1.getPythLazerOraclePublicKey)(this.program.programId, feedId),
1845
- },
1846
- });
1847
- }
1848
1831
  async initializeHighLeverageModeConfig(maxUsers) {
1849
1832
  const initializeHighLeverageModeConfigIx = await this.getInitializeHighLeverageModeConfigIx(maxUsers);
1850
1833
  const tx = await this.buildTransaction(initializeHighLeverageModeConfigIx);
@@ -6667,40 +6667,6 @@
6667
6667
  {
6668
6668
  "name": "feedId",
6669
6669
  "type": "u32"
6670
- },
6671
- {
6672
- "name": "exponent",
6673
- "type": "i32"
6674
- }
6675
- ]
6676
- },
6677
- {
6678
- "name": "updatePythLazerOracleExponent",
6679
- "accounts": [
6680
- {
6681
- "name": "admin",
6682
- "isMut": true,
6683
- "isSigner": true
6684
- },
6685
- {
6686
- "name": "lazerOracle",
6687
- "isMut": true,
6688
- "isSigner": false
6689
- },
6690
- {
6691
- "name": "state",
6692
- "isMut": false,
6693
- "isSigner": false
6694
- }
6695
- ],
6696
- "args": [
6697
- {
6698
- "name": "feedId",
6699
- "type": "u32"
6700
- },
6701
- {
6702
- "name": "exponent",
6703
- "type": "i32"
6704
6670
  }
6705
6671
  ]
6706
6672
  },
@@ -11393,7 +11359,8 @@
11393
11359
  "name": "Match",
11394
11360
  "fields": [
11395
11361
  "publicKey",
11396
- "u16"
11362
+ "u16",
11363
+ "u64"
11397
11364
  ]
11398
11365
  }
11399
11366
  ]
@@ -72,7 +72,7 @@ class SwiftOrderSubscriber {
72
72
  if (message['order']) {
73
73
  const order = JSON.parse(message['order']);
74
74
  const swiftOrderParamsBuf = Buffer.from(order['order_message'], 'hex');
75
- const swiftOrderParamsMessage = this.driftClient.program.coder.types.decode('SwiftOrderParamsMessage', swiftOrderParamsBuf);
75
+ const swiftOrderParamsMessage = this.driftClient.decodeSwiftOrderParamsMessage(swiftOrderParamsBuf);
76
76
  if (!swiftOrderParamsMessage.swiftOrderParams.price) {
77
77
  console.error(`order has no price: ${JSON.stringify(swiftOrderParamsMessage.swiftOrderParams)}`);
78
78
  return;
@@ -38,6 +38,7 @@ function getFeedIdUint8Array(feedId) {
38
38
  return Uint8Array.from(Buffer.from(trimmedFeedId, 'hex'));
39
39
  }
40
40
  exports.getFeedIdUint8Array = getFeedIdUint8Array;
41
+ const ED25519_INSTRUCTION_LEN = 16;
41
42
  const SIGNATURE_LEN = 64;
42
43
  const PUBKEY_LEN = 32;
43
44
  const MAGIC_LEN = 4;
@@ -95,7 +96,7 @@ function createMinimalEd25519VerifyIx(customInstructionIndex, messageOffset, cus
95
96
  const messageDataSizeOffset = publicKeyOffset + PUBKEY_LEN;
96
97
  const messageDataOffset = messageDataSizeOffset + MESSAGE_SIZE_LEN;
97
98
  const messageDataSize = readUint16LE(customInstructionData, messageDataSizeOffset - messageOffset);
98
- const instructionData = Buffer.alloc(16);
99
+ const instructionData = Buffer.alloc(ED25519_INSTRUCTION_LEN);
99
100
  ED25519_INSTRUCTION_LAYOUT.encode({
100
101
  numSignatures: 1,
101
102
  padding: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk-browser",
3
- "version": "2.108.0-beta.3",
3
+ "version": "2.108.0-beta.5",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
@@ -3936,11 +3936,10 @@ export class AdminClient extends DriftClient {
3936
3936
  }
3937
3937
 
3938
3938
  public async initializePythLazerOracle(
3939
- feedId: number,
3940
- exponent: number
3939
+ feedId: number
3941
3940
  ): Promise<TransactionSignature> {
3942
3941
  const initializePythPullOracleIx =
3943
- await this.getInitializePythLazerOracleIx(feedId, exponent);
3942
+ await this.getInitializePythLazerOracleIx(feedId);
3944
3943
  const tx = await this.buildTransaction(initializePythPullOracleIx);
3945
3944
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
3946
3945
 
@@ -3948,61 +3947,22 @@ export class AdminClient extends DriftClient {
3948
3947
  }
3949
3948
 
3950
3949
  public async getInitializePythLazerOracleIx(
3951
- feedId: number,
3952
- exponent: number
3950
+ feedId: number
3953
3951
  ): Promise<TransactionInstruction> {
3954
- return await this.program.instruction.initializePythLazerOracle(
3955
- feedId,
3956
- exponent,
3957
- {
3958
- accounts: {
3959
- admin: this.useHotWalletAdmin
3960
- ? this.wallet.publicKey
3961
- : this.getStateAccount().admin,
3962
- state: await this.getStatePublicKey(),
3963
- systemProgram: SystemProgram.programId,
3964
- lazerOracle: getPythLazerOraclePublicKey(
3965
- this.program.programId,
3966
- feedId
3967
- ),
3968
- rent: SYSVAR_RENT_PUBKEY,
3969
- },
3970
- }
3971
- );
3972
- }
3973
-
3974
- public async updatePythLazerOracleExponent(
3975
- feedId: number,
3976
- exponent: number
3977
- ): Promise<TransactionSignature> {
3978
- const initializePythPullOracleIx =
3979
- await this.getUpdatePythLazerOracleExponentIx(feedId, exponent);
3980
- const tx = await this.buildTransaction(initializePythPullOracleIx);
3981
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
3982
-
3983
- return txSig;
3984
- }
3985
-
3986
- public async getUpdatePythLazerOracleExponentIx(
3987
- feedId: number,
3988
- exponent: number
3989
- ): Promise<TransactionInstruction> {
3990
- return await this.program.instruction.updatePythLazerOracleExponent(
3991
- feedId,
3992
- exponent,
3993
- {
3994
- accounts: {
3995
- admin: this.useHotWalletAdmin
3996
- ? this.wallet.publicKey
3997
- : this.getStateAccount().admin,
3998
- state: await this.getStatePublicKey(),
3999
- lazerOracle: getPythLazerOraclePublicKey(
4000
- this.program.programId,
4001
- feedId
4002
- ),
4003
- },
4004
- }
4005
- );
3952
+ return await this.program.instruction.initializePythLazerOracle(feedId, {
3953
+ accounts: {
3954
+ admin: this.useHotWalletAdmin
3955
+ ? this.wallet.publicKey
3956
+ : this.getStateAccount().admin,
3957
+ state: await this.getStatePublicKey(),
3958
+ systemProgram: SystemProgram.programId,
3959
+ lazerOracle: getPythLazerOraclePublicKey(
3960
+ this.program.programId,
3961
+ feedId
3962
+ ),
3963
+ rent: SYSVAR_RENT_PUBKEY,
3964
+ },
3965
+ });
4006
3966
  }
4007
3967
 
4008
3968
  public async initializeHighLeverageModeConfig(
@@ -6667,40 +6667,6 @@
6667
6667
  {
6668
6668
  "name": "feedId",
6669
6669
  "type": "u32"
6670
- },
6671
- {
6672
- "name": "exponent",
6673
- "type": "i32"
6674
- }
6675
- ]
6676
- },
6677
- {
6678
- "name": "updatePythLazerOracleExponent",
6679
- "accounts": [
6680
- {
6681
- "name": "admin",
6682
- "isMut": true,
6683
- "isSigner": true
6684
- },
6685
- {
6686
- "name": "lazerOracle",
6687
- "isMut": true,
6688
- "isSigner": false
6689
- },
6690
- {
6691
- "name": "state",
6692
- "isMut": false,
6693
- "isSigner": false
6694
- }
6695
- ],
6696
- "args": [
6697
- {
6698
- "name": "feedId",
6699
- "type": "u32"
6700
- },
6701
- {
6702
- "name": "exponent",
6703
- "type": "i32"
6704
6670
  }
6705
6671
  ]
6706
6672
  },
@@ -11393,7 +11359,8 @@
11393
11359
  "name": "Match",
11394
11360
  "fields": [
11395
11361
  "publicKey",
11396
- "u16"
11362
+ "u16",
11363
+ "u64"
11397
11364
  ]
11398
11365
  }
11399
11366
  ]
@@ -124,10 +124,7 @@ export class SwiftOrderSubscriber {
124
124
  'hex'
125
125
  );
126
126
  const swiftOrderParamsMessage: SwiftOrderParamsMessage =
127
- this.driftClient.program.coder.types.decode(
128
- 'SwiftOrderParamsMessage',
129
- swiftOrderParamsBuf
130
- );
127
+ this.driftClient.decodeSwiftOrderParamsMessage(swiftOrderParamsBuf);
131
128
 
132
129
  if (!swiftOrderParamsMessage.swiftOrderParams.price) {
133
130
  console.error(
@@ -13,6 +13,7 @@ export function getFeedIdUint8Array(feedId: string): Uint8Array {
13
13
  return Uint8Array.from(Buffer.from(trimmedFeedId, 'hex'));
14
14
  }
15
15
 
16
+ const ED25519_INSTRUCTION_LEN = 16;
16
17
  const SIGNATURE_LEN = 64;
17
18
  const PUBKEY_LEN = 32;
18
19
  const MAGIC_LEN = 4;
@@ -116,7 +117,7 @@ export function createMinimalEd25519VerifyIx(
116
117
  messageDataSizeOffset - messageOffset
117
118
  );
118
119
 
119
- const instructionData = Buffer.alloc(16);
120
+ const instructionData = Buffer.alloc(ED25519_INSTRUCTION_LEN);
120
121
 
121
122
  ED25519_INSTRUCTION_LAYOUT.encode(
122
123
  {