@exodus/solana-api 3.29.6 → 3.30.0

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,22 @@
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.30.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.29.6...@exodus/solana-api@3.30.0) (2026-03-10)
7
+
8
+
9
+ ### Features
10
+
11
+
12
+ * feat: switch Solana txs to Clarity (#7449)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+
18
+ * fix: helius vote false param (#7486)
19
+
20
+
21
+
6
22
  ## [3.29.6](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.29.5...@exodus/solana-api@3.29.6) (2026-02-23)
7
23
 
8
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-api",
3
- "version": "3.29.6",
3
+ "version": "3.30.0",
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",
@@ -45,11 +45,11 @@
45
45
  "url-join": "^4.0.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@exodus/asset": "^2.2.0",
48
+ "@exodus/asset": "^2.3.0",
49
49
  "@exodus/assets-testing": "^1.0.0",
50
50
  "@exodus/solana-web3.js": "^1.63.1-exodus.9-rc3"
51
51
  },
52
- "gitHead": "6ac0fce9b0cc8dc2fe3cb5b940f077ec36cfcae3",
52
+ "gitHead": "0076335abe2f542d07cc23704104c106ed38d5f3",
53
53
  "bugs": {
54
54
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Asolana-api"
55
55
  },
@@ -17,6 +17,7 @@ export const createAccountState = ({ assetList }) => {
17
17
  return class SolanaAccountState extends AccountState {
18
18
  static defaults = {
19
19
  cursor: '',
20
+ historyCursor: '',
20
21
  balance: asset.currency.ZERO,
21
22
  tokenBalances: Object.create(null),
22
23
  rentExemptAmount: asset.currency.ZERO,
@@ -7,7 +7,7 @@ import urljoin from 'url-join'
7
7
 
8
8
  import { RpcApi } from './rpc-api.js'
9
9
 
10
- const CLARITY_URL = 'https://solana-clarity.a.exodus.io/api/v2/solana'
10
+ const CLARITY_URL = 'https://assets-gateway-clarity-api.a.exodus.io/assets/api/v2/solana'
11
11
 
12
12
  // Filter out nil and empty string values to prevent API validation errors (e.g., empty cursor)
13
13
  const cleanQuery = (obj) => omitBy(obj, (v) => isNil(v) || v === '')
@@ -47,11 +47,15 @@ export class ClarityApi extends RpcApi {
47
47
  })
48
48
  }
49
49
 
50
- async getTransactions(address, { cursor, limit, includeUnparsed = false } = Object.create(null)) {
50
+ async getTransactions(
51
+ address,
52
+ { after, before, limit, includeUnparsed = false } = Object.create(null)
53
+ ) {
51
54
  const result = await this.request(`/addresses/${encodeURIComponent(address)}/transactions`)
52
55
  .query(
53
56
  cleanQuery({
54
- cursor,
57
+ before,
58
+ after,
55
59
  limit,
56
60
  includeUnparsed,
57
61
  })
@@ -18,21 +18,21 @@ const TICKS_BETWEEN_STAKE_FETCHES = 5
18
18
  const TX_STALE_AFTER = ms('2m') // mark txs as dropped after N minutes
19
19
 
20
20
  export class SolanaClarityMonitor extends BaseMonitor {
21
+ #maxFetchLimitPerTick
22
+
21
23
  constructor({
22
24
  clarityApi,
23
- rpcApi,
24
25
  includeUnparsed = false,
25
26
  ticksBetweenHistoryFetches = TICKS_BETWEEN_HISTORY_FETCHES,
26
27
  ticksBetweenStakeFetches = TICKS_BETWEEN_STAKE_FETCHES,
27
28
  txsLimit,
29
+ maxFetchLimitPerTick = 5,
28
30
  shouldUpdateBalanceBeforeHistory = true,
29
31
  ...args
30
32
  }) {
31
33
  super(args)
32
34
  assert(clarityApi, 'clarityApi is required')
33
35
  this.clarityApi = clarityApi
34
- this.rpcApi = rpcApi
35
- this.cursors = Object.create(null)
36
36
  this.assets = Object.create(null)
37
37
  this.staking = DEFAULT_REMOTE_CONFIG.staking
38
38
  this.ticksBetweenStakeFetches = ticksBetweenStakeFetches
@@ -40,6 +40,7 @@ export class SolanaClarityMonitor extends BaseMonitor {
40
40
  this.shouldUpdateBalanceBeforeHistory = shouldUpdateBalanceBeforeHistory
41
41
  this.includeUnparsed = includeUnparsed
42
42
  this.txsLimit = txsLimit
43
+ this.#maxFetchLimitPerTick = maxFetchLimitPerTick
43
44
  }
44
45
 
45
46
  setServer(config = Object.create(null)) {
@@ -53,11 +54,6 @@ export class SolanaClarityMonitor extends BaseMonitor {
53
54
  this.staking = staking
54
55
  }
55
56
 
56
- hasNewCursor({ walletAccount, cursorState }) {
57
- const { cursor } = cursorState
58
- return this.cursors[walletAccount] !== cursor
59
- }
60
-
61
57
  async emitUnknownTokensEvent({ tokenAccounts }) {
62
58
  const tokensList = await this.clarityApi.getWalletTokensList({ tokenAccounts })
63
59
  const unknownTokensList = tokensList.filter((mintAddress) => {
@@ -101,7 +97,7 @@ export class SolanaClarityMonitor extends BaseMonitor {
101
97
  const txSet = await this.aci.getTxLog({ assetName, walletAccount })
102
98
  const { stale } = this.getUnconfirmed({ txSet, staleTxAge: TX_STALE_AFTER })
103
99
  if (stale.length > 0) {
104
- clearedLogItems[assetName] = lodash.unionBy(logItemsByAsset[assetName], stale, 'txId')
100
+ clearedLogItems[assetName] = lodash.unionBy(logItemsByAsset[assetName] ?? [], stale, 'txId')
105
101
  }
106
102
  }
107
103
 
@@ -137,9 +133,9 @@ export class SolanaClarityMonitor extends BaseMonitor {
137
133
  })
138
134
  const hasUnconfirmedSentTx = [...baseAssetTxLog].some((tx) => tx.pending && tx.sent)
139
135
 
140
- const shouldUpdateHistory =
136
+ const shouldUpdateLatestHistory =
141
137
  refresh || isHistoryUpdateTick || balanceChanged || hasUnconfirmedSentTx
142
- const shouldUpdateOnlyBalance = balanceChanged && !shouldUpdateHistory
138
+ const shouldUpdateOnlyBalance = balanceChanged && !shouldUpdateLatestHistory
143
139
 
144
140
  // start a batch
145
141
  const batch = this.aci.createOperationsBatch()
@@ -150,50 +146,146 @@ export class SolanaClarityMonitor extends BaseMonitor {
150
146
  await this.emitUnknownTokensEvent({ tokenAccounts })
151
147
  }
152
148
 
153
- if (shouldUpdateHistory) {
154
- const { logItemsByAsset, cursorState } = await this.getHistory({
149
+ const newCursorState = {
150
+ cursor: accountState.cursor,
151
+ historyCursor: accountState.historyCursor,
152
+ }
153
+
154
+ const newTransactions = []
155
+
156
+ if (shouldUpdateLatestHistory) {
157
+ const { transactions: latestTransactions, cursorState: latestHistoryCursorState } =
158
+ await this.getLatestHistory({
159
+ address,
160
+ accountState,
161
+ walletAccount,
162
+ refresh,
163
+ tokenAccounts,
164
+ })
165
+
166
+ if (latestHistoryCursorState.cursor) {
167
+ newCursorState.cursor = latestHistoryCursorState.cursor
168
+ }
169
+
170
+ if (latestHistoryCursorState.historyCursor) {
171
+ // refresh case will have historyCursor available
172
+ // but if user has 0 txs, it won't be available, therefore need to check
173
+ newCursorState.historyCursor = latestHistoryCursorState.historyCursor
174
+ }
175
+
176
+ newTransactions.push(...latestTransactions)
177
+ }
178
+
179
+ const shouldFetchOldHistory = !refresh && newCursorState.historyCursor // on refresh request, wait until next tick to fetch old history
180
+ if (shouldFetchOldHistory) {
181
+ const { transactions: historyTransactions, historyCursor } = await this.fetchOldHistory({
155
182
  address,
156
- accountState,
157
- walletAccount,
158
- refresh,
159
- tokenAccounts,
183
+ historyCursor: newCursorState.historyCursor,
160
184
  })
161
185
 
162
- const cursorChanged = this.hasNewCursor({ walletAccount, cursorState })
186
+ newTransactions.push(...historyTransactions)
187
+ // Always update so we persist historyCursor = undefined when history is exhausted
188
+ newCursorState.historyCursor = historyCursor
189
+ }
190
+
191
+ await this.emitUnknownTokensEvent({ tokenAccounts })
163
192
 
193
+ if (newTransactions.length > 0) {
164
194
  // update all state at once
165
- const clearedLogItems = await this.markStaleTransactions({ walletAccount, logItemsByAsset })
195
+ const clearedLogItems = await this.markStaleTransactions({
196
+ walletAccount,
197
+ logItemsByAsset: this.mapTransactionsToLogItems({ transactions: newTransactions, address }),
198
+ })
199
+
166
200
  this.updateTxLogByAssetBatch({
167
201
  logItemsByAsset: clearedLogItems,
168
202
  walletAccount,
169
203
  refresh,
170
204
  batch,
171
205
  })
172
- this.updateState({ account, cursorState, walletAccount, staking, batch })
173
- await this.emitUnknownTokensEvent({ tokenAccounts })
174
- if (refresh || cursorChanged) {
175
- this.cursors[walletAccount] = cursorState.cursor
176
- }
177
206
  }
178
207
 
208
+ // Always persist cursor state so historyCursor advances (and is cleared when history exhausted)
209
+ this.updateState({
210
+ account,
211
+ cursorState: newCursorState,
212
+ walletAccount,
213
+ staking,
214
+ batch,
215
+ })
216
+
179
217
  // close batch
180
218
  await this.aci.executeOperationsBatch(batch)
181
219
  }
182
220
 
183
- async getHistory({ address, accountState, refresh, tokenAccounts } = Object.create(null)) {
184
- const cursor = refresh ? '' : accountState.cursor
185
- const baseAsset = this.asset
221
+ async fetchOldHistory({ address, historyCursor }) {
222
+ if (!historyCursor) return { transactions: [], historyCursor: undefined }
186
223
 
187
- // TODO: switch to this.clarityApi.getTransactions once ready!!
188
- // and remove this.rpcApi from constructor and create-asset-utils.js
189
- const { transactions, newCursor } = await this.rpcApi.getTransactions(address, {
190
- cursor,
191
- includeUnparsed: this.includeUnparsed,
192
- limit: this.txsLimit,
193
- tokenAccounts,
224
+ try {
225
+ const { transactions, before } = await this.clarityApi.getTransactions(address, {
226
+ before: historyCursor,
227
+ includeUnparsed: this.includeUnparsed,
228
+ limit: this.txsLimit,
229
+ })
230
+
231
+ if (!transactions || transactions.length === 0 || !before) {
232
+ // no more transactions to fetch, return undefined to stop fetching old history
233
+ return { transactions: [], historyCursor: undefined }
234
+ }
235
+
236
+ const transactionsWithSilentSound = transactions.map((tx) => ({
237
+ ...tx,
238
+ data: { ...tx.data, silentSound: true },
239
+ }))
240
+
241
+ return { transactions: transactionsWithSilentSound, historyCursor: before }
242
+ } catch (error) {
243
+ console.warn('SolanaClarityMonitor fetchOldHistory failed', {
244
+ address,
245
+ historyCursor,
246
+ error,
247
+ })
248
+
249
+ return { transactions: [], historyCursor: undefined }
250
+ }
251
+ }
252
+
253
+ async getLatestHistory({ address, accountState, refresh, tokenAccounts } = Object.create(null)) {
254
+ if (refresh || !accountState.cursor) {
255
+ const { transactions, before, after } = await this.clarityApi.getTransactions(address, {
256
+ after: undefined,
257
+ includeUnparsed: this.includeUnparsed,
258
+ limit: this.txsLimit,
259
+ })
260
+
261
+ return {
262
+ transactions,
263
+ hasNewTxs: transactions.length > 0,
264
+ cursorState: {
265
+ cursor: after,
266
+ historyCursor: before,
267
+ },
268
+ }
269
+ }
270
+
271
+ const { transactions, after: newAfterCursor } = await this.fetchLatestTransactions({
272
+ address,
273
+ afterCursor: accountState.cursor,
194
274
  })
195
275
 
276
+ return {
277
+ transactions,
278
+ hasNewTxs: transactions.length > 0,
279
+ cursorState: {
280
+ cursor: newAfterCursor,
281
+ },
282
+ }
283
+ }
284
+
285
+ mapTransactionsToLogItems({ transactions, address }) {
286
+ const baseAsset = this.asset
196
287
  const mappedTransactions = []
288
+
197
289
  for (const tx of transactions) {
198
290
  // we get the token name using the token.mintAddress
199
291
  const assetName = tx.token
@@ -218,6 +310,7 @@ export class SolanaClarityMonitor extends BaseMonitor {
218
310
  staking: tx.staking || null,
219
311
  unparsed: !!tx.unparsed,
220
312
  swapTx: !!(tx.data && tx.data.inner),
313
+ silentSound: !!tx.data?.silentSound,
221
314
  },
222
315
  currencies: { [assetName]: asset.currency, [feeAsset.name]: feeAsset.currency },
223
316
  }
@@ -262,12 +355,63 @@ export class SolanaClarityMonitor extends BaseMonitor {
262
355
  mappedTransactions.push(item)
263
356
  }
264
357
 
265
- const logItemsByAsset = lodash.groupBy(mergeByTxId(mappedTransactions), 'coinName')
266
- return {
267
- logItemsByAsset,
268
- hasNewTxs: transactions.length > 0,
269
- cursorState: { cursor: newCursor },
358
+ return lodash.groupBy(mergeByTxId(mappedTransactions), 'coinName')
359
+ }
360
+
361
+ async fetchLatestTransactions({ address, afterCursor }) {
362
+ let cursor = afterCursor
363
+ let allTransactions = []
364
+ let newAfterCursor = afterCursor
365
+ let fetchCount = 0
366
+
367
+ while (fetchCount < this.#maxFetchLimitPerTick) {
368
+ try {
369
+ const { transactions, after } = await this.clarityApi.getTransactions(address, {
370
+ after: cursor,
371
+ includeUnparsed: this.includeUnparsed,
372
+ limit: this.txsLimit,
373
+ })
374
+
375
+ fetchCount += 1
376
+
377
+ if (!transactions || transactions.length === 0) {
378
+ break
379
+ }
380
+
381
+ if (!after) {
382
+ // guard against missing cursor on non-empty transactions
383
+ console.warn('SolanaClarityMonitor missing cursor with transactions', {
384
+ address,
385
+ cursor,
386
+ afterCursor,
387
+ fetchCount,
388
+ transactionsCount: transactions.length,
389
+ })
390
+ break
391
+ }
392
+
393
+ allTransactions = [...allTransactions, ...transactions]
394
+
395
+ if (after === cursor) {
396
+ newAfterCursor = after
397
+ break
398
+ }
399
+
400
+ cursor = after
401
+ newAfterCursor = after
402
+ } catch (error) {
403
+ console.warn('SolanaClarityMonitor fetchLatestTransactions failed', {
404
+ address,
405
+ cursor,
406
+ afterCursor,
407
+ fetchCount,
408
+ error,
409
+ })
410
+ break
411
+ }
270
412
  }
413
+
414
+ return { transactions: allTransactions, after: newAfterCursor }
271
415
  }
272
416
 
273
417
  async getAccountsAndBalances({ refresh, address, accountState, walletAccount }) {
@@ -367,17 +511,18 @@ export class SolanaClarityMonitor extends BaseMonitor {
367
511
  stakingInfo: staking,
368
512
  ...cursorState,
369
513
  }
514
+
370
515
  return this.updateAccountStateBatch({ assetName, walletAccount, newData, batch })
371
516
  }
372
517
 
373
518
  async getStakingInfo({ address, accountState, walletAccount }) {
374
519
  const stakingInfo = await this.clarityApi.getStakeAccountsInfo(address)
375
- let earned = accountState.stakingInfo.earned.toBaseString()
520
+ let earned = accountState.stakingInfo?.earned?.toBaseString() ?? '0'
376
521
  try {
377
522
  const rewards = await this.clarityApi.getRewards(address)
378
523
  earned = rewards
379
524
  } catch (error) {
380
- console.warn(error)
525
+ console.warn('SolanaClarityMonitor getStakingInfo failed', { address, error })
381
526
  }
382
527
 
383
528
  return {
@@ -26,7 +26,6 @@ export class SolanaWebsocketMonitor extends SolanaClarityMonitor {
26
26
  async beforeStart() {
27
27
  this.assets = await this.aci.getAssetsForNetwork({ baseAssetName: this.asset.name })
28
28
  this.clarityApi.setTokens(this.assets)
29
- this.rpcApi.setTokens(this.assets)
30
29
 
31
30
  const walletAccounts = await this.aci.getWalletAccounts({ assetName: this.asset.name })
32
31
  await Promise.all(
@@ -50,7 +49,7 @@ export class SolanaWebsocketMonitor extends SolanaClarityMonitor {
50
49
  useCache: true,
51
50
  })
52
51
 
53
- const { accounts: tokenAccountsByOwner } = await this.rpcApi.getTokensBalancesAndAccounts({
52
+ const { accounts: tokenAccountsByOwner } = await this.clarityApi.getTokensBalancesAndAccounts({
54
53
  address,
55
54
  })
56
55
  this.tokenAccountsByOwner[walletAccount] = tokenAccountsByOwner
package/src/ws-api.js CHANGED
@@ -7,7 +7,7 @@ import { parseTransaction } from './tx-parser.js'
7
7
  import { isSolAddressPoisoningTx } from './txs-utils.js'
8
8
 
9
9
  // Triton Whirligig WebSocket
10
- const TRITON_WS_ENDPOINT = 'wss://solana-triton.a.exodus.io/whirligig' // pointing to: wss://exodus-solanama-6db3.mainnet.rpcpool.com/<token>/whirligig
10
+ // const TRITON_WS_ENDPOINT = 'wss://solana-triton.a.exodus.io/whirligig' // pointing to: wss://exodus-solanama-6db3.mainnet.rpcpool.com/<token>/whirligig
11
11
  // Helius Enhanced WebSocket (https://www.helius.dev/docs/enhanced-websockets)
12
12
  const HELIUS_WS_URL = 'wss://solana-helius-wss.a.exodus.io/ws'
13
13
 
@@ -31,7 +31,7 @@ export class WsApi {
31
31
  }
32
32
 
33
33
  setWsEndpoint(wsUrl) {
34
- this.wsUrl = wsUrl || TRITON_WS_ENDPOINT
34
+ this.wsUrl = wsUrl || HELIUS_WS_URL
35
35
  }
36
36
 
37
37
  /** True when using Helius Enhanced WebSocket (different transactionSubscribe params and notification shape). */
@@ -189,7 +189,7 @@ export class WsApi {
189
189
  maxSupportedTransactionVersion: 255,
190
190
  }
191
191
  const filter = this.#isHelius()
192
- ? { accountInclude: difference }
192
+ ? { vote: false, accountInclude: difference }
193
193
  : { vote: false, accounts: { include: difference } }
194
194
  conn.send({
195
195
  jsonrpc: '2.0',