@augustdigital/sdk 8.12.0 → 8.13.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.
@@ -2,12 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.vaultUsesSwapRouter = void 0;
4
4
  exports.getSwapRouterAddress = getSwapRouterAddress;
5
+ exports.getSwapRouterName = getSwapRouterName;
5
6
  exports.isSwapRouterEligible = isSwapRouterEligible;
6
7
  exports.resolveOriginCode = resolveOriginCode;
7
8
  exports.getSwapRouterDepositResult = getSwapRouterDepositResult;
9
+ exports.getSwapRouterWhitelistedTokens = getSwapRouterWhitelistedTokens;
10
+ exports.getSwapRouterEligibleVaults = getSwapRouterEligibleVaults;
8
11
  const ethers_1 = require("ethers");
9
12
  const swap_router_1 = require("../constants/swap-router");
13
+ const abis_1 = require("../../abis");
10
14
  const errors_1 = require("../errors");
15
+ const cache_1 = require("../cache");
16
+ const logger_1 = require("../logger");
17
+ const web3_1 = require("./web3");
18
+ const multicall_1 = require("./multicall");
11
19
  /**
12
20
  * Resolve the `SwapRouter` address for a chain.
13
21
  *
@@ -22,6 +30,28 @@ const errors_1 = require("../errors");
22
30
  function getSwapRouterAddress(chainId) {
23
31
  return swap_router_1.SWAP_ROUTER_ADDRESSES[chainId];
24
32
  }
33
+ /**
34
+ * Resolve the human-readable display name of the `SwapRouter` periphery
35
+ * contract for a chain.
36
+ *
37
+ * The contract exposes no name on-chain, so this reads the SDK-maintained
38
+ * {@link SWAP_ROUTER_NAMES} registry. Intended for UI surfaces that label the
39
+ * contract a swap-and-deposit routes through (e.g. a "Router" row in a
40
+ * transaction overview) — display metadata only, never routing logic.
41
+ *
42
+ * @param chainId - EVM chain ID.
43
+ * @returns The display name (e.g. `'Upshift Swap Router'`), or `undefined`
44
+ * when no SwapRouter is deployed on the chain — callers should omit the
45
+ * label rather than show an address.
46
+ * @example
47
+ * ```ts
48
+ * const name = getSwapRouterName(1);
49
+ * // 'Upshift Swap Router'
50
+ * ```
51
+ */
52
+ function getSwapRouterName(chainId) {
53
+ return swap_router_1.SWAP_ROUTER_NAMES[chainId];
54
+ }
25
55
  /**
26
56
  * Whether a vault is eligible for the any-token `SwapRouter` deposit surface
27
57
  * (the SwapRouter is `enableVault`-ed for it on-chain). Address comparison is
@@ -33,15 +63,22 @@ function getSwapRouterAddress(chainId) {
33
63
  *
34
64
  * @param vaultAddress - August vault address.
35
65
  * @returns `true` when the vault is in {@link SWAP_ROUTER_ELIGIBLE_VAULTS}.
66
+ * @deprecated Superseded by {@link getSwapRouterEligibleVaults}, which resolves
67
+ * eligibility from the router's on-chain `VaultEnabled` history + current
68
+ * `vaultInfo` registration instead of this static snapshot. Kept functional as
69
+ * the zero-RPC sync fallback (seed data, fail-fast checks); migrate UI gates
70
+ * to the async resolver.
36
71
  */
37
72
  function isSwapRouterEligible(vaultAddress) {
38
73
  return swap_router_1.SWAP_ROUTER_ELIGIBLE_VAULTS.has(vaultAddress.toLowerCase());
39
74
  }
40
75
  /**
41
- * @deprecated Renamed to {@link isSwapRouterEligible}. The meaning also changed:
42
- * it no longer implies `vaultDeposit` routes the vault through the SwapRouter
43
- * (that behavior was removed) it only reports swap-router *eligibility* for
44
- * the opt-in deposit surface. Kept as an alias for one release.
76
+ * @deprecated Renamed to {@link isSwapRouterEligible} (itself now superseded by
77
+ * {@link getSwapRouterEligibleVaults}, the on-chain-derived resolver). The
78
+ * meaning also changed: it no longer implies `vaultDeposit` routes the vault
79
+ * through the SwapRouter (that behavior was removed) it only reports
80
+ * swap-router *eligibility* for the opt-in deposit surface. Kept as an alias
81
+ * for one release; migrate to the async resolver.
45
82
  */
