@exodus/solana-api 3.14.6 → 3.14.7

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.14.7](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.14.6...@exodus/solana-api@3.14.7) (2025-04-03)
7
+
8
+ **Note:** Version bump only for package @exodus/solana-api
9
+
10
+
11
+
12
+
13
+
6
14
  ## [3.14.6](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.14.5...@exodus/solana-api@3.14.6) (2025-04-01)
7
15
 
8
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-api",
3
- "version": "3.14.6",
3
+ "version": "3.14.7",
4
4
  "description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Solana",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -46,7 +46,7 @@
46
46
  "@exodus/assets-testing": "^1.0.0",
47
47
  "@exodus/solana-web3.js": "^1.63.1-exodus.9-rc3"
48
48
  },
49
- "gitHead": "310d0d34a574d1da978f862e42c481de1e57bade",
49
+ "gitHead": "9b7dd58f7b4f5e4ba9e23e869dee7e26e5fe9499",
50
50
  "bugs": {
51
51
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Asolana-api"
52
52
  },
package/src/index.js CHANGED
@@ -4,7 +4,7 @@ import assetsList from '@exodus/solana-meta'
4
4
 
5
5
  import { Api } from './api.js'
6
6
 
7
- export { SolanaMonitor, SolanaAutoWithdrawMonitor } from './tx-log/index.js'
7
+ export { SolanaMonitor } from './tx-log/index.js'
8
8
  export { createAccountState } from './account-state.js'
9
9
  export { getSolStakedFee, getStakingInfo, getUnstakingFee } from './staking-utils.js'
10
10
  export {
@@ -1,2 +1 @@
1
1
  export * from './solana-monitor.js'
2
- export * from './solana-auto-withdraw-monitor.js'
@@ -1,90 +0,0 @@
1
- import { Timer } from '@exodus/timer'
2
- import assert from 'minimalistic-assert'
3
- import ms from 'ms'
4
-
5
- const INTERVAL = ms('30s')
6
-
7
- export class SolanaAutoWithdrawMonitor {
8
- constructor({ interval = INTERVAL, assetClientInterface, createAndSendStake }) {
9
- this.assetName = 'solana'
10
- this.timer = new Timer(interval)
11
- this.aci = assetClientInterface
12
- this.createAndSendStake = createAndSendStake
13
- assert(typeof createAndSendStake === 'function', 'createAndSendStake is required')
14
- this.cursors = {}
15
- }
16
-
17
- start = async () => {
18
- const assets = await this.aci.getAssetsForNetwork({ baseAssetName: this.assetName })
19
- this.asset = assets[this.assetName]
20
- await this.timer.start(() => this.tick())
21
- }
22
-
23
- async tick() {
24
- const walletAccounts = await this.aci.getWalletAccounts({ assetName: this.assetName })
25
- for (const walletAccount of walletAccounts) {
26
- await this._tick({ walletAccount })
27
- }
28
- }
29
-
30
- async _tick({ walletAccount }) {
31
- this.processing = this.processing || new Set()
32
- if (this.processing.has(walletAccount)) return
33
- this.processing.add(walletAccount)
34
-
35
- try {
36
- const accountState = await this.aci.getAccountState({
37
- assetName: this.assetName,
38
- walletAccount,
39
- })
40
- const { cursor, stakingInfo } = accountState
41
- const { loaded, withdrawable } = stakingInfo
42
-
43
- if (!Array.isArray(this.cursors[walletAccount])) this.cursors[walletAccount] = []
44
- const cursorChanged = !this.cursors[walletAccount].includes(cursor)
45
-
46
- if (loaded && cursorChanged && withdrawable.isPositive) {
47
- this.cursors[walletAccount].push(cursor)
48
- try {
49
- const txIds = await this.tryWithdraw({ accountState, walletAccount })
50
- this.cursors[walletAccount].push(...txIds)
51
- } catch (e) {
52
- console.log('solana auto withdraw error:', e)
53
- }
54
- }
55
- } finally {
56
- this.processing.delete(walletAccount)
57
- }
58
- }
59
-
60
- async tryWithdraw({ accountState, walletAccount }) {
61
- const stakingInfo = accountState.stakingInfo
62
- const feeData = await this.aci.getFeeData({ assetName: this.assetName })
63
- const fee = feeData?.fee ?? this.asset.currency.ZERO
64
-
65
- const solBalance = accountState?.balance ?? this.asset.currency.ZERO
66
- if (solBalance.lt(fee) || stakingInfo.withdrawable.isZero) return []
67
-
68
- const promises = await this.createAndSendStake(
69
- {
70
- method: 'withdraw',
71
- walletAccount,
72
- amount: stakingInfo.withdrawable,
73
- },
74
- { watchForTxConfirmation: false }
75
- )
76
-
77
- return Promise.all(promises)
78
- }
79
- }
80
-
81
- /*
82
- const _solanaAutoWithdrawMonitor = new SolanaAutoWithdrawMonitor({ interval: INTERVAL })
83
-
84
- export const solanaAutoWithdrawMonitor = {
85
- start:
86
- ({ assetClientInterface, createAndSendStake }) =>
87
- async () =>
88
- _solanaAutoWithdrawMonitor.start({ assetClientInterface, createAndSendStake }),
89
- }
90
- */