@exodus/solana-api 3.9.1 → 3.9.3

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,23 @@
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.9.3](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.9.2...@exodus/solana-api@3.9.3) (2024-07-23)
7
+
8
+ **Note:** Version bump only for package @exodus/solana-api
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.9.2](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.9.1...@exodus/solana-api@3.9.2) (2024-07-18)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * match correct solana dex swap amount ([#2878](https://github.com/ExodusMovement/assets/issues/2878)) ([24d8d13](https://github.com/ExodusMovement/assets/commit/24d8d138a99d80d36088b89ff1f5d8a04308a2ec))
20
+
21
+
22
+
6
23
  ## [3.9.1](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.9.0...@exodus/solana-api@3.9.1) (2024-07-15)
7
24
 
8
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-api",
3
- "version": "3.9.1",
3
+ "version": "3.9.3",
4
4
  "description": "Exodus internal Solana asset API wrapper",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -16,7 +16,7 @@
16
16
  "access": "restricted"
17
17
  },
18
18
  "scripts": {
19
- "test": "run -T jest",
19
+ "test": "run -T exodus-test --jest --esbuild",
20
20
  "lint": "run -T eslint .",
21
21
  "lint:fix": "yarn lint --fix"
22
22
  },
@@ -47,7 +47,7 @@
47
47
  "@exodus/assets-testing": "^1.0.0",
48
48
  "@solana/web3.js": "^1.91.8"
49
49
  },
50
- "gitHead": "054951dbfb7fb897b4b072e35fd5601920393b71",
50
+ "gitHead": "faa92e86406bfff4f738557b73773bc8c539d53d",
51
51
  "bugs": {
52
52
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Asolana-api"
53
53
  },