46
83
  exports.vaultUsesSwapRouter = isSwapRouterEligible;
47
84
  /**
@@ -144,4 +181,300 @@ async function getSwapRouterDepositResult(signer, { txHash, vault }) {
144
181
  }
145
182
  return null;
146
183
  }
184
+ /** Cache TTL for a chain's resolved SwapRouter token allowlist (5 minutes). */
185
+ const SWAP_ROUTER_WHITELIST_TTL_MS = 5 * 60 * 1000;
186
+ /**
187
+ * Resolve the ERC-20 tokens currently whitelisted for the `SwapRouter` on a
188
+ * chain — the any-token set a UI can offer as swap-and-deposit inputs.
189
+ *
190
+ * The router exposes its allowlist only as `mapping(address => bool)
191
+ * whitelistedTokens` with **no on-chain enumeration**, so this cannot be a
192
+ * single view call. It runs in two stages:
193
+ * 1. Scan the router's `TokenEnabled(address)` event history (from the chain's
194
+ * {@link SWAP_ROUTER_DEPLOY_BLOCKS} floor, in `eth_getLogs` chunks sized by
195
+ * {@link determineBlockSkipInternal}) to reconstruct the candidate set of
196
+ * every token ever enabled.
197
+ * 2. Re-read `whitelistedTokens(token)` for each candidate — batched via
198
+ * Multicall3 where verified, else per-call — and keep only those the
199
+ * mapping currently returns `true` for. This step makes later disables (and
200
+ * disable-then-re-enable) correct without replaying `TokenDisabled`, and is
201
+ * the fail-closed source of truth: a token surfaces only on a definite
202
+ * on-chain `true`.
203
+ *
204
+ * The resolved list is cached per chain for 5 minutes — the allowlist changes
205
+ * only via an admin `enableToken`/`disableToken` transaction, so a short TTL
206
+ * keeps the (multi-RPC) scan off the hot path without going stale for long.
207
+ *
208
+ * @param chainId - EVM chain ID. Chains without a {@link SWAP_ROUTER_ADDRESSES}
209
+ * entry resolve to `[]` with no RPC.
210
+ * @param options - `rpcUrl` (required) must point at `chainId`'s network;
211
+ * `fromBlock` overrides the default deploy-block scan floor (e.g. to widen a
212
+ * scan on a chain missing from {@link SWAP_ROUTER_DEPLOY_BLOCKS}).
213
+ * @returns Checksummed addresses of the currently-whitelisted tokens, deduped.
214
+ * Empty when no router is deployed or none are enabled. Callers still filter
215
+ * out a given vault's natively-accepted assets (those deposit without a swap).
216
+ * @throws AugustValidationError when `rpcUrl` is missing/empty.
217
+ * @throws AugustSDKError when an `eth_getLogs` chunk fails — surfaced (not
218
+ * swallowed) so a partial scan never masquerades as a complete allowlist.
219
+ * @worstCaseRpcCalls On mainnet, 1 `eth_blockNumber` + ~4 `eth_getLogs` chunks
220
+ * (router-lifetime ÷ 50k-block window) + 1 Multicall3 `eth_call` ≈ 6; scales
221
+ * with the router's on-chain age, not with candidate count.
222
+ * @example
223
+ * ```ts
224
+ * const tokens = await getSwapRouterWhitelistedTokens(1, {
225
+ * rpcUrl: 'https://eth-mainnet.example/v2/KEY',
226
+ * });
227
+ * // ['0xA0b8…', '0xdAC1…', '0xC02a…', '0x2260…'] (USDC, USDT, WETH, WBTC)
228
+ * ```
229
+ */
230
+ async function getSwapRouterWhitelistedTokens(chainId, options) {
231
+ const router = getSwapRouterAddress(chainId);
232
+ if (!router)
233
+ return [];
234
+ const cacheKey = `swap-router-whitelisted-tokens-${chainId}-${router.toLowerCase()}`;
235
+ const cached = await (0, cache_1.getSafeCache)(cacheKey);
236
+ if (cached)
237
+ return cached;
238
+ const provider = (0, web3_1.createProvider)(options.rpcUrl, chainId);
239
+ const contract = (0, web3_1.createContract)({
240
+ address: router,
241
+ provider,
242
+ abi: abis_1.ABI_SWAP_ROUTER,
243
+ });
244
+ if (!contract)
245
+ return [];
246
+ // Stage 1 — reconstruct the candidate set from TokenEnabled logs, scanning
247
+ // the router's lifetime in chunks to respect per-request eth_getLogs limits.
248
+ const currentBlock = await provider.getBlockNumber();
249
+ const fromBlock = Math.max(0, options.fromBlock ?? swap_router_1.SWAP_ROUTER_DEPLOY_BLOCKS[chainId] ?? 0);
250
+ const blockSkip = (0, web3_1.determineBlockSkipInternal)(chainId);
251
+ const ranges = [];
252
+ for (let end = currentBlock; end >= fromBlock; end -= blockSkip + 1) {
253
+ ranges.push({ from: Math.max(end - blockSkip, fromBlock), to: end });
254
+ }
255
+ const settled = await Promise.allSettled(ranges.map((r) => contract.queryFilter('TokenEnabled', BigInt(r.from), BigInt(r.to))));
256
+ const failed = settled.find((s) => s.status === 'rejected');
257
+ if (failed) {
258
+ const reason = failed.reason instanceof Error
259
+ ? failed.reason.message
260
+ : String(failed.reason);
261
+ throw new errors_1.AugustSDKError('NETWORK_ERROR', `getSwapRouterWhitelistedTokens: TokenEnabled log scan failed on chain ${chainId}: ${reason}`);
262
+ }
263
+ const candidates = new Set();
264
+ for (const s of settled) {
265
+ if (s.status !== 'fulfilled')
266
+ continue;
267
+ for (const log of s.value) {
268
+ const raw = log.args?.tokenAddr;
269
+ if (typeof raw === 'string' && (0, ethers_1.isAddress)(raw)) {
270
+ candidates.add((0, ethers_1.getAddress)(raw));
271
+ }
272
+ }
273
+ }
274
+ if (candidates.size === 0) {
275
+ cache_1.CACHE.set(cacheKey, [], { ttl: SWAP_ROUTER_WHITELIST_TTL_MS });
276
+ return [];
277
+ }
278
+ // Stage 2 — keep only tokens the mapping currently reports as whitelisted.
279
+ const list = [...candidates];
280
+ let enabled;
281
+ if ((0, multicall_1.isMulticall3Supported)(chainId)) {
282
+ const calls = list.map((token) => ({
283
+ target: router,
284
+ abi: abis_1.ABI_SWAP_ROUTER,
285
+ functionName: 'whitelistedTokens',
286
+ args: [token],
287
+ }));
288
+ const results = await (0, multicall_1.multicall3Aggregate)(provider, chainId, calls);
289
+ enabled = list.filter((_, i) => results[i]?.success && results[i]?.value === true);
290
+ }
291
+ else {
292
+ const bools = await Promise.all(list.map(async (token) => {
293
+ try {
294
+ return (await contract.whitelistedTokens(token));
295
+ }
296
+ catch (e) {
297
+ logger_1.Logger.log.warn('getSwapRouterWhitelistedTokens', `whitelistedTokens(${token}) read failed — omitting`, e);
298
+ return false;
299
+ }
300
+ }));
301
+ enabled = list.filter((_, i) => bools[i] === true);
302
+ }
303
+ cache_1.CACHE.set(cacheKey, enabled, { ttl: SWAP_ROUTER_WHITELIST_TTL_MS });
304
+ return enabled;
305
+ }
306
+ /** Cache TTL for a chain's resolved SwapRouter eligible-vault set (5 minutes). */
307
+ const SWAP_ROUTER_ELIGIBLE_VAULTS_TTL_MS = 5 * 60 * 1000;
308
+ /**
309
+ * Minimal `vaultInfo` fragment declaring the four static outputs as a single
310
+ * named tuple. The ABI encoding of `(uint256,uint8,address,address)` returned
311
+ * as four values is byte-identical to the same four static types returned as
312
+ * one tuple, and {@link multicall3Aggregate} surfaces only the FIRST decoded
313
+ * output — so decoding against this fragment makes that first output the whole
314
+ * struct, giving batched access to `referenceAsset` (the registration marker)
315
+ * without changing the shared multicall helper.
316
+ */
317
+ const ABI_SWAP_ROUTER_VAULT_INFO_TUPLE = [
318
+ {
319
+ inputs: [{ internalType: 'address', name: '', type: 'address' }],
320
+ name: 'vaultInfo',
321
+ outputs: [
322
+ {
323
+ components: [
324
+ { internalType: 'uint256', name: 'swapFee', type: 'uint256' },
325
+ { internalType: 'uint8', name: 'vaultType', type: 'uint8' },
326
+ { internalType: 'address', name: 'referenceAsset', type: 'address' },
327
+ { internalType: 'address', name: 'lpTokenAddress', type: 'address' },
328
+ ],
329
+ internalType: 'struct SwapRouter.VaultInfo',
330
+ name: 'info',
331
+ type: 'tuple',
332
+ },
333
+ ],
334
+ stateMutability: 'view',
335
+ type: 'function',
336
+ },
337
+ ];
338
+ /**
339
+ * Extract `referenceAsset` from a decoded `vaultInfo` result (ethers `Result`
340
+ * proxies expose named tuple components as properties). Returns `undefined`
341
+ * for anything that doesn't carry a string `referenceAsset` — treated as
342
+ * unregistered by the caller (fail-closed).
343
+ */
344
+ function referenceAssetOf(value) {
345
+ const ref = value
346
+ ?.referenceAsset;
347
+ return typeof ref === 'string' ? ref : undefined;
348
+ }
349
+ /**
350
+ * Resolve the vaults currently eligible for the any-token `SwapRouter` deposit
351
+ * surface on a chain — i.e. every vault the router has `enableVault`-ed that is
352
+ * still registered on-chain.
353
+ *
354
+ * The router stores registrations as `mapping(address => VaultInfo) vaultInfo`
355
+ * with **no on-chain enumeration**, so (exactly like
356
+ * {@link getSwapRouterWhitelistedTokens}) this runs in two stages:
357
+ * 1. Scan the router's `VaultEnabled(address)` event history (from the chain's
358
+ * {@link SWAP_ROUTER_DEPLOY_BLOCKS} floor, in `eth_getLogs` chunks sized by
359
+ * {@link determineBlockSkipInternal}) to reconstruct the candidate set of
360
+ * every vault ever enabled.
361
+ * 2. Re-read `vaultInfo(vault)` for each candidate — batched via Multicall3
362
+ * where verified, else per-call — and keep only those whose
363
+ * `referenceAsset != address(0)` (an unregistered vault reverts with
364
+ * `InvalidVault` at deposit time). This makes later disables correct
365
+ * without replaying `VaultDisabled`, and is the fail-closed source of
366
+ * truth: a vault surfaces only on a definite on-chain registration.
367
+ *
368
+ * This is the dynamic successor to the static
369
+ * {@link SWAP_ROUTER_ELIGIBLE_VAULTS} snapshot / {@link isSwapRouterEligible}.
370
+ * It reports **on-chain eligibility only** — app-level policy (e.g. excluding
371
+ * OVault-enabled vaults that have their own deposit flow) remains the caller's
372
+ * responsibility, as does the flag gating of the UI surface.
373
+ *
374
+ * The resolved list is cached per chain for 5 minutes — registrations change
375
+ * only via an admin `enableVault`/`disableVault` transaction, so a short TTL
376
+ * keeps the (multi-RPC) scan off the hot path without going stale for long.
377
+ *
378
+ * @param chainId - EVM chain ID. Chains without a {@link SWAP_ROUTER_ADDRESSES}
379
+ * entry resolve to `[]` with no RPC.
380
+ * @param options - `rpcUrl` (required) must point at `chainId`'s network;
381
+ * `fromBlock` overrides the default deploy-block scan floor.
382
+ * @returns Checksummed addresses of the currently-registered eligible vaults,
383
+ * deduped. Empty when no router is deployed or none are registered.
384
+ * @throws AugustValidationError when `rpcUrl` is missing/empty.
385
+ * @throws AugustSDKError when an `eth_getLogs` chunk fails — surfaced (not
386
+ * swallowed) so a partial scan never masquerades as the complete set.
387
+ * @worstCaseRpcCalls On mainnet, 1 `eth_blockNumber` + ~4 `eth_getLogs` chunks
388
+ * (router-lifetime ÷ 50k-block window) + 1 Multicall3 `eth_call` ≈ 6; scales
389
+ * with the router's on-chain age, not with candidate count.
390
+ * @example
391
+ * ```ts
392
+ * const vaults = await getSwapRouterEligibleVaults(1, {
393
+ * rpcUrl: 'https://eth-mainnet.example/v2/KEY',
394
+ * });
395
+ * // ['0x74aD…718b', '0xE9B7…9D32'] (Sentora USD, Upshift Core USDC)
396
+ * ```
397
+ */
398
+ async function getSwapRouterEligibleVaults(chainId, options) {
399
+ const router = getSwapRouterAddress(chainId);
400
+ if (!router)
401
+ return [];
402
+ const cacheKey = `swap-router-eligible-vaults-${chainId}-${router.toLowerCase()}`;
403
+ const cached = await (0, cache_1.getSafeCache)(cacheKey);
404
+ if (cached)
405
+ return cached;
406
+ const provider = (0, web3_1.createProvider)(options.rpcUrl, chainId);
407
+ const contract = (0, web3_1.createContract)({
408
+ address: router,
409
+ provider,
410
+ abi: abis_1.ABI_SWAP_ROUTER,
411
+ });
412
+ if (!contract)
413
+ return [];
414
+ // Stage 1 — reconstruct the candidate set from VaultEnabled logs, scanning
415
+ // the router's lifetime in chunks to respect per-request eth_getLogs limits.
416
+ const currentBlock = await provider.getBlockNumber();
417
+ const fromBlock = Math.max(0, options.fromBlock ?? swap_router_1.SWAP_ROUTER_DEPLOY_BLOCKS[chainId] ?? 0);
418
+ const blockSkip = (0, web3_1.determineBlockSkipInternal)(chainId);
419
+ const ranges = [];
420
+ for (let end = currentBlock; end >= fromBlock; end -= blockSkip + 1) {
421
+ ranges.push({ from: Math.max(end - blockSkip, fromBlock), to: end });
422
+ }
423
+ const settled = await Promise.allSettled(ranges.map((r) => contract.queryFilter('VaultEnabled', BigInt(r.from), BigInt(r.to))));
424
+ const failed = settled.find((s) => s.status === 'rejected');
425
+ if (failed) {
426
+ const reason = failed.reason instanceof Error
427
+ ? failed.reason.message
428
+ : String(failed.reason);
429
+ throw new errors_1.AugustSDKError('NETWORK_ERROR', `getSwapRouterEligibleVaults: VaultEnabled log scan failed on chain ${chainId}: ${reason}`);
430
+ }
431
+ const candidates = new Set();
432
+ for (const s of settled) {
433
+ if (s.status !== 'fulfilled')
434
+ continue;
435
+ for (const log of s.value) {
436
+ const raw = log.args?.vaultAddr;
437
+ if (typeof raw === 'string' && (0, ethers_1.isAddress)(raw)) {
438
+ candidates.add((0, ethers_1.getAddress)(raw));
439
+ }
440
+ }
441
+ }
442
+ if (candidates.size === 0) {
443
+ cache_1.CACHE.set(cacheKey, [], { ttl: SWAP_ROUTER_ELIGIBLE_VAULTS_TTL_MS });
444
+ return [];
445
+ }
446
+ // Stage 2 — keep only vaults whose current on-chain registration is live
447
+ // (referenceAsset set). Fail-closed: unreadable/zero → excluded.
448
+ const list = [...candidates];
449
+ let registered;
450
+ if ((0, multicall_1.isMulticall3Supported)(chainId)) {
451
+ const calls = list.map((vault) => ({
452
+ target: router,
453
+ abi: ABI_SWAP_ROUTER_VAULT_INFO_TUPLE,
454
+ functionName: 'vaultInfo',
455
+ args: [vault],
456
+ }));
457
+ const results = await (0, multicall_1.multicall3Aggregate)(provider, chainId, calls);
458
+ registered = list.filter((_, i) => {
459
+ if (!results[i]?.success)
460
+ return false;
461
+ const ref = referenceAssetOf(results[i]?.value);
462
+ return !!ref && ref !== ethers_1.ethers.ZeroAddress;
463
+ });
464
+ }
465
+ else {
466
+ const refs = await Promise.all(list.map(async (vault) => {
467
+ try {
468
+ return referenceAssetOf(await contract.vaultInfo(vault));
469
+ }
470
+ catch (e) {
471
+ logger_1.Logger.log.warn('getSwapRouterEligibleVaults', `vaultInfo(${vault}) read failed — omitting`, e);
472
+ return undefined;
473
+ }
474
+ }));
475
+ registered = list.filter((_, i) => !!refs[i] && refs[i] !== ethers_1.ethers.ZeroAddress);
476
+ }
477
+ cache_1.CACHE.set(cacheKey, registered, { ttl: SWAP_ROUTER_ELIGIBLE_VAULTS_TTL_MS });
478
+ return registered;
479
+ }
147
480
  //# sourceMappingURL=swap-router.js.map
