@augustdigital/sdk 8.5.0 → 8.6.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.
Files changed (101) hide show
  1. package/README.md +207 -117
  2. package/lib/adapters/evm/index.d.ts +4 -4
  3. package/lib/adapters/evm/index.js +2 -0
  4. package/lib/adapters/solana/constants.d.ts +1 -1
  5. package/lib/adapters/solana/getters.d.ts +1 -1
  6. package/lib/adapters/solana/index.d.ts +4 -4
  7. package/lib/adapters/solana/index.js +4 -0
  8. package/lib/adapters/solana/types.d.ts +1 -1
  9. package/lib/adapters/solana/utils.d.ts +3 -3
  10. package/lib/adapters/solana/vault.actions.d.ts +4 -4
  11. package/lib/adapters/stellar/actions.d.ts +1 -1
  12. package/lib/adapters/stellar/index.d.ts +24 -2
  13. package/lib/adapters/stellar/index.js +25 -2
  14. package/lib/adapters/stellar/soroban.d.ts +1 -1
  15. package/lib/adapters/stellar/soroban.js +1 -1
  16. package/lib/adapters/stellar/submit.d.ts +20 -3
  17. package/lib/adapters/stellar/submit.js +74 -8
  18. package/lib/adapters/sui/getters.d.ts +1 -1
  19. package/lib/adapters/sui/index.d.ts +1 -1
  20. package/lib/adapters/sui/index.js +2 -0
  21. package/lib/adapters/sui/transformer.d.ts +2 -2
  22. package/lib/adapters/sui/transformer.js +1 -0
  23. package/lib/adapters/sui/types.d.ts +1 -1
  24. package/lib/core/analytics/sentry-runtime.js +1 -1
  25. package/lib/core/analytics/sentry.d.ts +2 -2
  26. package/lib/core/analytics/types.d.ts +1 -1
  27. package/lib/core/analytics/user-identity.d.ts +2 -2
  28. package/lib/core/analytics/user-identity.js +1 -1
  29. package/lib/core/analytics/version.d.ts +1 -1
  30. package/lib/core/analytics/version.js +1 -1
  31. package/lib/core/base.class.d.ts +3 -3
  32. package/lib/core/base.class.js +10 -4
  33. package/lib/core/constants/adapters.d.ts +1 -1
  34. package/lib/core/constants/core.d.ts +2 -0
  35. package/lib/core/constants/core.js +6 -0
  36. package/lib/core/constants/swap-router.d.ts +37 -1
  37. package/lib/core/constants/swap-router.js +41 -1
  38. package/lib/core/constants/vaults.d.ts +1 -1
  39. package/lib/core/constants/web3.d.ts +1 -1
  40. package/lib/core/constants/web3.js +0 -3
  41. package/lib/core/errors/index.d.ts +2 -2
  42. package/lib/core/errors/index.js +9 -0
  43. package/lib/core/fetcher.d.ts +39 -39
  44. package/lib/core/fetcher.js +75 -57
  45. package/lib/core/helpers/adapters.d.ts +1 -1
  46. package/lib/core/helpers/core.d.ts +21 -18
  47. package/lib/core/helpers/core.js +22 -20
  48. package/lib/core/helpers/explorer-link.d.ts +1 -1
  49. package/lib/core/helpers/signer.d.ts +1 -1
  50. package/lib/core/helpers/swap-router.d.ts +1 -1
  51. package/lib/core/helpers/vault-version.d.ts +1 -1
  52. package/lib/core/helpers/vaults.d.ts +1 -1
  53. package/lib/core/helpers/web3.d.ts +2 -2
  54. package/lib/core/helpers/web3.js +9 -9
  55. package/lib/core/vault-metadata.d.ts +1 -1
  56. package/lib/core/version-check.js +1 -1
  57. package/lib/evm/methods/crossChainVault.js +1 -1
  58. package/lib/evm/types/crossChain.js +1 -1
  59. package/lib/main.d.ts +1 -1
  60. package/lib/main.js +7 -0
  61. package/lib/modules/sub-accounts/fetcher.d.ts +2 -2
  62. package/lib/modules/sub-accounts/main.d.ts +2 -2
  63. package/lib/modules/sub-accounts/main.js +1 -1
  64. package/lib/modules/sub-accounts/utils.d.ts +1 -1
  65. package/lib/modules/vaults/adapter.helpers.d.ts +3 -3
  66. package/lib/modules/vaults/fetcher.d.ts +25 -0
  67. package/lib/modules/vaults/fetcher.js +51 -1
  68. package/lib/modules/vaults/getters.d.ts +50 -50
  69. package/lib/modules/vaults/getters.js +68 -67
  70. package/lib/modules/vaults/main.js +3 -1
  71. package/lib/modules/vaults/read.actions.d.ts +2 -2
  72. package/lib/modules/vaults/utils/call-data-decoder.d.ts +1 -1
  73. package/lib/modules/vaults/utils.d.ts +19 -3
  74. package/lib/modules/vaults/utils.js +39 -6
  75. package/lib/modules/vaults/write.actions.js +35 -1
  76. package/lib/polyfills.js +3 -3
  77. package/lib/sdk.d.ts +1339 -1197
  78. package/lib/services/coingecko/fetcher.d.ts +10 -9
  79. package/lib/services/coingecko/fetcher.js +22 -18
  80. package/lib/services/debank/fetcher.d.ts +1 -1
  81. package/lib/services/debank/utils.d.ts +1 -1
  82. package/lib/services/debank/utils.js +1 -1
  83. package/lib/services/layerzero/deposits.d.ts +1 -1
  84. package/lib/services/layerzero/redeems.d.ts +1 -1
  85. package/lib/services/octavfi/fetcher.d.ts +1 -1
  86. package/lib/services/octavfi/types.d.ts +1 -1
  87. package/lib/services/octavfi/utils.d.ts +2 -2
  88. package/lib/services/subgraph/fetcher.js +1 -1
  89. package/lib/services/subgraph/vaults.js +76 -0
  90. package/lib/services/swap-quotes/index.d.ts +9 -0
  91. package/lib/services/swap-quotes/index.js +2 -1
  92. package/lib/services/swap-quotes/paraswap.d.ts +8 -0
  93. package/lib/services/swap-quotes/paraswap.js +8 -0
  94. package/lib/types/pools.d.ts +2 -2
  95. package/lib/types/staking.d.ts +1 -1
  96. package/lib/types/sub-accounts.d.ts +1 -1
  97. package/lib/types/subgraph.d.ts +10 -1
  98. package/lib/types/vaults.d.ts +26 -0
  99. package/lib/types/web3.d.ts +1 -1
  100. package/lib/types/webserver.d.ts +2 -2
  101. package/package.json +1 -1