@@ -17,7 +17,7 @@ export const createAccountState = ({ assetList }) => {
17
17
  cursor: '',
18
18
  balance: asset.currency.ZERO,
19
19
  tokenBalances: Object.create(null),
20
- mem: {
20
+ stakingInfo: {
21
21
  loaded: false,
22
22
  staking: {
23
23
  // remote-config data
package/src/api.js CHANGED
@@ -1,5 +1,5 @@
1
- import BN from 'bn.js'
2
1
  import createApi from '@exodus/asset-json-rpc'
2
+ import { magicEden } from '@exodus/nfts-core'
3
3
  import { retry } from '@exodus/simple-retry'
4
4
  import {
5
5
  buildRawTransaction,
@@ -15,10 +15,11 @@ import {
15
15
  TOKEN_PROGRAM_ID,
16
16
  } from '@exodus/solana-lib'
17
17
  import assert from 'assert'
18
+ import BN from 'bn.js'
18
19
  import lodash from 'lodash'
19
20
  import urljoin from 'url-join'
20
21
  import wretch from 'wretch'
21
- import { magicEden } from '@exodus/nfts-core'
22
+
22
23
  import { Connection } from './connection'
23
24
 
24
25
  // Doc: https://docs.solana.com/apps/jsonrpc-api
@@ -26,7 +27,6 @@ import { Connection } from './connection'
26
27
  const RPC_URL = 'https://solana.a.exodus.io' // https://vip-api.mainnet-beta.solana.com/, https://api.mainnet-beta.solana.com
27
28
  const WS_ENDPOINT = 'wss://solana.a.exodus.io/ws' // not standard across all node providers (we're compatible only with Quicknode)
28
29
  const FORCE_HTTP = true // use https over ws
29
- const WRAPPED_SOLANA_TOKEN_MINT_ADDRESS = `So11111111111111111111111111111111111111112`
30
30
 
31
31
  // Tokens + SOL api support
32
32
  export class Api {
@@ -379,24 +379,19 @@ export class Api {
379
379
 
380
380
  const source = lodash.get(ix, 'parsed.info.source')
381
381
  const destination = lodash.get(ix, 'parsed.info.destination')
382
- const mint = lodash.get(ix, 'parsed.info.mint')
383
382
  const amount = Number(
384
383
  lodash.get(ix, 'parsed.info.amount', 0) ||
385
384
  lodash.get(ix, 'parsed.info.tokenAmount.amount', 0)
386
385
  )
387
386
  const txId = txDetails.transaction.signatures[0]
388
- if (
389
- accountToRedeemToOwner &&
390
- [source, destination].includes(accountToRedeemToOwner) &&
391
- mint === WRAPPED_SOLANA_TOKEN_MINT_ADDRESS
392
- ) {
393
- const ownerOrAccount = (account) =>
387
+ if (accountToRedeemToOwner && destination === accountToRedeemToOwner) {
388
+ const getOwnerOrAccount = (account) =>
394
389
  account && account === accountToRedeemToOwner ? ownerAddress : account
395
390
 
396
391
  solanaTransferTx = {
397
392
  id: txId,
398
- from: ownerOrAccount(source),
399
- to: ownerOrAccount(destination),
393
+ from: getOwnerOrAccount(source),
394
+ to: getOwnerOrAccount(destination),
400
395
  amount,
401
396
  fee,
402
397
  }
@@ -10,9 +10,9 @@ export const getBalancesFactory =
10
10
  const { balance, locked, withdrawable, pending } = fixBalances({
11
11
  txLog,
12
12
  balance: getBalanceFromAccountState({ asset, accountState }),
13
- locked: accountState.mem?.locked || zero,
14
- withdrawable: accountState.mem?.withdrawable || zero,
15
- pending: accountState.mem?.pending || zero,
13
+ locked: accountState.stakingInfo?.locked || zero,
14
+ withdrawable: accountState.stakingInfo?.withdrawable || zero,
15
+ pending: accountState.stakingInfo?.pending || zero,
16
16
  asset,
17
17
  })
18
18
  if (asset.baseAsset.name !== asset.name) {
@@ -12,21 +12,21 @@ export const getSolStakedFee = ({ asset, stakingInfo, fee }) => {
12
12
  return allPending > 0 ? fee.mul(allPending) : currency.ZERO
13
13
  }
14
14
 
15
- export const getStakingInfo = (accountMem) => {
15
+ export const getStakingInfo = (stakingInfo) => {
16
16
  return {
17
- loaded: accountMem.loaded,
18
- staking: accountMem.staking,
19
- isDelegating: accountMem.isDelegating,
20
- locked: accountMem.locked,
21
- activating: accountMem.activating,
22
- withdrawable: accountMem.withdrawable,
23
- pending: accountMem.pending,
24
- accounts: accountMem.accounts,
25
- earned: accountMem.earned,
17
+ loaded: stakingInfo.loaded,
18
+ staking: stakingInfo.staking,
19
+ isDelegating: stakingInfo.isDelegating,
20
+ locked: stakingInfo.locked,
21
+ activating: stakingInfo.activating,
22
+ withdrawable: stakingInfo.withdrawable,
23
+ pending: stakingInfo.pending,
24
+ accounts: stakingInfo.accounts,
25
+ earned: stakingInfo.earned,
26
26
  }
27
27
  }
28
28
 
29
29
  export const getUnstakingFee = ({ asset, fee, accountState }) => {
30
- const stakingInfo = getStakingInfo(accountState.mem ?? {})
30
+ const stakingInfo = getStakingInfo(accountState.stakingInfo ?? {})
31
31
  return getSolStakedFee({ asset, stakingInfo, fee })
32
32
  }
@@ -125,7 +125,7 @@ export class MeSolanaMonitor extends SolanaMonitor {
125
125
  const staking =
126
126
  this.isStakingEnabled() && fetchStakingInfo
127
127
  ? await this.getStakingInfo({ address, walletAccount })
128
- : { ...accountState.mem, staking: this.staking }
128
+ : { ...accountState.stakingInfo, staking: this.staking }
129
129
 
130
130
  return { account, tokenAccounts, staking }
131
131
  }
@@ -31,8 +31,8 @@ export class SolanaAutoWithdrawMonitor {
31
31
  assetName: this.assetName,
32
32
  walletAccount,
33
33
  })
34
- const { cursor, mem } = accountState
35
- const { loaded, withdrawable } = mem
34
+ const { cursor, stakingInfo } = accountState
35
+ const { loaded, withdrawable } = stakingInfo
36
36
 
37
37
  if (!Array.isArray(this.cursors[walletAccount])) this.cursors[walletAccount] = []
38
38
  const cursorChanged = !this.cursors[walletAccount].includes(cursor)
@@ -49,7 +49,7 @@ export class SolanaAutoWithdrawMonitor {
49
49
  }
50
50
 
51
51
  async tryWithdraw({ accountState, walletAccount }) {
52
- const stakingInfo = accountState.mem
52
+ const stakingInfo = accountState.stakingInfo
53
53
  const feeData = await this.aci.getFeeData({ assetName: this.assetName })
54
54
  const fee = get(feeData, 'fee', this.asset.currency.ZERO)
55
55
 
@@ -309,7 +309,7 @@ export class SolanaMonitor extends BaseMonitor {
309
309
  const staking =
310
310
  this.isStakingEnabled() && fetchStakingInfo
311
311
  ? await this.getStakingInfo({ address, walletAccount })
312
- : { ...accountState.mem, staking: this.staking }
312
+ : { ...accountState.stakingInfo, staking: this.staking }
313
313
 
314
314
  const stakedBalance = this.asset.currency.baseUnit(staking.locked)
315
315
  const withdrawableBalance = this.asset.currency.baseUnit(staking.withdrawable)
@@ -332,7 +332,7 @@ export class SolanaMonitor extends BaseMonitor {
332
332
 
333
333
  async updateState({ account, cursorState, walletAccount, staking }) {
334
334
  const { balance, tokenBalances } = account
335
- const newData = { balance, tokenBalances, mem: staking, ...cursorState }
335
+ const newData = { balance, tokenBalances, stakingInfo: staking, ...cursorState }
336
336
  return this.updateAccountState({ newData, walletAccount })
337
337
  }
338
338