@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
@@ -10,12 +10,67 @@ const stellar_sdk_1 = require("@stellar/stellar-sdk");
10
10
  const core_1 = require("../../core");
11
11
  const soroban_1 = require("./soroban");
12
12
  const constants_1 = require("./constants");
13
+ /**
14
+ * Best-effort decode of the transaction-level result code (the XDR union
15
+ * discriminant, e.g. `"txBadSeq"`, `"txTooLate"`) from a Soroban
16
+ * `TransactionResult`. Typed `unknown` and probed structurally so it stays
17
+ * robust to RPC/SDK shape drift; returns `undefined` for anything that isn't a
18
+ * decoded union, so callers fall back to the stringified XDR in the message.
19
+ */
20
+ function extractTxResultCode(result) {
21
+ try {
22
+ const decoded = result;
23
+ if (typeof decoded?.result !== 'function')
24
+ return undefined;
25
+ // `|| undefined`: an empty discriminant shares the clean "no code" path.
26
+ return decoded.result().switch().name || undefined;
27
+ }
28
+ catch (e) {
29
+ // Only reached on a malformed / shape-drifted union (the non-union case
30
+ // already returned above). Breadcrumb it so decoder rot stays detectable;
31
+ // the caller still throws with the stringified XDR in the message.
32
+ core_1.Logger.log.warn('extractTxResultCode', { decodeError: String(e) });
33
+ return undefined;
34
+ }
35
+ }
36
+ /**
37
+ * `JSON.stringify` that never throws. A real `xdr.TransactionResult` can hold
38
+ * `bigint` fields (e.g. `feeCharged`), which make `JSON.stringify` throw a
39
+ * `TypeError` — that would escape and replace the `AugustSDKError` this detail
40
+ * is only meant to enrich. Returns `''` on failure so the caller falls back to
41
+ * the status; the decoded `resultCode` still carries the precise reason.
42
+ */
43
+ function safeStringify(value) {
44
+ try {
45
+ return JSON.stringify(value) ?? '';
46
+ }
47
+ catch {
48
+ return '';
49
+ }
50
+ }
13
51
  /**
14
52
  * Submit a signed Soroban transaction and poll until confirmed.
15
53
  *
16
- * @param signedXdr Base64-encoded XDR of the signed transaction
17
- * @param network Stellar network name
18
- * @returns Transaction hash on success
54
+ * @param signedXdr - Base64-encoded XDR of the signed transaction
55
+ * @param network - Stellar network name
56
+ * @returns The transaction hash once the network confirms it as successful
57
+ * @throws {@link AugustTimeoutError} when the transaction is not confirmed
58
+ * within the poll budget (`MAX_POLL_ATTEMPTS`).
59
+ * @throws {@link AugustSDKError} when the RPC rejects the submission or the
60
+ * transaction confirms as failed. Its `context` carries `{ network, status }`
61
+ * plus, when the result XDR decodes, a `resultCode` string holding the
62
+ * transaction-level reason (e.g. `"txBadSeq"`, `"txTooLate"`); `resultCode`
63
+ * is `undefined` when the code cannot be decoded.
64
+ * @example
65
+ * ```ts
66
+ * try {
67
+ * const hash = await submitStellarTransaction(signedXdr, 'mainnet');
68
+ * } catch (err) {
69
+ * if (err instanceof AugustSDKError && err.context?.resultCode === 'txBadSeq') {
70
+ * // stale sequence number — rebuild the transaction and resubmit
71
+ * }
72
+ * }
73
+ * ```
19
74
  */