@@ -1,6 +1,21 @@
1
1
  import type { ITokenizedVault, IVaultVersion, ChainType } from '../../types';
2
2
  /** Classify an address by chain family (evm / solana / stellar / sui). */
3
3
  export declare function getAddressChainType(address: string): ChainType;
4
+ /**
5
+ * Classify a vault's protocol version from its address alone.
6
+ *
7
+ * @deprecated Use {@link getVaultVersionV2} instead. This V1 classifier can only
8
+ * recognise a multi-asset vault (`evm-2`) if its address is hard-coded in the
9
+ * static `MULTI_ASSET_VAULTS` list. Any multi-asset vault missing from that list
10
+ * is silently misclassified as `evm-1`, which broke deposit preview/simulation in
11
+ * the 2026-07-06 Sentora incident. `getVaultVersionV2` reads the backend
12
+ * `internal_type` (falling back to the static list only as a safety net), so new
13
+ * vaults classify correctly without a code change. Retained as a non-breaking
14
+ * shim; scheduled for removal in the next major.
15
+ *
16
+ * @param vault - The vault contract address (EVM `0x…`, Solana, or Stellar).
17
+ * @returns The vault version slug, or `undefined` for empty/invalid input.
18
+ */
4
19
  export declare function getVaultVersion(vault: string): IVaultVersion | undefined;