@@ -103,10 +103,10 @@ const redeems_1 = require("../../services/layerzero/redeems");
103
103
  * Fetch comprehensive vault data including on-chain state and backend metadata.
104
104
  * Routes to appropriate chain adapter (EVM v1/v2, Solana, or Stellar) based on vault version.
105
105
  * Optionally enriches with loan and allocation data.
106
- * @param vault Vault contract address (EVM hex, Stellar C-address, or Solana program ID)
107
- * @param loans Include active loan data
108
- * @param allocations Include DeFi/CeFi allocation breakdowns
109
- * @param options RPC and service configuration
106
+ * @param vault - Vault contract address (EVM hex, Stellar C-address, or Solana program ID)
107
+ * @param loans - Include active loan data
108
+ * @param allocations - Include DeFi/CeFi allocation breakdowns
109
+ * @param options - RPC and service configuration
110
110
  * @returns Complete vault object with optional enrichments
111
111
  */
112
112
  async function getVault({ vault, loans = false, allocations = false, options, loadSubaccounts, loadSnapshots, }) {
@@ -355,8 +355,8 @@ async function getVaultSubaccountLoans(vault, options) {
355
355
  * Fetch comprehensive vault asset allocation breakdown.
356
356
  * Includes DeFi protocols (via DeBank), CeFi balances, OTC positions, and loans.
357
357
  * Categorizes exposures by borrowing, supplying, lending, and wallet holdings.
358
- * @param vault Vault address
359
- * @param options RPC configuration
358
+ * @param vault - Vault address
359
+ * @param options - RPC configuration
360
360
  * @returns Detailed allocation data with exposure categorization
361
361
  */
362
362
  async function getVaultAllocations(vault, options) {
@@ -604,9 +604,9 @@ async function getVaultAvailableRedemptions({ vault, wallet, options, }) {
604
604
  core_1.Logger.log.warn('getVaultAvailableRedemptions', `Skipping invalid event: ${ev}`);
605
605
  continue;
606
606
  }
607
- let month;
608
- let day;
609
- let year;
607
+ let month = 0;
608
+ let day = 0;
609
+ let year = 0;
610
610
  if (version === 'evm-2') {
611
611
  // Use UTC-based computeClaimableDate to mirror contract logic exactly
612
612
  const claimable = (0, date_utils_1.computeClaimableDate)(Number(ev.timestamp_), lagDuration);
@@ -931,11 +931,12 @@ async function getVaultRedemptionHistory({ vault, wallet, lookbackBlocks, option
931
931
  if (isV2 && logs.length > 0) {
932
932
  const uniqueBlocks = [...new Set(logs.map((l) => l.blockNumber))];
933
933
  const blockResults = await Promise.all(uniqueBlocks.map((bn) => provider.getBlock(bn)));
934
- blockTimestamps = new Map();
934
+ const timestamps = new Map();
935
935
  blockResults.forEach((block) => {
936
936
  if (block)
937
- blockTimestamps.set(block.number, block.timestamp);
937
+ timestamps.set(block.number, block.timestamp);
938
938
  });
939
+ blockTimestamps = timestamps;
939
940
  }
940
941
  // format — iterate logs directly to preserve transactionHash
941
942
  const redemptions = [];
@@ -1190,7 +1191,7 @@ async function getVaultApy({ vault, options, historical, }) {
1190
1191
  const query = urlParams.toString();
1191
1192
  if (!query)
1192
1193
  return '';
1193
- return baseUrl && baseUrl.includes('?') ? `&${query}` : `?${query}`;
1194
+ return baseUrl?.includes('?') ? `&${query}` : `?${query}`;
1194
1195
  }
1195
1196
  const baseUrl = core_1.WEBSERVER_ENDPOINTS.public.tokenizedVault.historicalApy(vault);
1196
1197
  const historicalApy = await (0, core_1.fetchAugustPublic)(`${baseUrl}${paramBuilder(historical, baseUrl)}`, {
@@ -1357,15 +1358,15 @@ async function getVaultTvl({ vault, options, historical, }) {
1357
1358
  case 'evm-2': {
1358
1359
  const receiptTokenAddress = await (0, core_1.getReceiptTokenAddress)(provider, vault);
1359
1360
  const receiptTokenDecimals = await (0, core_1.getDecimals)(provider, receiptTokenAddress, false);
1360
- const receiptTokenContract = (0, core_1.createContract)({
1361
- address: receiptTokenAddress,
1362
- abi: TokenizedVaultV2Receipt_1.ABI_TOKENIZED_VAULT_V2_RECEIPT,
1361
+ const vaultContract = (0, core_1.createContract)({
1362
+ address: vault,
1363
+ abi: TokenizedVaultV2_1.ABI_TOKENIZED_VAULT_V2,
1363
1364
  provider,
1364
1365
  });
1365
- const totalSupply = await receiptTokenContract.totalSupply();
1366
+ const totalAssets = await vaultContract.getTotalAssets();
1366
1367
  return [
1367
1368
  {
1368
- value: (0, core_1.toNormalizedBn)(totalSupply, receiptTokenDecimals),
1369
+ value: (0, core_1.toNormalizedBn)(totalAssets, receiptTokenDecimals),
1369
1370
  timestamp: new Date().toISOString(),
1370
1371
  },
1371
1372
  ];
@@ -1377,10 +1378,10 @@ async function getVaultTvl({ vault, options, historical, }) {
1377
1378
  provider,
1378
1379
  });
1379
1380
  const decimals = await (0, core_1.getDecimals)(provider, vault);
1380
- const totalSupply = await vaultContract.totalSupply();
1381
+ const totalAssets = await vaultContract.totalAssets();
1381
1382
  return [
1382
1383
  {
1383
- value: (0, core_1.toNormalizedBn)(totalSupply, decimals),
1384
+ value: (0, core_1.toNormalizedBn)(totalAssets, decimals),
1384
1385
  timestamp: new Date().toISOString(),
1385
1386
  },
1386
1387
  ];
@@ -1495,8 +1496,8 @@ async function getVaultTvl({ vault, options, historical, }) {
1495
1496
  * `health_factor: undefined` so callers can render an explicit empty state
1496
1497
  * rather than a perpetual loading skeleton.
1497
1498
  *
1498
- * @param vault Vault address to scope the fetch to.
1499
- * @param options Standard vault options — `rpcUrl` must point at `vault`'s chain.
1499
+ * @param vault - Vault address to scope the fetch to.
1500
+ * @param options - Standard vault options — `rpcUrl` must point at `vault`'s chain.
1500
1501
  * @returns Array of `IVaultBorrowerHealthFactor`, one entry per active loan.
1501
1502
  */
1502
1503
  async function getVaultBorrowerHealthFactor({ vault, options, }) {
@@ -1588,8 +1589,8 @@ async function getVaultBorrowerHealthFactor({ vault, options, }) {
1588
1589
  * look up entries without worrying about EIP-55 checksum casing in either the
1589
1590
  * backend response or the caller's input.
1590
1591
  *
1591
- * @param options Standard vault options — `rpcUrl` should match `vault`'s chain.
1592
- * @param vault Optional vault address to scope the fetch to.
1592
+ * @param options - Standard vault options — `rpcUrl` should match `vault`'s chain.
1593
+ * @param vault - Optional vault address to scope the fetch to.
1593
1594
  * @returns Map of lowercased vault address → array of borrower-health-factor rows.
1594
1595
  */
1595
1596
  async function getHealthFactorOfBorrowersByVault({ options, vault, }) {
@@ -1620,8 +1621,8 @@ async function getHealthFactorOfBorrowersByVault({ options, vault, }) {
1620
1621
  /**
1621
1622
  * Fetch user points from the backend API endpoint.
1622
1623
  * This replaces client-side points calculation with server-side processing.
1623
- * @param userAddress User wallet address (EVM or Solana)
1624
- * @param options Request options including headers
1624
+ * @param userAddress - User wallet address (EVM or Solana)
1625
+ * @param options - Request options including headers
1625
1626
  * @returns Points data from the backend API
1626
1627
  */
1627
1628
  async function getUserPoints({ userAddress, options, }) {
@@ -1665,24 +1666,24 @@ async function getUserPoints({ userAddress, options, }) {
1665
1666
  * expires: {expiry}
1666
1667
  * ```
1667
1668
  *
1668
- * @param userAddress EVM wallet address being registered. Must match the
1669
+ * @param userAddress - EVM wallet address being registered. Must match the
1669
1670
  * signer that produced `signature`. Lowercased before being embedded in
1670
1671
  * the canonical message.
1671
- * @param referrerAddress Optional EVM address that referred this user.
1672
+ * @param referrerAddress - Optional EVM address that referred this user.
1672
1673
  * Lowercased when embedded; the literal string `"none"` is used when
1673
1674
  * absent. Tampering with this field after signing produces 401.
1674
- * @param chainId Chain on which the wallet signed. For smart-contract wallets
1675
+ * @param chainId - Chain on which the wallet signed. For smart-contract wallets
1675
1676
  * (Safe etc.) this is the chain whose RPC the backend will use to run the
1676
1677
  * EIP-1271 `isValidSignature` check; for EOAs it still pins the signature
1677
1678
  * to a chain so it can't be replayed cross-chain. Must be one of the chains
1678
1679
  * Upshift supports (see backend `SUPPORTED_REGISTRATION_CHAINS`).
1679
- * @param signature `0x`-prefixed hex of the personal_sign signature over
1680
+ * @param signature - `0x`-prefixed hex of the personal_sign signature over
1680
1681
  * the canonical message. Single-use: replays within ~10 min are rejected.
1681
- * @param nonce Caller-generated random string (8–128 chars). Pair with
1682
+ * @param nonce - Caller-generated random string (8–128 chars). Pair with
1682
1683
  * `userAddress` to form the single-use key in the backend's nonce store.
1683
- * @param expiry Unix timestamp (seconds). Must be in the future and within
1684
+ * @param expiry - Unix timestamp (seconds). Must be in the future and within
1684
1685
  * the backend's TTL window (currently 10 min).
1685
- * @param options Request options (headers).
1686
+ * @param options - Request options (headers).
1686
1687
  * @returns Raw `Response` from the backend. 200 on success, 401 for
1687
1688
  * expired / replayed / mismatched-signer / tampered-referrer, 422 for an
1688
1689
  * unsupported `chainId`.
@@ -1735,8 +1736,8 @@ async function registerUserForPoints({ userAddress, referrerAddress, chainId, si
1735
1736
  }
1736
1737
  /**
1737
1738
  * Fetch the points leaderboard data.
1738
- * @param params Optional parameters for pagination and sorting
1739
- * @param options Request options including headers
1739
+ * @param params - Optional parameters for pagination and sorting
1740
+ * @param options - Request options including headers
1740
1741
  * @returns Leaderboard response data
1741
1742
  */
1742
1743
  async function fetchPointsLeaderboard({ params, options, }) {
@@ -1764,8 +1765,8 @@ async function fetchPointsLeaderboard({ params, options, }) {
1764
1765
  /**
1765
1766
  * Fetch the timestamp when yield was last realized for a vault.
1766
1767
  * Returns the assetsUpdatedOn timestamp from the vault contract.
1767
- * @param vault Vault contract address
1768
- * @param options RPC configuration
1768
+ * @param vault - Vault contract address
1769
+ * @param options - RPC configuration
1769
1770
  * @returns Timestamp (Unix timestamp in seconds) when yield was last realized
1770
1771
  */
1771
1772
  async function getYieldLastRealizedOn({ vault, options, }) {
@@ -1822,9 +1823,9 @@ async function getYieldLastRealizedOn({ vault, options, }) {
1822
1823
  * 2. Fetch user's current assets (balanceOf * sharePrice via convertToAssets)
1823
1824
  * 3. Calculate PnL = assets withdrawn + current assets - assets deposited
1824
1825
  *
1825
- * @param vault Vault contract address
1826
- * @param wallet User wallet address
1827
- * @param options RPC configuration and service options
1826
+ * @param vault - Vault contract address
1827
+ * @param wallet - User wallet address
1828
+ * @param options - RPC configuration and service options
1828
1829
  * @returns Lifetime PnL data in both native token and USD
1829
1830
  */
1830
1831
  async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
@@ -2196,8 +2197,8 @@ async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
2196
2197
  * Calculate PnL for a vault (vault-level, not user-specific).
2197
2198
  * Returns the vault's overall profit and loss across all users.
2198
2199
  *
2199
- * @param vault Vault contract address
2200
- * @param options RPC configuration and service options
2200
+ * @param vault - Vault contract address
2201
+ * @param options - RPC configuration and service options
2201
2202
  * @returns Vault PnL in USD and notional value
2202
2203
  */
2203
2204
  async function getVaultPnl({ vault, options, }) {
@@ -2254,7 +2255,7 @@ async function getVaultPnl({ vault, options, }) {
2254
2255
  const dateKey = dayDate.toISOString().split('T')[0];
2255
2256
  // Find matching snapshot for this date
2256
2257
  const snapshot = snapshotsByDate.get(dateKey);
2257
- if (!snapshot || !snapshot.total_shares) {
2258
+ if (!snapshot?.total_shares) {
2258
2259
  core_1.Logger.log.warn('getVaultPnl:snapshotNotFound', `No snapshot found for date ${dateKey}`);
2259
2260
  return;
2260
2261
  }
@@ -2301,9 +2302,9 @@ async function getVaultPnl({ vault, options, }) {
2301
2302
  /*
2302
2303
  * Fetch historical timeseries data for a vault.
2303
2304
  * Returns TVL, APY, PnL, share price, and other metrics over time.
2304
- * @param vault Vault contract address
2305
- * @param nDays Number of days of historical data (default 30, min 1)
2306
- * @param options Request options including headers
2305
+ * @param vault - Vault contract address
2306
+ * @param nDays - Number of days of historical data (default 30, min 1)
2307
+ * @param options - Request options including headers
2307
2308
  * @returns Historical timeseries data with date string keys
2308
2309
  */
2309
2310
  async function getVaultHistoricalTimeseries({ vault, nDays, options, }) {
@@ -2328,8 +2329,8 @@ async function getVaultHistoricalTimeseries({ vault, nDays, options, }) {
2328
2329
  * These fields will be removed on 2026-01-01.
2329
2330
  * Use `liquidAPY30Day` and `liquidAPY7Day` fields instead.
2330
2331
  *
2331
- * @param vault Vault contract address
2332
- * @param options Request options including headers
2332
+ * @param vault - Vault contract address
2333
+ * @param options - Request options including headers
2333
2334
  * @returns Annualized APY data including liquidity APY
2334
2335
  */
2335
2336
  async function getVaultAnnualizedApy({ vault, options, }) {
@@ -2358,8 +2359,8 @@ async function getVaultAnnualizedApy({ vault, options, }) {
2358
2359
  }
2359
2360
  /**
2360
2361
  * Fetch summary data for a vault (name, type, chain, recent returns).
2361
- * @param vault Vault contract address
2362
- * @param options Request options including headers
2362
+ * @param vault - Vault contract address
2363
+ * @param options - Request options including headers
2363
2364
  * @returns Vault summary data
2364
2365
  */
2365
2366
  async function getVaultSummary({ vault, options, }) {
@@ -2389,9 +2390,9 @@ async function getVaultSummary({ vault, options, }) {
2389
2390
  }
2390
2391
  /**
2391
2392
  * Fetch withdrawal summary and pending queue for a vault.
2392
- * @param vault Vault contract address
2393
- * @param chain Chain identifier (e.g., chain ID as string)
2394
- * @param options Request options including headers
2393
+ * @param vault - Vault contract address
2394
+ * @param chain - Chain identifier (e.g., chain ID as string)
2395
+ * @param options - Request options including headers
2395
2396
  * @returns Withdrawal summary and pending queue
2396
2397
  */
2397
2398
  async function getVaultWithdrawals({ vault, chain, options, }) {
@@ -2424,10 +2425,10 @@ async function getVaultWithdrawals({ vault, chain, options, }) {
2424
2425
  }
2425
2426
  /**
2426
2427
  * Fetch pending redemptions for a vault with liquidity analysis.
2427
- * @param vault Vault contract address
2428
- * @param pastDays Number of past days to include (default 7, min 1, max 30)
2429
- * @param futureDays Number of future days to include (default 14, min 1, max 30)
2430
- * @param options Request options including headers
2428
+ * @param vault - Vault contract address
2429
+ * @param pastDays - Number of past days to include (default 7, min 1, max 30)
2430
+ * @param futureDays - Number of future days to include (default 14, min 1, max 30)
2431
+ * @param options - Request options including headers
2431
2432
  * @returns Pending redemptions grouped by date with liquidity summary
2432
2433
  */
2433
2434
  async function getVaultPendingRedemptions({ vault, pastDays, futureDays, options, }) {
@@ -2499,10 +2500,10 @@ async function getVaultPendingRedemptions({ vault, pastDays, futureDays, options
2499
2500
  }
2500
2501
  /**
2501
2502
  * Preview the amount of assets that would be received for redeeming shares (queued redemption).
2502
- * @param vault Vault contract address
2503
- * @param sharesAmount Amount of shares to redeem (human-readable, raw bigint, or string)
2504
- * @param options RPC configuration
2505
- * @returns The amount of assets as INormalizedNumber { normalized, raw }
2503
+ * @param vault - Vault contract address
2504
+ * @param sharesAmount - Amount of shares to redeem (human-readable, raw bigint, or string)
2505
+ * @param options - RPC configuration
2506
+ * @returns The amount of assets as an INormalizedNumber with `normalized` and `raw` fields
2506
2507
  */
2507
2508
  async function getPreviewRedemption({ vault, sharesAmount, options, }) {
2508
2509
  try {
@@ -2599,13 +2600,13 @@ async function decodeProcessingTransaction(txHash, provider, iface) {
2599
2600
  * - `'ready_to_claim'` — Claimable date has passed (within the lookback window) but no processed event found.
2600
2601
  * - `'pending'` — Claimable date is still in the future.
2601
2602
  *
2602
- * @param params - Query parameters
2603
- * @param params.vault - Vault address to query
2604
- * @param params.receiver - (Optional) Filter by receiver address
2605
- * @param params.lookbackBlocks - (Optional) On-chain log lookback window in blocks.
2606
- * Defaults to a chain-specific value (e.g. 150,000 for Ethereum, 3,456,000 for Monad).
2607
- * Increasing this scans more history but requires more RPC calls.
2608
- * @param params.options - Standard vault query options (provider, RPC URL, etc.)
2603
+ * @param params - Query parameters:
2604
+ * - `vault` Vault address to query.
2605
+ * - `receiver` (Optional) Filter by receiver address.
2606
+ * - `lookbackBlocks` (Optional) On-chain log lookback window in blocks.
2607
+ * Defaults to a chain-specific value (e.g. 150,000 for Ethereum, 3,456,000 for Monad).
2608
+ * Increasing this scans more history but requires more RPC calls.
2609
+ * - `options` Standard vault query options (provider, RPC URL, etc.).
2609
2610
  * @returns Array of withdrawal requests with status and claimable dates
2610
2611
  *
2611
2612
  * @example
@@ -71,9 +71,11 @@ const read_actions_1 = require("./read.actions");
71
71
  * Supports both EVM and Solana vaults with unified interface.
72
72
  */
73
73
  class AugustVaults extends core_1.AugustBase {
74
+ solanaService;
75
+ suiService;
76
+ headers = null;
74
77
  constructor(baseConfig, solana, sui) {
75
78
  super(baseConfig);
76
- this.headers = null;
77
79
  this.solanaService = solana;
78
80
  this.suiService = sui || new sui_1.default();
79
81
  this.headers = {
@@ -1,5 +1,5 @@
1
- import { IAddress, IContractRunner, INormalizedNumber } from '../../types';
2
- import { IContractWriteOptions } from './write.actions';
1
+ import type { IAddress, IContractRunner, INormalizedNumber } from '../../types';
2
+ import type { IContractWriteOptions } from './write.actions';
3
3
  /**
4
4
  * Function to fetch instant redemption fee
5
5
  * @param signer - signer / provider object
@@ -4,7 +4,7 @@
4
4
  * Decodes transaction calldata to extract which (year, month, day) cluster
5
5
  * was processed when a WithdrawalProcessed event was emitted.
6
6
  */
7
- import { ContractTransactionReceipt, Interface } from 'ethers';
7
+ import type { ContractTransactionReceipt, Interface } from 'ethers';
8
8
  export interface ProcessingCallData {
9
9
  functionName: 'processAllClaimsByDate' | 'claim' | 'unknown';
10
10
  year: number;
@@ -16,9 +16,18 @@ export declare function walletClientToSigner(walletClient: WalletClient): Promis
16
16
  */
17
17
  export declare const getRewardMultiplierByTimestamp: (foundPool: IVault, timestamp?: number) => number;
18
18
  /**
19
- * Get the rewards for the vault
20
- * @param tokenizedVault - The tokenized vault
21
- * @returns The rewards
19
+ * Get the rewards for the vault.
20
+ *
21
+ * Builds the display-facing rewards summary from the raw tokenized-vault
22
+ * rewards array. In addition to the legacy `additionalPoints` string list, it
23
+ * emits `additionalPointsDetailed`, which pairs each label with its
24
+ * backend-provided `img_url`. Consumers (e.g. the Upshift app) resolve a
25
+ * reward's logo from this `imgUrl` first, falling back to a bundled asset only
26
+ * when it is absent — so a newly-added reward with a backend logo (e.g.
27
+ * "Cores") renders its icon without any client-side keyword mapping.
28
+ *
29
+ * @param tokenizedVault - The tokenized vault.
30
+ * @returns The rewards summary, including `additionalPointsDetailed`.
22
31
  */
23
32
  export declare function getVaultRewards(tokenizedVault: ITokenizedVault): {
24
33
  points: string;
@@ -28,6 +37,13 @@ export declare function getVaultRewards(tokenizedVault: ITokenizedVault): {
28
37
  value: number;
29
38
  }[];
30
39
  additionalPoints: string[];
40
+ additionalPointsDetailed: {
41
+ id: string;
42
+ label: string;
43
+ text: string;
44
+ imgUrl: string;
45
+ multiplier: number;
46
+ }[];
31
47
  };
32
48
  /**
33
49
  * Get the idle assets for the vault
@@ -72,9 +72,34 @@ const getRewardMultiplierByTimestamp = (foundPool, timestamp) => {
72
72
  };
73
73
  exports.getRewardMultiplierByTimestamp = getRewardMultiplierByTimestamp;
74
74
  /**
75
- * Get the rewards for the vault
76
- * @param tokenizedVault - The tokenized vault
77
- * @returns The rewards
75
+ * Build the human-readable display label for a single reward.
76
+ *
77
+ * The format is `"{multiplier}x {text}"`, with the multiplier prefix omitted
78
+ * when it equals 1 (e.g. `"2x Cores"`, `" Cores"` when multiplier is 1 — the
79
+ * leading space is preserved to keep `additionalPoints` and the
80
+ * `additionalPointsDetailed` label in lockstep). This is a display string only;
81
+ * consumers that need a stable key should join on the reward's `id`
82
+ * (see {@link IVaultRewardDetail}), not on this label.
83
+ *
84
+ * @param reward - The raw tokenized-vault reward.
85
+ * @returns The display label string.
86
+ */
87
+ function getRewardLabel(reward) {
88
+ return `${reward.multiplier !== 1 ? `${reward.multiplier}x` : ''} ${reward.text}`;
89
+ }
90
+ /**
91
+ * Get the rewards for the vault.
92
+ *
93
+ * Builds the display-facing rewards summary from the raw tokenized-vault
94
+ * rewards array. In addition to the legacy `additionalPoints` string list, it
95
+ * emits `additionalPointsDetailed`, which pairs each label with its
96
+ * backend-provided `img_url`. Consumers (e.g. the Upshift app) resolve a
97
+ * reward's logo from this `imgUrl` first, falling back to a bundled asset only
98
+ * when it is absent — so a newly-added reward with a backend logo (e.g.
99
+ * "Cores") renders its icon without any client-side keyword mapping.
100
+ *
101
+ * @param tokenizedVault - The tokenized vault.
102
+ * @returns The rewards summary, including `additionalPointsDetailed`.
78
103
  */
79
104
  function getVaultRewards(tokenizedVault) {
80
105
  const upshiftPointRewards = tokenizedVault.rewards?.filter((r) => r.text === 'Upshift Points');
@@ -91,7 +116,14 @@ function getVaultRewards(tokenizedVault) {
91
116
  : '',
92
117
  multiplier: latestUpshiftPointMultiplier,
93
118
  multipliers: upshiftPointsMultipliers,
94
- additionalPoints: tokenizedVault.rewards.map((r) => `${r.multiplier !== 1 ? `${r.multiplier}x` : ''} ${r.text}`),
119
+ additionalPoints: tokenizedVault.rewards.map(getRewardLabel),
120
+ additionalPointsDetailed: tokenizedVault.rewards.map((r) => ({
121
+ id: r.id,
122
+ label: getRewardLabel(r),
123
+ text: r.text,
124
+ imgUrl: r.img_url || null,
125
+ multiplier: r.multiplier,
126
+ })),
95
127
  };
96
128
  return rewards;
97
129
  }
@@ -289,6 +321,7 @@ function buildBackendVault(tokenizedVault, overrides) {
289
321
  multiplier: 0,
290
322
  multipliers: [],
291
323
  additionalPoints: [],
324
+ additionalPointsDetailed: [],
292
325
  };
293
326
  return {
294
327
  operator: '0x',
@@ -313,7 +346,7 @@ function buildBackendVault(tokenizedVault, overrides) {
313
346
  reserveTolerance: tokenizedVault.reserve_tolerance || 0,
314
347
  // Vault decimals are derived from the receipt token decimals for non-EVM vaults
315
348
  decimals: overrides.receipt.decimals,
316
- maxSupply: (0, core_1.toNormalizedBn)(1000000000),
349
+ maxSupply: (0, core_1.toNormalizedBn)(1_000_000_000),
317
350
  depositCap: null,
318
351
  apy,
319
352
  rewards,
@@ -498,7 +531,7 @@ async function buildFormattedVault(provider, tokenizedVault, contractCalls) {
498
531
  depositAssets = [...depositAssets, ...extraAssets];
499
532
  totalSupply = contractCalls.totalSupply;
500
533
  (maxSupply =
501
- (0, core_1.toNormalizedBn)(1000000000000)), // @hardcoded: no maxSupply on here
534
+ (0, core_1.toNormalizedBn)(1_000_000_000_000)), // @hardcoded: no maxSupply on here
502
535
  (receipt = {
503
536
  symbol: tokenizedVault.receipt_token_symbol,
504
537
  address: contractCalls.lpTokenAddress,
@@ -90,7 +90,7 @@ function validateAmountPrecision(amount) {
90
90
  }
91
91
  // Tries tx.wait() first (preserves replacement detection & revert checks), then falls back to
92
92
  // provider.waitForTransaction() for RPCs (e.g. Monad) that return malformed pending tx fields.
93
- const SAFE_WAIT_TIMEOUT_MS = 120000;
93
+ const SAFE_WAIT_TIMEOUT_MS = 120_000;
94
94
  /** @internal */
95
95
  function isNonceParsing(error) {
96
96
  const code = error?.code;
@@ -1040,6 +1040,22 @@ async function dispatchViaSwapRouter(args) {
1040
1040
  abi: abis_1.ABI_ERC20,
1041
1041
  });
1042
1042
  const underlyingDecimals = Number(await underlyingErc20.decimals());
1043
+ // The on-chain SwapRouter only authorizes a specific (router, selector) pair
1044
+ // per chain (see SWAP_ROUTER_DEX_AGGREGATOR). Pin the aggregator to that
1045
+ // router's single generic method so the calldata selector is deterministic,
1046
+ // then reject any quote that would not match — otherwise the deposit reverts
1047
+ // on-chain with InvalidRouter() / InvalidNotWhitelisted() after the user has
1048
+ // already paid gas.
1049
+ const aggregator = core_1.SWAP_ROUTER_DEX_AGGREGATOR[args.chainId];
1050
+ if (!aggregator) {
1051
+ throw new core_1.AugustValidationError('INVALID_CHAIN', `vaultDeposit (SwapRouter): no DEX aggregator is configured for chainId ${args.chainId}, but a swap is required because the deposit asset (${args.actualDepositAsset}) differs from the vault's reference asset (${args.underlyingAsset}). Deposit the reference asset directly, or add a SWAP_ROUTER_DEX_AGGREGATOR entry once the router is whitelisted on-chain.`, {
1052
+ context: {
1053
+ chainId: args.chainId,
1054
+ depositAsset: args.actualDepositAsset,
1055
+ underlyingAsset: args.underlyingAsset,
1056
+ },
1057
+ });
1058
+ }
1043
1059
  const quote = await (0, swap_quotes_1.fetchSwapQuote)({
1044
1060
  chainId: args.chainId,
1045
1061
  srcToken: args.actualDepositAsset,
@@ -1049,7 +1065,25 @@ async function dispatchViaSwapRouter(args) {
1049
1065
  amount: amountRaw,
1050
1066
  receiver: args.routerAddress,
1051
1067
  slippageBps: args.slippageBps,
1068
+ contractMethod: aggregator.contractMethod,
1052
1069
  });
1070
+ // Fail closed on off-chain/on-chain config drift: if the aggregator's quote
1071
+ // targets a router or selector the deployed SwapRouter has not whitelisted,
1072
+ // the swapAndDeposit call would revert. Surfacing it here turns a wasted gas
1073
+ // burn into an actionable SDK error.
1074
+ const quotedSelector = quote.payload.slice(0, 10).toLowerCase();
1075
+ if (quote.router.toLowerCase() !== aggregator.router.toLowerCase() ||
1076
+ quotedSelector !== aggregator.selector.toLowerCase()) {
1077
+ throw new core_1.AugustValidationError('INVALID_INPUT', `vaultDeposit (SwapRouter): the aggregator quote (router ${quote.router}, selector ${quotedSelector}) does not match the router whitelisted on chain ${args.chainId} (router ${aggregator.router}, selector ${aggregator.selector}); the on-chain SwapRouter would revert. This signals drift between the SDK's SWAP_ROUTER_DEX_AGGREGATOR and the deployed router's enableRouter config.`, {
1078
+ context: {
1079
+ chainId: args.chainId,
1080
+ quotedRouter: quote.router,
1081
+ quotedSelector,
1082
+ expectedRouter: aggregator.router,
1083
+ expectedSelector: aggregator.selector,
1084
+ },
1085
+ });
1086
+ }
1053
1087
  return swapAndDeposit(args.signer, {
1054
1088
  chainId: args.chainId,
1055
1089
  vault: args.target,
package/lib/polyfills.js CHANGED
@@ -5,8 +5,8 @@ const buffer_1 = require("buffer");
5
5
  if (typeof window !== 'undefined' && !window.Buffer) {
6
6
  window.Buffer = buffer_1.Buffer;
7
7
  }
8
- // @ts-ignore - Node.js global
9
- if (typeof global !== 'undefined' && !global.Buffer) {
10
- global.Buffer = buffer_1.Buffer;
8
+ const globalRef = globalThis;
9
+ if (typeof globalRef !== 'undefined' && !globalRef.Buffer) {
10
+ globalRef.Buffer = buffer_1.Buffer;
11
11
  }
12
12
  //# sourceMappingURL=polyfills.js.map