20
75
  async function submitStellarTransaction(signedXdr, network) {
21
76
  const { rpcUrl, passphrase } = (0, soroban_1.resolveNetworkConfig)(network);
@@ -23,11 +78,13 @@ async function submitStellarTransaction(signedXdr, network) {
23
78
  const tx = stellar_sdk_1.TransactionBuilder.fromXDR(signedXdr, passphrase);
24
79
  const sendResult = await server.sendTransaction(tx);
25
80
  if (sendResult.status === 'ERROR') {
26
- const detail = 'errorResult' in sendResult ? JSON.stringify(sendResult.errorResult) : '';
81
+ const errorResult = 'errorResult' in sendResult ? sendResult.errorResult : undefined;
82
+ const resultCode = extractTxResultCode(errorResult);
83
+ const detail = errorResult ? safeStringify(errorResult) : '';
27
84
  const msg = `Transaction submission failed: ${detail || sendResult.status}`;
28
- core_1.Logger.log.error('submitStellarTransaction', msg, { network });
85
+ core_1.Logger.log.error('submitStellarTransaction', msg, { network, resultCode });
29
86
  throw new core_1.AugustSDKError('UNKNOWN', msg, {
30
- context: { network, status: sendResult.status },
87
+ context: { network, status: sendResult.status, resultCode },
31
88
  });
32
89
  }
33
90
  // Only PENDING (and DUPLICATE) mean the tx was accepted by the RPC.
@@ -66,14 +123,23 @@ async function submitStellarTransaction(signedXdr, network) {
66
123
  if (getResult.status === 'SUCCESS') {
67
124
  return sendResult.hash;
68
125
  }
69
- const failDetail = 'resultXdr' in getResult ? ` (${JSON.stringify(getResult.resultXdr)})` : '';
126
+ const resultXdr = 'resultXdr' in getResult ? getResult.resultXdr : undefined;
127
+ const resultCode = extractTxResultCode(resultXdr);
128
+ const detail = resultXdr ? safeStringify(resultXdr) : '';
129
+ const failDetail = detail ? ` (${detail})` : '';
70
130
  const msg = `Transaction failed: ${getResult.status}${failDetail}`;
71
131
  core_1.Logger.log.error('submitStellarTransaction', msg, {
72
132
  hash: sendResult.hash,
73
133
  network,
134
+ resultCode,
74
135
  });
75
136
  throw new core_1.AugustSDKError('UNKNOWN', msg, {
76
- context: { hash: sendResult.hash, network, status: getResult.status },
137
+ context: {
138
+ hash: sendResult.hash,
139
+ network,
140
+ status: getResult.status,
141
+ resultCode,
142
+ },
77
143
  });
78
144
  }
79
145
  //# sourceMappingURL=submit.js.map
@@ -1,4 +1,4 @@
1
- import { IEmberVault, IFetchEmberVaultsOptions } from './types';
1
+ import type { IEmberVault, IFetchEmberVaultsOptions } from './types';
2
2
  /**
3
3
  * Fetch Ember vaults from API
4
4
  */
@@ -7,7 +7,7 @@ import * as SuiConstants from './constants';
7
7
  import * as SuiGetters from './getters';
8
8
  import * as SuiUtils from './utils';
9
9
  import { transformEmberVaultToIVault, transformEmberVaultsToIVaults } from './transformer';
10
- import { IEmberVault, IFetchEmberVaultsOptions } from './types';
10
+ import type { IEmberVault, IFetchEmberVaultsOptions } from './types';
11
11
  export declare const Sui: {
12
12
  utils: typeof SuiUtils;
13
13
  constants: typeof SuiConstants;
@@ -60,6 +60,8 @@ exports.Sui = {
60
60
  * ```
61
61
  */
62
62
  class SuiAdapter {
63
+ _apiBaseUrl;
64
+ _chainId;
63
65
  constructor(apiBaseUrl = SuiConstants.EMBER_API_BASE_URL, chainId = SuiConstants.SUI_CHAIN_ID) {
64
66
  this._apiBaseUrl = apiBaseUrl;
65
67
  this._chainId = chainId;
@@ -1,5 +1,5 @@
1
- import { IVault } from '../../types';
2
- import { IEmberVault } from './types';
1
+ import type { IVault } from '../../types';
2
+ import type { IEmberVault } from './types';
3
3
  /**
4
4
  * Transform Ember vault to IVault format
5
5
  */
@@ -59,6 +59,7 @@ function transformEmberVaultToIVault(emberVault) {
59
59
  multiplier: 0,
60
60
  multipliers: [],
61
61
  additionalPoints: [],
62
+ additionalPointsDetailed: [],
62
63
  },
63
64
  version: constants_1.EMBER_DEFAULTS.VERSION,
64
65
  description: emberVault.description || '',
@@ -1,4 +1,4 @@
1
- import { IHIstoricalSnapshot } from '../../types';
1
+ import type { IHIstoricalSnapshot } from '../../types';
2
2
  export interface IEmberVault {
3
3
  address: string;
4
4
  id: string;
@@ -13,7 +13,7 @@ function detectRuntime() {
13
13
  return 'browser';
14
14
  }
15
15
  if (typeof process !== 'undefined' &&
16
- !!process.versions?.node &&
16
+ process.versions?.node &&
17
17
  typeof window === 'undefined') {
18
18
  return 'node';
19
19
  }
@@ -1,6 +1,6 @@
1
1
  import type * as Sentry from '@sentry/browser';
2
- import { IEnv } from '../../types';
3
- import { IAnalyticsConfig } from './types';
2
+ import type { IEnv } from '../../types';
3
+ import type { IAnalyticsConfig } from './types';
4
4
  /**
5
5
  * Initialize Sentry with SDK-specific configuration. Idempotent: re-calls
6
6
  * only refresh user identity and the cached API-key hash.
@@ -1,4 +1,4 @@
1
- import { IEnv } from '../../types';
1
+ import type { IEnv } from '../../types';
2
2
  /**
3
3
  * Configuration for SDK analytics/telemetry.
4
4
  * Analytics are enabled by default (opt-out model).
@@ -1,5 +1,5 @@
1
- import { IEnv } from '../../types';
2
- import { IUserIdentity } from './types';
1
+ import type { IEnv } from '../../types';
2
+ import type { IUserIdentity } from './types';
3
3
  /**
4
4
  * Mask an API key, keeping only the last 5 characters visible.
5
5
  * Example: "abcdefghij12345" -> "**********12345"
@@ -95,7 +95,7 @@ function generateFingerprint() {
95
95
  * @returns User identity object
96
96
  */
97
97
  function createUserIdentity(apiKey, walletAddress, environment = 'PROD') {
98
- let domain = undefined;
98
+ let domain;
99
99
  try {
100
100
  if (typeof window !== 'undefined' && window.location) {
101
101
  domain = window.location.hostname;
@@ -3,4 +3,4 @@
3
3
  * Generated during publish from package.json version
4
4
  * This file is gitignored and created at publish time
5
5
  */
6
- export declare const SDK_VERSION = "8.5.0";
6
+ export declare const SDK_VERSION = "8.6.0";
@@ -6,5 +6,5 @@ exports.SDK_VERSION = void 0;
6
6
  * Generated during publish from package.json version
7
7
  * This file is gitignored and created at publish time
8
8
  */
9
- exports.SDK_VERSION = '8.5.0';
9
+ exports.SDK_VERSION = '8.6.0';
10
10
  //# sourceMappingURL=version.js.map
@@ -1,6 +1,6 @@
1
- import { ISolanaConfig, IAddress, IChainId, IEnv, IProvidersConfig, IWSMonitorHeaders } from '../types';
2
- import { IAnalyticsConfig } from './analytics';
3
- import { IVersionCheckConfig } from './version-check';
1
+ import type { ISolanaConfig, IAddress, IChainId, IEnv, IProvidersConfig, IWSMonitorHeaders } from '../types';
2
+ import { type IAnalyticsConfig } from './analytics';
3
+ import { type IVersionCheckConfig } from './version-check';
4
4
  interface IKeys {
5
5
  august?: string;
6
6
  graph?: string;
@@ -38,6 +38,16 @@ function validateAppName(value) {
38
38
  * network switching, and authentication state.
39
39
  */
40
40
  class AugustBase {
41
+ keys;
42
+ monitoring = {
43
+ 'x-user-id': undefined,
44
+ 'x-environment': undefined,
45
+ };
46
+ authorized;
47
+ activeNetwork;
48
+ providers;
49
+ /** Validated app-name slug from the constructor. */
50
+ appName;
41
51
  /**
42
52
  * Initialize base SDK with provider configuration and API keys.
43
53
  * Sets up the first provider as the active network by default.
@@ -46,10 +56,6 @@ class AugustBase {
46
56
  * length range — see {@link IAugustBase.appName}.
47
57
  */
48
58
  constructor({ appName, providers = {}, keys, monitoring, analytics, versionCheck, timeoutMs, }) {
49
- this.monitoring = {
50
- 'x-user-id': undefined,
51
- 'x-environment': undefined,
52
- };
53
59
  // Validate first so the failure mode is a clear, actionable error before
54
60
  // any provider / analytics side effects run.
55
61
  this.appName = validateAppName(appName);
@@ -4,7 +4,7 @@
4
4
  * This file contains configurations for vaults that support deposits with alternative tokens
5
5
  * through wrapper contracts, swap adapters, or native token deposits.
6
6
  */
7
- import { IVaultAdapterConfig, IAddress } from '../../types';
7
+ import type { IVaultAdapterConfig, IAddress } from '../../types';
8
8
  /**
9
9
  * Pool/Vault names for adapter routing
10
10
  */
@@ -70,6 +70,8 @@ export declare const WEBSERVER_ENDPOINTS: {
70
70
  summary: (vaultAddress: IAddress) => string;
71
71
  withdrawals: (chain: string, vaultAddress: IAddress) => string;
72
72
  debank: (vaultAddress: IAddress) => string;
73
+ userHistory: (vaultAddress: IAddress, wallet: IAddress) => string;
74
+ archivedVaults: string;
73
75
  };
74
76
  points: {
75
77
  byUserAddress: (userAddress: IAddress) => string;
@@ -73,6 +73,12 @@ exports.WEBSERVER_ENDPOINTS = {
73
73
  summary: (vaultAddress) => `/tokenized_vault/vault_summary/${(0, ethers_1.getAddress)(vaultAddress)}`,
74
74
  withdrawals: (chain, vaultAddress) => `/withdrawals/${chain}/${(0, ethers_1.getAddress)(vaultAddress)}`,
75
75
  debank: (vaultAddress) => `/tokenized_vault/${(0, ethers_1.getAddress)(vaultAddress)}/debank`,
76
+ // Mongo-backed deposit/withdraw history for archived vaults whose
77
+ // subgraph has been (or will be) retired. See fetchArchivedVaults.
78
+ userHistory: (vaultAddress, wallet) => `/upshift/vault_history/${(0, ethers_1.getAddress)(vaultAddress)}?wallet=${(0, ethers_1.getAddress)(wallet)}`,
79
+ // Vaults whose history is served from the snapshot (source of truth for
80
+ // routing — a vault appears only after its backfill completes).
81
+ archivedVaults: '/upshift/vault_history/archived',
76
82
  },
77
83
  points: {
78
84
  byUserAddress: (userAddress) => `/upshift/points/${(0, ethers_1.getAddress)(userAddress)}`,
@@ -1,4 +1,4 @@
1
- import { IAddress } from '../../types';
1
+ import type { IAddress } from '../../types';
2
2
  /**
3
3
  * Address of the `SwapRouter` periphery contract on each supported chain.
4
4
  *
@@ -52,3 +52,39 @@ export declare const SWAP_ROUTER_MAX_SWAPS = 9;
52
52
  * the contract's `depositNativeToken` / `swapAndDepositNativeToken` accept.
53
53
  */
54
54
  export declare const SWAP_ROUTER_WRAPPED_NATIVE: Readonly<Record<number, IAddress>>;
55
+ /**
56
+ * The DEX aggregator whitelisted on each chain's `SwapRouter` via
57
+ * `enableRouter`, plus the single aggregator contract method every swap leg is
58
+ * pinned to and that method's 4-byte selector.
59
+ *
60
+ * This is the single source of truth tying the off-chain swap-leg builder to
61
+ * the on-chain router whitelist. The two MUST agree or `swapAndDeposit` reverts
62
+ * with `InvalidRouter()` (router not whitelisted) or `InvalidNotWhitelisted()`
63
+ * (selector not authorized). It is consumed in three places:
64
+ *
65
+ * - `dispatchViaSwapRouter` asks {@link fetchSwapQuote} to pin the aggregator to
66
+ * `contractMethod`, then asserts the returned quote's `router` and payload
67
+ * selector match this entry before broadcasting — failing closed rather than
68
+ * letting the user pay gas for a transaction the contract will reject.
69
+ * - The CI check `scripts/verify-swap-router-aggregator.mjs` asserts the
70
+ * deployed `SwapRouter` actually has `tokenTransferProxies[router] != 0` and
71
+ * `isAuthorizedSelector(router, selector) == true` for every entry here, so
72
+ * config drift is caught at release time, not by a user's failed deposit.
73
+ *
74
+ * Pinning to one generic method matters: the aggregator otherwise picks a route
75
+ * method per quote (e.g. a direct `swapExactAmountInOnUniswapV3`) that varies
76
+ * with market conditions, producing a different selector each time. Pinning
77
+ * collapses that to one stable selector so the on-chain whitelist needs only
78
+ * that selector and never drifts as routing changes.
79
+ *
80
+ * `router` is the address the aggregator's calldata targets (ParaSwap v6.2
81
+ * pulls tokens to the Augustus contract itself, so the SwapRouter's
82
+ * `tokenTransferProxies[router]` is the router address). `selector` is
83
+ * `bytes4(keccak256("<contractMethod>(...)"))`. Verify both against the
84
+ * deployed router before adding a chain — a wrong value reverts at deposit time.
85
+ */
86
+ export declare const SWAP_ROUTER_DEX_AGGREGATOR: Readonly<Record<number, {
87
+ router: IAddress;
88
+ contractMethod: string;
89
+ selector: `0x${string}`;
90
+ }>>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SWAP_ROUTER_WRAPPED_NATIVE = exports.SWAP_ROUTER_MAX_SWAPS = exports.ORIGIN_CODES = exports.VAULTS_USING_SWAP_ROUTER = exports.SWAP_ROUTER_ADDRESSES = void 0;
3
+ exports.SWAP_ROUTER_DEX_AGGREGATOR = exports.SWAP_ROUTER_WRAPPED_NATIVE = exports.SWAP_ROUTER_MAX_SWAPS = exports.ORIGIN_CODES = exports.VAULTS_USING_SWAP_ROUTER = exports.SWAP_ROUTER_ADDRESSES = void 0;
4
4
  /**
5
5
  * Address of the `SwapRouter` periphery contract on each supported chain.
6
6
  *
@@ -65,4 +65,44 @@ exports.SWAP_ROUTER_MAX_SWAPS = 9;
65
65
  exports.SWAP_ROUTER_WRAPPED_NATIVE = {
66
66
  1: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
67
67
  };
68
+ /**
69
+ * The DEX aggregator whitelisted on each chain's `SwapRouter` via
70
+ * `enableRouter`, plus the single aggregator contract method every swap leg is
71
+ * pinned to and that method's 4-byte selector.
72
+ *
73
+ * This is the single source of truth tying the off-chain swap-leg builder to
74
+ * the on-chain router whitelist. The two MUST agree or `swapAndDeposit` reverts
75
+ * with `InvalidRouter()` (router not whitelisted) or `InvalidNotWhitelisted()`
76
+ * (selector not authorized). It is consumed in three places:
77
+ *
78
+ * - `dispatchViaSwapRouter` asks {@link fetchSwapQuote} to pin the aggregator to
79
+ * `contractMethod`, then asserts the returned quote's `router` and payload
80
+ * selector match this entry before broadcasting — failing closed rather than
81
+ * letting the user pay gas for a transaction the contract will reject.
82
+ * - The CI check `scripts/verify-swap-router-aggregator.mjs` asserts the
83
+ * deployed `SwapRouter` actually has `tokenTransferProxies[router] != 0` and
84
+ * `isAuthorizedSelector(router, selector) == true` for every entry here, so
85
+ * config drift is caught at release time, not by a user's failed deposit.
86
+ *
87
+ * Pinning to one generic method matters: the aggregator otherwise picks a route
88
+ * method per quote (e.g. a direct `swapExactAmountInOnUniswapV3`) that varies
89
+ * with market conditions, producing a different selector each time. Pinning
90
+ * collapses that to one stable selector so the on-chain whitelist needs only
91
+ * that selector and never drifts as routing changes.
92
+ *
93
+ * `router` is the address the aggregator's calldata targets (ParaSwap v6.2
94
+ * pulls tokens to the Augustus contract itself, so the SwapRouter's
95
+ * `tokenTransferProxies[router]` is the router address). `selector` is
96
+ * `bytes4(keccak256("<contractMethod>(...)"))`. Verify both against the
97
+ * deployed router before adding a chain — a wrong value reverts at deposit time.
98
+ */
99
+ exports.SWAP_ROUTER_DEX_AGGREGATOR = {
100
+ // ParaSwap AugustusV6.2 (Velora). `swapExactAmountIn` is the generic
101
+ // executor method; its selector is 0xe3ead59e.
102
+ 1: {
103
+ router: '0x6A000F20005980200259B80c5102003040001068',
104
+ contractMethod: 'swapExactAmountIn',
105
+ selector: '0xe3ead59e',
106
+ },
107
+ };
68
108
  //# sourceMappingURL=swap-router.js.map
@@ -1,4 +1,4 @@
1
- import { IAddress, IPoolFunctions } from '../../types';
1
+ import type { IAddress, IPoolFunctions } from '../../types';
2
2
  /**
3
3
  * Table of Contents
4
4
  * - Hardcoded Addresses
@@ -1,4 +1,4 @@
1
- import { IChainId, IChainObj } from '../../types';
1
+ import type { IChainId, IChainObj } from '../../types';
2
2
  export declare const SPECIAL_CHAINS: {
3
3
  solana: {
4
4
  name: string;
@@ -145,8 +145,5 @@ exports.FALLBACK_RPC_URLS = {
145
145
  747474: ['https://rpc.katana.network'],
146
146
  4114: ['https://rpc.mainnet.citrea.xyz'],
147
147
  25363: ['https://rpc.fluent.xyz'],
148
- // [-1]: [
149
- // "https://devnet.helius-rpc.com/?api-key=5f652958-74ed-42e4-a874-0ac8056ac02c"
150
- // ]
151
148
  };
152
149
  //# sourceMappingURL=web3.js.map
@@ -15,7 +15,7 @@
15
15
  * ```
16
16
  */
17
17
  /** Stable error codes attached to SDK errors. */
18
- export type AugustErrorCode = 'AUTH_MISSING_KEY' | 'AUTH_INVALID_KEY' | 'AUTH_FORBIDDEN' | 'AUTH_UNAUTHORIZED' | 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS' | 'NETWORK_ERROR' | 'TIMEOUT' | 'RATE_LIMITED' | 'SERVER_ERROR' | 'UNKNOWN';
18
+ export type AugustErrorCode = 'AUTH_MISSING_KEY' | 'AUTH_INVALID_KEY' | 'AUTH_FORBIDDEN' | 'AUTH_UNAUTHORIZED' | 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS' | 'ACCOUNT_NOT_FUNDED' | 'NETWORK_ERROR' | 'TIMEOUT' | 'RATE_LIMITED' | 'SERVER_ERROR' | 'UNKNOWN';
19
19
  /** Options accepted by every SDK error constructor. */
20
20
  export interface AugustErrorOptions {
21
21
  /** Original error preserved for stack-trace chaining. */
@@ -54,7 +54,7 @@ export declare class AugustTimeoutError extends AugustSDKError {
54
54
  }
55
55
  /** Caller-side input failed validation. */
56
56
  export declare class AugustValidationError extends AugustSDKError {
57
- constructor(code: Extract<AugustErrorCode, 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS'>, message: string, options?: AugustErrorOptions);
57
+ constructor(code: Extract<AugustErrorCode, 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS' | 'ACCOUNT_NOT_FUNDED'>, message: string, options?: AugustErrorOptions);
58
58
  }
59
59
  /** Backend rate-limited the request (HTTP 429 or equivalent). */
60
60
  export declare class AugustRateLimitError extends AugustSDKError {
@@ -20,6 +20,9 @@ exports.AugustServerError = exports.AugustRateLimitError = exports.AugustValidat
20
20
  exports.isAugustSDKError = isAugustSDKError;
21
21
  /** Base class for all SDK errors. */
22
22
  class AugustSDKError extends Error {
23
+ code;
24
+ correlationId;
25
+ context;
23
26
  constructor(code, message, options = {}) {
24
27
  super(message);
25
28
  this.name = 'AugustSDKError';
@@ -77,6 +80,8 @@ class AugustNetworkError extends AugustSDKError {
77
80
  exports.AugustNetworkError = AugustNetworkError;
78
81
  /** Request exceeded its deadline. */
79
82
  class AugustTimeoutError extends AugustSDKError {
83
+ /** Time elapsed (ms) before the request was aborted. */
84
+ timeoutMs;
80
85
  constructor(message, timeoutMs, options) {
81
86
  super('TIMEOUT', message, options);
82
87
  this.name = 'AugustTimeoutError';
@@ -97,6 +102,8 @@ class AugustValidationError extends AugustSDKError {
97
102
  exports.AugustValidationError = AugustValidationError;
98
103
  /** Backend rate-limited the request (HTTP 429 or equivalent). */
99
104
  class AugustRateLimitError extends AugustSDKError {
105
+ /** Suggested wait before retrying, in milliseconds. */
106
+ retryAfterMs;
100
107
  constructor(message, options) {
101
108
  super('RATE_LIMITED', message, options);
102
109
  this.name = 'AugustRateLimitError';
@@ -112,6 +119,8 @@ class AugustRateLimitError extends AugustSDKError {
112
119
  exports.AugustRateLimitError = AugustRateLimitError;
113
120
  /** Backend returned a non-OK status that isn't auth, rate-limit, or timeout. */
114
121
  class AugustServerError extends AugustSDKError {
122
+ /** HTTP status code returned by the backend. */
123
+ status;
115
124
  constructor(status, message, options) {
116
125
  super('SERVER_ERROR', message, options);
117
126
  this.name = 'AugustServerError';