5
20
  export declare function getVaultVersionV2(vault: (Pick<ITokenizedVault, 'address'> & {
6
21
  chain_type?: string;
@@ -16,7 +16,21 @@ function getAddressChainType(address) {
16
16
  return 'sui';
17
17
  return 'evm';
18
18
  }
19
- // @todo: move to backend
19
+ /**
20
+ * Classify a vault's protocol version from its address alone.
21
+ *
22
+ * @deprecated Use {@link getVaultVersionV2} instead. This V1 classifier can only
23
+ * recognise a multi-asset vault (`evm-2`) if its address is hard-coded in the
24
+ * static `MULTI_ASSET_VAULTS` list. Any multi-asset vault missing from that list
25
+ * is silently misclassified as `evm-1`, which broke deposit preview/simulation in
26
+ * the 2026-07-06 Sentora incident. `getVaultVersionV2` reads the backend
27
+ * `internal_type` (falling back to the static list only as a safety net), so new
28
+ * vaults classify correctly without a code change. Retained as a non-breaking
29
+ * shim; scheduled for removal in the next major.
30
+ *
31
+ * @param vault - The vault contract address (EVM `0x…`, Solana, or Stellar).
32
+ * @returns The vault version slug, or `undefined` for empty/invalid input.
33
+ */
20
34
  function getVaultVersion(vault) {
21
35
  if (!vault)
22
36
  return;
@@ -18,3 +18,4 @@ export * from './helpers/core';
18
18
  export * from './helpers/adapters';
19
19
  export * from './helpers/signer';
20
20
  export * from './helpers/swap-router';
21
+ export * from './helpers/revert-decode';
package/lib/core/index.js CHANGED
@@ -34,4 +34,5 @@ __exportStar(require("./helpers/core"), exports);
34
34
  __exportStar(require("./helpers/adapters"), exports);
35
35
  __exportStar(require("./helpers/signer"), exports);
36
36
  __exportStar(require("./helpers/swap-router"), exports);
37
+ __exportStar(require("./helpers/revert-decode"), exports);
37
38
  //# sourceMappingURL=index.js.map
package/lib/main.d.ts CHANGED
@@ -279,6 +279,52 @@ export declare class AugustSDK extends AugustBase {
279
279
  untilTs?: number;
280
280
  types?: ('withdraw-request' | 'deposit' | 'withdraw-processed' | 'redeem')[];
281
281
  }): Promise<import("./types").IVaultUserHistoryItem[]>;
282
+ /**
283
+ * Resolve the ERC-20 tokens currently whitelisted for the `SwapRouter` on a
284
+ * chain — the any-token set a deposit UI can offer as swap-and-deposit inputs.
285
+ *
286
+ * Delegates to {@link AugustVaults.getSwapRouterWhitelistedTokens}, which
287
+ * reconstructs the set from the router's `TokenEnabled` events and verifies
288
+ * each against the on-chain `whitelistedTokens` mapping (not enumerable).
289
+ * Returns `[]` when no router is deployed on `chainId` or no provider is
290
+ * configured for it.
291
+ *
292
+ * @param chainId - EVM chain ID to resolve the allowlist for.
293
+ * @param options - Optional `fromBlock` to override the deploy-block scan floor.
294
+ * @returns Checksummed whitelisted token addresses; `[]` when unavailable.
295
+ * @throws AugustSDKError when an `eth_getLogs` scan chunk fails.
296
+ * @example
297
+ * ```ts
298
+ * const tokens = await augustSdk.getSwapRouterWhitelistedTokens(1);
299
+ * ```
300
+ */
301
+ getSwapRouterWhitelistedTokens(chainId: number, options?: {
302
+ fromBlock?: number;
303
+ }): Promise<IAddress[]>;
304
+ /**
305
+ * Resolve the vaults currently eligible for the any-token `SwapRouter`
306
+ * deposit surface on a chain — every vault the router has `enableVault`-ed
307
+ * whose on-chain registration is still live.
308
+ *
309
+ * Delegates to {@link AugustVaults.getSwapRouterEligibleVaults}, which
310
+ * reconstructs the set from the router's `VaultEnabled` events and verifies
311
+ * each vault's current `vaultInfo` registration (not enumerable). Returns
312
+ * `[]` when no router is deployed on `chainId` or no provider is configured
313
+ * for it. On-chain eligibility only — app-level policy (e.g. OVault
314
+ * exclusions) remains the caller's responsibility.
315
+ *
316
+ * @param chainId - EVM chain ID to resolve eligible vaults for.
317
+ * @param options - Optional `fromBlock` to override the deploy-block scan floor.
318
+ * @returns Checksummed eligible vault addresses; `[]` when unavailable.
319
+ * @throws AugustSDKError when an `eth_getLogs` scan chunk fails.
320
+ * @example
321
+ * ```ts
322
+ * const vaults = await augustSdk.getSwapRouterEligibleVaults(1);
323
+ * ```
324
+ */
325
+ getSwapRouterEligibleVaults(chainId: number, options?: {
326
+ fromBlock?: number;
327
+ }): Promise<IAddress[]>;
282
328
  /**
283
329
  * Get lifetime PnL for a user in a specific vault.
284
330
  * Calculates realized and unrealized PnL based on deposit/withdrawal history and current position.
package/lib/main.js CHANGED
@@ -343,6 +343,52 @@ class AugustSDK extends core_1.AugustBase {
343
343
  async getVaultActivity(props) {
344
344
  return await this.vaults.getVaultActivity(props);
345
345
  }
346
+ /**
347
+ * Resolve the ERC-20 tokens currently whitelisted for the `SwapRouter` on a
348
+ * chain — the any-token set a deposit UI can offer as swap-and-deposit inputs.
349
+ *
350
+ * Delegates to {@link AugustVaults.getSwapRouterWhitelistedTokens}, which
351
+ * reconstructs the set from the router's `TokenEnabled` events and verifies
352
+ * each against the on-chain `whitelistedTokens` mapping (not enumerable).
353
+ * Returns `[]` when no router is deployed on `chainId` or no provider is
354
+ * configured for it.
355
+ *
356
+ * @param chainId - EVM chain ID to resolve the allowlist for.
357
+ * @param options - Optional `fromBlock` to override the deploy-block scan floor.
358
+ * @returns Checksummed whitelisted token addresses; `[]` when unavailable.
359
+ * @throws AugustSDKError when an `eth_getLogs` scan chunk fails.
360
+ * @example
361
+ * ```ts
362
+ * const tokens = await augustSdk.getSwapRouterWhitelistedTokens(1);
363
+ * ```
364
+ */
365
+ async getSwapRouterWhitelistedTokens(chainId, options) {
366
+ return await this.vaults.getSwapRouterWhitelistedTokens(chainId, options);
367
+ }
368
+ /**
369
+ * Resolve the vaults currently eligible for the any-token `SwapRouter`
370
+ * deposit surface on a chain — every vault the router has `enableVault`-ed
371
+ * whose on-chain registration is still live.
372
+ *
373
+ * Delegates to {@link AugustVaults.getSwapRouterEligibleVaults}, which
374
+ * reconstructs the set from the router's `VaultEnabled` events and verifies
375
+ * each vault's current `vaultInfo` registration (not enumerable). Returns
376
+ * `[]` when no router is deployed on `chainId` or no provider is configured
377
+ * for it. On-chain eligibility only — app-level policy (e.g. OVault
378
+ * exclusions) remains the caller's responsibility.
379
+ *
380
+ * @param chainId - EVM chain ID to resolve eligible vaults for.
381
+ * @param options - Optional `fromBlock` to override the deploy-block scan floor.
382
+ * @returns Checksummed eligible vault addresses; `[]` when unavailable.
383
+ * @throws AugustSDKError when an `eth_getLogs` scan chunk fails.
384
+ * @example
385
+ * ```ts
386
+ * const vaults = await augustSdk.getSwapRouterEligibleVaults(1);
387
+ * ```
388
+ */
389
+ async getSwapRouterEligibleVaults(chainId, options) {
390
+ return await this.vaults.getSwapRouterEligibleVaults(chainId, options);
391
+ }
346
392
  /**
347
393
  * Get lifetime PnL for a user in a specific vault.
348
394
  * Calculates realized and unrealized PnL based on deposit/withdrawal history and current position.
@@ -328,6 +328,59 @@ export declare class AugustVaults extends AugustBase {
328
328
  untilTs?: number;
329
329
  types?: IVaultUserHistoryItem['type'][];
330
330
  }): Promise<IVaultUserHistoryItem[]>;
331
+ /**
332
+ * Resolve the ERC-20 tokens currently whitelisted for the `SwapRouter` on a
333
+ * chain — the any-token set a deposit UI can offer as swap-and-deposit inputs,
334
+ * each verified `true` against the router's on-chain allowlist.
335
+ *
336
+ * Reconstructs the set from the router's `TokenEnabled` event history and
337
+ * re-checks `whitelistedTokens(token)` for each (the mapping is not
338
+ * enumerable). See {@link getSwapRouterWhitelistedTokens} for the full
339
+ * two-stage behavior and RPC cost. Uses this instance's configured provider
340
+ * for `chainId`; returns `[]` (no RPC) when no router is deployed there or no
341
+ * provider is configured.
342
+ *
343
+ * @param chainId - EVM chain ID to resolve the allowlist for.
344
+ * @param options - Optional `fromBlock` to override the deploy-block scan floor.
345
+ * @returns Checksummed whitelisted token addresses; `[]` when unavailable.
346
+ * Callers still exclude a target vault's natively-accepted assets (those
347
+ * deposit without a swap).
348
+ * @throws AugustSDKError when an `eth_getLogs` scan chunk fails.
349
+ * @example
350
+ * ```ts
351
+ * const tokens = await augustSdk.getSwapRouterWhitelistedTokens(1);
352
+ * ```
353
+ */
354
+ getSwapRouterWhitelistedTokens(chainId: number, options?: {
355
+ fromBlock?: number;
356
+ }): Promise<IAddress[]>;
357
+ /**
358
+ * Resolve the vaults currently eligible for the any-token `SwapRouter`
359
+ * deposit surface on a chain — every vault the router has `enableVault`-ed
360
+ * whose on-chain registration is still live.
361
+ *
362
+ * Reconstructs the set from the router's `VaultEnabled` event history and
363
+ * re-checks `vaultInfo(vault).referenceAsset != 0` for each (the mapping is
364
+ * not enumerable). See {@link getSwapRouterEligibleVaults} for the full
365
+ * two-stage behavior and RPC cost. Uses this instance's configured provider
366
+ * for `chainId`; returns `[]` (no RPC) when no router is deployed there or no
367
+ * provider is configured.
368
+ *
369
+ * On-chain eligibility only — app-level policy (e.g. excluding vaults with
370
+ * their own OVault deposit flow) remains the caller's responsibility.
371
+ *
372
+ * @param chainId - EVM chain ID to resolve eligible vaults for.
373
+ * @param options - Optional `fromBlock` to override the deploy-block scan floor.
374
+ * @returns Checksummed eligible vault addresses; `[]` when unavailable.
375
+ * @throws AugustSDKError when an `eth_getLogs` scan chunk fails.
376
+ * @example
377
+ * ```ts
378
+ * const vaults = await augustSdk.getSwapRouterEligibleVaults(1);
379
+ * ```
380
+ */
381
+ getSwapRouterEligibleVaults(chainId: number, options?: {
382
+ fromBlock?: number;
383
+ }): Promise<IAddress[]>;
331
384
  /**
332
385
  * @function getStakingPositions gets all available reward staking positions
333
386
  * @param wallet optionally passed user wallet address