@exodus/solana-lib 3.11.1 → 3.11.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.11.2](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.11.1...@exodus/solana-lib@3.11.2) (2025-05-05)
7
+
8
+ **Note:** Version bump only for package @exodus/solana-lib
9
+
10
+
11
+
12
+
13
+
6
14
  ## [3.11.1](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.11.0...@exodus/solana-lib@3.11.1) (2025-04-21)
7
15
 
8
16
  **Note:** Version bump only for package @exodus/solana-lib
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-lib",
3
- "version": "3.11.1",
3
+ "version": "3.11.2",
4
4
  "description": "Solana utils, such as for cryptography, address encoding/decoding, transaction building, etc.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -46,5 +46,5 @@
46
46
  "type": "git",
47
47
  "url": "git+https://github.com/ExodusMovement/assets.git"
48
48
  },
49
- "gitHead": "2e550990ef9db4209f8fe4e6e0485579d1afeedf"
49
+ "gitHead": "aeb2c9fa295b25d05938640f32aa6f3d318c6922"
50
50
  }
@@ -277,7 +277,7 @@ class Tx {
277
277
  }
278
278
 
279
279
  static undelegate({ address, stakeAddresses, recentBlockhash }) {
280
- // undelegate all stake addresses
280
+ // undelegate all stake addresses, in a single tx
281
281
  assert(Array.isArray(stakeAddresses), 'stakeAddresses Array is required')
282
282
 
283
283
  const fromPubkey = new PublicKey(address)
@@ -295,19 +295,29 @@ class Tx {
295
295
  return transaction
296
296
  }
297
297
 
298
- static withdraw({ address, stakeAddresses, amount, recentBlockhash }) {
298
+ static withdraw({ address, accounts, recentBlockhash }) {
299
+ // withdraw all inactive unstaked addresses, in a single tx
300
+ assert(typeof accounts === 'object', 'accounts object is required')
299
301
  const fromPubkey = new PublicKey(address)
300
- const stakeAddress = Array.isArray(stakeAddresses) ? stakeAddresses[0] : stakeAddresses
301
- const stakePublicKey = new PublicKey(stakeAddress)
302
302
 
303
- // TODO: why don't we put all withdraw in a single tx??
304
- const transaction = StakeProgram.withdraw({
305
- stakePubkey: stakePublicKey,
306
- authorizedPubkey: fromPubkey,
307
- toPubkey: fromPubkey,
308
- lamports: amount,
309
- })
310
- transaction.recentBlockhash = recentBlockhash
303
+ const transaction = new Transaction({ recentBlockhash })
304
+
305
+ // putting all withdraw instructions in a single tx
306
+ for (const [stakeAddress, account] of Object.entries(accounts)) {
307
+ if (!account.canWithdraw) continue // skip non-withdrawable accounts
308
+ if (!account.lamports) continue // skip empty accounts
309
+
310
+ const stakePublicKey = new PublicKey(stakeAddress)
311
+
312
+ const instruction = StakeProgram.withdraw({
313
+ stakePubkey: stakePublicKey,
314
+ authorizedPubkey: fromPubkey,
315
+ toPubkey: fromPubkey,
316
+ lamports: account.lamports,
317
+ })
318
+ transaction.add(instruction)
319
+ }
320
+
311
321
  return transaction
312
322
  }
313
323
 
@@ -18,6 +18,7 @@ export function createUnsignedTx({
18
18
  method,
19
19
  // Staking related:
20
20
  stakeAddresses,
21
+ accounts,
21
22
  seed,
22
23
  pool,
23
24
  // MagicEden escrow/related:
@@ -54,6 +55,7 @@ export function createUnsignedTx({
54
55
  // Staking related:
55
56
  method,
56
57
  stakeAddresses,
58
+ accounts,
57
59
  seed,
58
60
  pool,
59
61
  // MagicEden escrow/related:
@@ -9,6 +9,7 @@ export function parseUnsignedTx({ asset, unsignedTx }) {
9
9
  fromTokenAddresses,
10
10
  method,
11
11
  stakeAddresses,
12
+ accounts,
12
13
  seed,
13
14
  pool,
14
15
  initializerAddress,
@@ -41,6 +42,7 @@ export function parseUnsignedTx({ asset, unsignedTx }) {
41
42
  // staking related
42
43
  method,
43
44
  stakeAddresses,
45
+ accounts,
44
46
  seed,
45
47
  pool,
46
48
  // MagicEden escrow/related:
@@ -141,12 +141,12 @@ const createUndelegateTransaction = ({ address, recentBlockhash, stakeAddresses
141
141
  stakeAddresses,
142
142
  })
143
143
 
144
- const createWithdrawTransaction = ({ address, amount, recentBlockhash, stakeAddresses }) =>
144
+ const createWithdrawTransaction = ({ address, amount, recentBlockhash, accounts }) =>
145
145
  Transaction.withdraw({
146
146
  address,
147
147
  amount,
148
148
  recentBlockhash,
149
- stakeAddresses,
149
+ accounts,
150
150
  })
151
151
 
152
152
  const createMagicEdenInitializeEscrowTransaction = ({