@augustdigital/sdk 8.6.0 → 8.7.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.
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUserRejectionError = isUserRejectionError;
4
+ exports.isExpectedRevertError = isExpectedRevertError;
5
+ exports.logChainError = logChainError;
6
+ const logger_1 = require("../logger");
7
+ /**
8
+ * Classification of caught chain/RPC/wallet errors so the SDK can decide
9
+ * whether a failure is worth a standalone Sentry issue or is routine, expected
10
+ * noise that should ride along as a breadcrumb instead.
11
+ *
12
+ * Why this exists: most of the SDK's read/write paths `catch` and re-throw, and
13
+ * historically logged every caught error at `error` level — which the SDK's
14
+ * Sentry sink turns into a billed issue (see the severity policy on
15
+ * `SDKSentrySink` in `core/logger`). Two large, low-signal categories dominate
16
+ * that volume:
17
+ *
18
+ * 1. **User-rejected transactions** — the user clicked "reject" in their wallet.
19
+ * This is normal product behaviour, not an SDK fault, yet it fires on every
20
+ * cancelled deposit/redeem/approve.
21
+ * 2. **Expected on-chain read reverts** — reading a function a vault doesn't
22
+ * implement, or an address with no/incompatible bytecode, reverts. This is a
23
+ * routine outcome of probing heterogeneous vaults, not a defect.
24
+ *
25
+ * These predicates let call sites demote exactly those cases to `warn` while
26
+ * leaving genuine failures at `error`. They are intentionally dependency-free
27
+ * (no `ethers`/Sentry imports) so they stay cheap and safe in both browser and
28
+ * Node, and classify purely by inspecting the error's `code`/`message` shape.
29
+ *
30
+ * @module
31
+ */
32
+ /**
33
+ * Best-effort message extraction from an unknown thrown value. Reads
34
+ * `error.message` for `Error` and error-like objects, passes strings through,
35
+ * and falls back to `String(error)` for everything else. Never throws.
36
+ *
37
+ * @param error - The caught value, of unknown type.
38
+ * @returns The error's message text (never `undefined`).
39
+ */
40
+ function errorText(error) {
41
+ if (typeof error === 'string')
42
+ return error;
43
+ if (error instanceof Error)
44
+ return error.message;
45
+ if (error && typeof error === 'object') {
46
+ const maybe = error.message;
47
+ if (typeof maybe === 'string')
48
+ return maybe;
49
+ }
50
+ return String(error);
51
+ }
52
+ /**
53
+ * Collect the `code` fields an error-like value may carry. Wallet/provider
54
+ * errors stash their machine-readable code in different places depending on the
55
+ * stack: ethers sets a top-level string `code` (e.g. `'ACTION_REJECTED'`),
56
+ * EIP-1193 providers use a numeric `code` (e.g. `4001`), and some wrap the
57
+ * original under `error`/`info.error`/`cause`. We scan the common locations so
58
+ * callers needn't know which library produced the error.
59
+ *
60
+ * @param error - The caught value, of unknown type.
61
+ * @returns Every string/number `code` found (possibly empty).
62
+ */
63
+ function errorCodes(error) {
64
+ const codes = [];
65
+ if (error && typeof error === 'object') {
66
+ const e = error;
67
+ const candidates = [
68
+ e.code,
69
+ e.error?.code,
70
+ e.info?.error?.code,
71
+ e.cause?.code,
72
+ ];
73
+ for (const c of candidates) {
74
+ if (typeof c === 'string' || typeof c === 'number')
75
+ codes.push(c);
76
+ }
77
+ }
78
+ return codes;
79
+ }
80
+ /**
81
+ * Is this error a wallet/user rejection of a transaction or signature request?
82
+ *
83
+ * Detects ethers v6's `ACTION_REJECTED` code, the EIP-1193 `4001`
84
+ * ("User rejected the request") code (top-level or nested), and the common
85
+ * human-readable phrasings as a fallback for providers that omit a code.
86
+ *
87
+ * @param error - The caught value, of unknown type.
88
+ * @returns `true` when the failure was the user declining in their wallet.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * try { await vault.deposit(...); }
93
+ * catch (e) {
94
+ * if (isUserRejectionError(e)) return; // user cancelled — not an error
95
+ * throw e;
96
+ * }
97
+ * ```
98
+ */
99
+ function isUserRejectionError(error) {
100
+ const codes = errorCodes(error);
101
+ if (codes.includes('ACTION_REJECTED') || codes.includes(4001))
102
+ return true;
103
+ const msg = errorText(error).toLowerCase();
104
+ return (msg.includes('user rejected') ||
105
+ msg.includes('user denied') ||
106
+ msg.includes('rejected the request') ||
107
+ msg.includes('request rejected'));
108
+ }
109
+ /**
110
+ * Is this error a routine on-chain read revert rather than a real failure?
111
+ *
112
+ * Reading a function a contract doesn't implement, or an address that holds no
113
+ * (or incompatible) bytecode, reverts — a normal outcome when the SDK probes
114
+ * heterogeneous vaults. Matches ethers' `CALL_EXCEPTION` code and the
115
+ * message variants emitted by ethers and viem (`missing revert data`,
116
+ * `execution reverted`, `call revert exception`, and the bare `reverted`
117
+ * phrasing such as `the contract function "totalAssets" reverted`).
118
+ *
119
+ * Scope note: callers apply this on **read** paths only. A reverted *write*
120
+ * (a tx that failed on-chain) is a genuine error and is intentionally not
121
+ * demoted by this predicate's use in `write.actions`.
122
+ *
123
+ * @param error - The caught value, of unknown type.
124
+ * @returns `true` when the failure is an expected/benign contract revert.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * try { return await vaultContract.maxDepositAmount(); }
129
+ * catch (e) {
130
+ * logChainError('maxDeposit', e, isExpectedRevertError(e));
131
+ * throw e;
132
+ * }
133
+ * ```
134
+ */
135
+ function isExpectedRevertError(error) {
136
+ const codes = errorCodes(error);
137
+ if (codes.includes('CALL_EXCEPTION'))
138
+ return true;
139
+ const msg = errorText(error).toLowerCase();
140
+ return (msg.includes('call_exception') ||
141
+ msg.includes('missing revert data') ||
142
+ msg.includes('execution reverted') ||
143
+ msg.includes('call revert exception') ||
144
+ msg.includes('reverted'));
145
+ }
146
+ /**
147
+ * Log a caught chain error at the severity its category warrants, without
148
+ * swallowing it. When `isBenign` is `true` the failure is recorded as a `warn`
149
+ * (a Sentry breadcrumb that rides along with the next real issue, not a billed
150
+ * standalone issue); otherwise it is logged at `error` (a Sentry issue). The
151
+ * caller is still responsible for re-throwing — this only routes telemetry.
152
+ *
153
+ * Pass the benign decision explicitly (via {@link isUserRejectionError} or
154
+ * {@link isExpectedRevertError}) so the call site documents *why* the demotion
155
+ * is safe and each path opts into only the category that applies to it.
156
+ *
157
+ * @param tag - Low-cardinality call-site label (e.g. `'deposit'`), used as the
158
+ * Sentry breadcrumb/issue grouping key.
159
+ * @param error - The caught value, of unknown type.
160
+ * @param isBenign - `true` to demote to `warn`; `false` to keep at `error`.
161
+ * @param context - Optional structured context attached to the log entry. It is
162
+ * sanitized by the logger before transport.
163
+ */
164
+ function logChainError(tag, error, isBenign, context) {
165
+ if (isBenign) {
166
+ // Demote to a breadcrumb: the SDK's Sentry sink forwards `warn` as a
167
+ // breadcrumb, so this no longer creates its own billed issue while still
168
+ // preserving the trail if a genuine error follows.
169
+ logger_1.Logger.log.warn(tag, { message: errorText(error), ...(context ?? {}) });
170
+ return;
171
+ }
172
+ logger_1.Logger.log.error(tag, error, context);
173
+ }
174
+ //# sourceMappingURL=chain-error.js.map
@@ -12,13 +12,25 @@ import type { IAddress } from '../../types';
12
12
  */
13
13
  export declare function getSwapRouterAddress(chainId: number): IAddress | undefined;
14
14
  /**
15
- * Whether a vault has been registered on a `SwapRouter` and should route
16
- * its deposits through it. Address comparison is case-insensitive.
15
+ * Whether a vault is eligible for the any-token `SwapRouter` deposit surface
16
+ * (the SwapRouter is `enableVault`-ed for it on-chain). Address comparison is
17
+ * case-insensitive.
18
+ *
19
+ * This gates the (flag-controlled) swap-router deposit UI and can fail-fast a
20
+ * {@link swapRouterDeposit} call. It does **not** affect {@link vaultDeposit},
21
+ * which is always the native/multiasset/adapter path.
17
22
  *
18
23
  * @param vaultAddress - August vault address.
19
- * @returns `true` when the vault is in {@link VAULTS_USING_SWAP_ROUTER}.
24
+ * @returns `true` when the vault is in {@link SWAP_ROUTER_ELIGIBLE_VAULTS}.
25
+ */
26
+ export declare function isSwapRouterEligible(vaultAddress: IAddress): boolean;
27
+ /**
28
+ * @deprecated Renamed to {@link isSwapRouterEligible}. The meaning also changed:
29
+ * it no longer implies `vaultDeposit` routes the vault through the SwapRouter
30
+ * (that behavior was removed) — it only reports swap-router *eligibility* for
31
+ * the opt-in deposit surface. Kept as an alias for one release.
20
32
  */
21
- export declare function vaultUsesSwapRouter(vaultAddress: IAddress): boolean;
33
+ export declare const vaultUsesSwapRouter: typeof isSwapRouterEligible;
22
34
  /**
23
35
  * Normalize an optional origin code to the value to send on-chain.
24
36
  *
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vaultUsesSwapRouter = void 0;
3
4
  exports.getSwapRouterAddress = getSwapRouterAddress;
4
- exports.vaultUsesSwapRouter = vaultUsesSwapRouter;
5
+ exports.isSwapRouterEligible = isSwapRouterEligible;
5
6
  exports.resolveOriginCode = resolveOriginCode;
6
7
  const swap_router_1 = require("../constants/swap-router");
7
8
  const errors_1 = require("../errors");
@@ -20,15 +21,27 @@ function getSwapRouterAddress(chainId) {
20
21
  return swap_router_1.SWAP_ROUTER_ADDRESSES[chainId];
21
22
  }
22
23
  /**
23
- * Whether a vault has been registered on a `SwapRouter` and should route
24
- * its deposits through it. Address comparison is case-insensitive.
24
+ * Whether a vault is eligible for the any-token `SwapRouter` deposit surface
25
+ * (the SwapRouter is `enableVault`-ed for it on-chain). Address comparison is
26
+ * case-insensitive.
27
+ *
28
+ * This gates the (flag-controlled) swap-router deposit UI and can fail-fast a
29
+ * {@link swapRouterDeposit} call. It does **not** affect {@link vaultDeposit},
30
+ * which is always the native/multiasset/adapter path.
25
31
  *
26
32
  * @param vaultAddress - August vault address.
27
- * @returns `true` when the vault is in {@link VAULTS_USING_SWAP_ROUTER}.
33
+ * @returns `true` when the vault is in {@link SWAP_ROUTER_ELIGIBLE_VAULTS}.
28
34
  */
29
- function vaultUsesSwapRouter(vaultAddress) {
30
- return swap_router_1.VAULTS_USING_SWAP_ROUTER.has(vaultAddress.toLowerCase());
35
+ function isSwapRouterEligible(vaultAddress) {
36
+ return swap_router_1.SWAP_ROUTER_ELIGIBLE_VAULTS.has(vaultAddress.toLowerCase());
31
37
  }
38
+ /**
39
+ * @deprecated Renamed to {@link isSwapRouterEligible}. The meaning also changed:
40
+ * it no longer implies `vaultDeposit` routes the vault through the SwapRouter
41
+ * (that behavior was removed) — it only reports swap-router *eligibility* for
42
+ * the opt-in deposit surface. Kept as an alias for one release.
43
+ */
44
+ exports.vaultUsesSwapRouter = isSwapRouterEligible;
32
45
  /**
33
46
  * Normalize an optional origin code to the value to send on-chain.
34
47
  *
@@ -12,6 +12,7 @@ export * from './constants/vaults';
12
12
  export * from './constants/swap-router';
13
13
  export * from './helpers/web3';
14
14
  export * from './helpers/vaults';
15
+ export * from './helpers/chain-error';
15
16
  export * from './helpers/core';
16
17
  export * from './helpers/adapters';
17
18
  export * from './helpers/signer';
package/lib/core/index.js CHANGED
@@ -28,6 +28,7 @@ __exportStar(require("./constants/vaults"), exports);
28
28
  __exportStar(require("./constants/swap-router"), exports);
29
29
  __exportStar(require("./helpers/web3"), exports);
30
30
  __exportStar(require("./helpers/vaults"), exports);
31
+ __exportStar(require("./helpers/chain-error"), exports);
31
32
  __exportStar(require("./helpers/core"), exports);
32
33
  __exportStar(require("./helpers/adapters"), exports);
33
34
  __exportStar(require("./helpers/signer"), exports);
package/lib/main.d.ts CHANGED
@@ -253,6 +253,32 @@ export declare class AugustSDK extends AugustBase {
253
253
  timestamp: number;
254
254
  transactionHash: string;
255
255
  }[]>;
256
+ /**
257
+ * Get a vault's deposit/withdrawal activity across every participant.
258
+ *
259
+ * The vault-wide counterpart to {@link AugustSDK.getVaultUserHistory} — use
260
+ * it to answer flow questions ("how many deposits in the last 7 days", "net
261
+ * flow this week") that point-in-time TVL cannot. Reads from the Goldsky
262
+ * subgraph, paginated so busy vaults are not truncated; a `sinceTs` window
263
+ * keeps short lookbacks cheap.
264
+ * @param props - Vault address, optional chain id, optional `sinceTs`/`untilTs`
265
+ * Unix-second bounds, and an optional `types` filter.
266
+ * @returns Array of activity items (oldest-first) with normalized amounts,
267
+ * actor addresses, event type, and transaction hashes.
268
+ * @throws If `vault` is not a valid address or no chain id can be resolved.
269
+ * @example
270
+ * ```ts
271
+ * const weekAgo = Math.floor(Date.now() / 1000) - 7 * 86_400;
272
+ * const items = await sdk.getVaultActivity({ vault, chainId: 143, sinceTs: weekAgo });
273
+ * ```
274
+ */
275
+ getVaultActivity(props: {
276
+ vault: IAddress;
277
+ chainId?: IChainId;
278
+ sinceTs?: number;
279
+ untilTs?: number;
280
+ types?: ('withdraw-request' | 'deposit' | 'withdraw-processed' | 'redeem')[];
281
+ }): Promise<import("./types").IVaultUserHistoryItem[]>;
256
282
  /**
257
283
  * Get lifetime PnL for a user in a specific vault.
258
284
  * Calculates realized and unrealized PnL based on deposit/withdrawal history and current position.
package/lib/main.js CHANGED
@@ -316,6 +316,28 @@ class AugustSDK extends core_1.AugustBase {
316
316
  async getVaultUserTransfers(props) {
317
317
  return await this.vaults.getUserTransfers(props);
318
318
  }
319
+ /**
320
+ * Get a vault's deposit/withdrawal activity across every participant.
321
+ *
322
+ * The vault-wide counterpart to {@link AugustSDK.getVaultUserHistory} — use
323
+ * it to answer flow questions ("how many deposits in the last 7 days", "net
324
+ * flow this week") that point-in-time TVL cannot. Reads from the Goldsky
325
+ * subgraph, paginated so busy vaults are not truncated; a `sinceTs` window
326
+ * keeps short lookbacks cheap.
327
+ * @param props - Vault address, optional chain id, optional `sinceTs`/`untilTs`
328
+ * Unix-second bounds, and an optional `types` filter.
329
+ * @returns Array of activity items (oldest-first) with normalized amounts,
330
+ * actor addresses, event type, and transaction hashes.
331
+ * @throws If `vault` is not a valid address or no chain id can be resolved.
332
+ * @example
333
+ * ```ts
334
+ * const weekAgo = Math.floor(Date.now() / 1000) - 7 * 86_400;
335
+ * const items = await sdk.getVaultActivity({ vault, chainId: 143, sinceTs: weekAgo });
336
+ * ```
337
+ */
338
+ async getVaultActivity(props) {
339
+ return await this.vaults.getVaultActivity(props);
340
+ }
319
341
  /**
320
342
  * Get lifetime PnL for a user in a specific vault.
321
343
  * Calculates realized and unrealized PnL based on deposit/withdrawal history and current position.
@@ -254,6 +254,52 @@ export declare class AugustVaults extends AugustBase {
254
254
  timestamp: number;
255
255
  transactionHash: string;
256
256
  }[]>;
257
+ /**
258
+ * Fetch a vault's deposit/withdrawal activity across every participant.
259
+ *
260
+ * This is the vault-wide counterpart to {@link getUserHistory}: instead of
261
+ * filtering the subgraph to one wallet, it returns every deposit,
262
+ * withdrawal-request, and processed-withdrawal event for the pool. Use it to
263
+ * answer flow questions ("how many deposits in the last 7 days", "net flow
264
+ * this week") that point-in-time TVL cannot.
265
+ *
266
+ * Rows are read from the Goldsky subgraph, paginated internally so busy
267
+ * vaults are not truncated at the 1000-row page cap. When `sinceTs` is
268
+ * supplied the reader stops paging once it passes the window boundary, so a
269
+ * short lookback stays cheap even on high-volume vaults.
270
+ *
271
+ * @param params - Query parameters.
272
+ * @param params.vault - Vault (pool) address to read activity for.
273
+ * @param params.chainId - Chain id of the vault; falls back to the active
274
+ * network when omitted. Required for the subgraph lookup.
275
+ * @param params.sinceTs - Lower bound (inclusive) as a Unix timestamp in
276
+ * seconds. Events at or after this time are returned.
277
+ * @param params.untilTs - Upper bound (inclusive) as a Unix timestamp in
278
+ * seconds. Events at or before this time are returned.
279
+ * @param params.types - Restrict to a subset of event types (e.g.
280
+ * `['deposit']`). Returns all types when omitted.
281
+ * @returns Activity items sorted oldest-first, each with a normalized
282
+ * `amount`, actor `address`, `type`, and `transactionHash`.
283
+ * @throws If `vault` is not a valid address, or no chain id can be resolved.
284
+ * @example
285
+ * ```ts
286
+ * const weekAgo = Math.floor(Date.now() / 1000) - 7 * 86_400;
287
+ * const deposits = await sdk.getVaultActivity({
288
+ * vault: '0x36eDbF0C834591BFdfCaC0Ef9605528c75c406aA',
289
+ * chainId: 143,
290
+ * sinceTs: weekAgo,
291
+ * types: ['deposit'],
292
+ * });
293
+ * console.log(`${deposits.length} deposits in the last 7 days`);
294
+ * ```
295
+ */
296
+ getVaultActivity({ vault, chainId, sinceTs, untilTs, types, }: {
297
+ vault: IAddress;
298
+ chainId?: IChainId;
299
+ sinceTs?: number;
300
+ untilTs?: number;
301
+ types?: IVaultUserHistoryItem['type'][];
302
+ }): Promise<IVaultUserHistoryItem[]>;
257
303
  /**
258
304
  * @function getStakingPositions gets all available reward staking positions
259
305
  * @param wallet optionally passed user wallet address
@@ -905,6 +905,77 @@ class AugustVaults extends core_1.AugustBase {
905
905
  core_1.Logger.log.info('getUserTransfers', `${wallet}::${finalArray.length}`);
906
906
  return finalArray;
907
907
  }
908
+ /**
909
+ * Fetch a vault's deposit/withdrawal activity across every participant.
910
+ *
911
+ * This is the vault-wide counterpart to {@link getUserHistory}: instead of
912
+ * filtering the subgraph to one wallet, it returns every deposit,
913
+ * withdrawal-request, and processed-withdrawal event for the pool. Use it to
914
+ * answer flow questions ("how many deposits in the last 7 days", "net flow
915
+ * this week") that point-in-time TVL cannot.
916
+ *
917
+ * Rows are read from the Goldsky subgraph, paginated internally so busy
918
+ * vaults are not truncated at the 1000-row page cap. When `sinceTs` is
919
+ * supplied the reader stops paging once it passes the window boundary, so a
920
+ * short lookback stays cheap even on high-volume vaults.
921
+ *
922
+ * @param params - Query parameters.
923
+ * @param params.vault - Vault (pool) address to read activity for.
924
+ * @param params.chainId - Chain id of the vault; falls back to the active
925
+ * network when omitted. Required for the subgraph lookup.
926
+ * @param params.sinceTs - Lower bound (inclusive) as a Unix timestamp in
927
+ * seconds. Events at or after this time are returned.
928
+ * @param params.untilTs - Upper bound (inclusive) as a Unix timestamp in
929
+ * seconds. Events at or before this time are returned.
930
+ * @param params.types - Restrict to a subset of event types (e.g.
931
+ * `['deposit']`). Returns all types when omitted.
932
+ * @returns Activity items sorted oldest-first, each with a normalized
933
+ * `amount`, actor `address`, `type`, and `transactionHash`.
934
+ * @throws If `vault` is not a valid address, or no chain id can be resolved.
935
+ * @example
936
+ * ```ts
937
+ * const weekAgo = Math.floor(Date.now() / 1000) - 7 * 86_400;
938
+ * const deposits = await sdk.getVaultActivity({
939
+ * vault: '0x36eDbF0C834591BFdfCaC0Ef9605528c75c406aA',
940
+ * chainId: 143,
941
+ * sinceTs: weekAgo,
942
+ * types: ['deposit'],
943
+ * });
944
+ * console.log(`${deposits.length} deposits in the last 7 days`);
945
+ * ```
946
+ */
947
+ async getVaultActivity({ vault, chainId, sinceTs, untilTs, types, }) {
948
+ if (!(0, ethers_1.isAddress)(vault))
949
+ throw new Error(`Vault parameter is not an address: ${String(vault)}`);
950
+ const _chainId = chainId || this.activeNetwork?.chainId;
951
+ if (!_chainId) {
952
+ throw new Error('Chain ID is required for getVaultActivity. Pass chainId explicitly or configure an active network.');
953
+ }
954
+ const provider = (0, core_1.createProvider)(this.providers?.[_chainId]);
955
+ const raw = await (0, vaults_1.getSubgraphVaultHistory)(provider, vault, undefined, {
956
+ sinceTs,
957
+ });
958
+ const typeFilter = types?.length ? new Set(types) : undefined;
959
+ return raw
960
+ .map((h) => ({
961
+ timestamp: Number(h.timestamp_),
962
+ address: h.address,
963
+ amount: (0, core_1.toNormalizedBn)(BigInt(h.amount), h.decimals),
964
+ pool: h.contractId_,
965
+ chainId: _chainId,
966
+ type: h.type,
967
+ transactionHash: h.transactionHash_,
968
+ }))
969
+ .filter((h) => {
970
+ if (sinceTs !== undefined && h.timestamp < sinceTs)
971
+ return false;
972
+ if (untilTs !== undefined && h.timestamp > untilTs)
973
+ return false;
974
+ if (typeFilter && !typeFilter.has(h.type))
975
+ return false;
976
+ return true;
977
+ });
978
+ }
908
979
  /**
909
980
  * @function getStakingPositions gets all available reward staking positions
910
981
  * @param wallet optionally passed user wallet address
@@ -40,7 +40,7 @@ async function fetchInstantRedemptionFee(signer, options) {
40
40
  }
41
41
  }
42
42
  catch (e) {
43
- core_1.Logger.log.error('failed to fetch instant redeem fee', e);
43
+ (0, core_1.logChainError)('failed to fetch instant redeem fee', e, (0, core_1.isExpectedRevertError)(e));
44
44
  throw new Error(`Failed to fetch instant redeem fee for ${target}: ${e instanceof Error ? e.message : 'Unknown error'}`);
45
45
  }
46
46
  }
@@ -83,7 +83,7 @@ async function vaultAllowance(signer, options) {
83
83
  return normalized;
84
84
  }
85
85
  catch (e) {
86
- core_1.Logger.log.error('allowance', e);
86
+ (0, core_1.logChainError)('allowance', e, (0, core_1.isExpectedRevertError)(e));
87
87
  throw new Error(`Failed to fetch allowance: ${e instanceof Error ? e.message : 'Unknown error'}`);
88
88
  }
89
89
  }
@@ -109,7 +109,7 @@ async function sendersWhitelistAddress(signer, options) {
109
109
  return whitelistAddress;
110
110
  }
111
111
  catch (e) {
112
- core_1.Logger.log.error('sendersWhitelistAddress', e);
112
+ (0, core_1.logChainError)('sendersWhitelistAddress', e, (0, core_1.isExpectedRevertError)(e));
113
113
  throw new Error(`Failed to fetch senders whitelist address: ${e instanceof Error ? e.message : 'Unknown error'}`);
114
114
  }
115
115
  }
@@ -138,7 +138,7 @@ async function isWhitelisted(signer, options) {
138
138
  return result;
139
139
  }
140
140
  catch (e) {
141
- core_1.Logger.log.error('isWhitelisted', e);
141
+ (0, core_1.logChainError)('isWhitelisted', e, (0, core_1.isExpectedRevertError)(e));
142
142
  throw new Error(`Failed to check whitelist status: ${e instanceof Error ? e.message : 'Unknown error'}`);
143
143
  }
144
144
  }
@@ -183,7 +183,7 @@ async function getDeposited(signer, options) {
183
183
  return normalized;
184
184
  }
185
185
  catch (e) {
186
- core_1.Logger.log.error('getDeposited', e);
186
+ (0, core_1.logChainError)('getDeposited', e, (0, core_1.isExpectedRevertError)(e));
187
187
  throw new Error(`Failed to fetch deposited amount: ${e instanceof Error ? e.message : 'Unknown error'}`);
188
188
  }
189
189
  }
@@ -232,7 +232,7 @@ async function getRemainingAllocations(signer, options) {
232
232
  return normalized;
233
233
  }
234
234
  catch (e) {
235
- core_1.Logger.log.error('getRemainingAllocations', e);
235
+ (0, core_1.logChainError)('getRemainingAllocations', e, (0, core_1.isExpectedRevertError)(e));
236
236
  throw new Error(`Failed to fetch remaining allocations: ${e instanceof Error ? e.message : 'Unknown error'}`);
237
237
  }
238
238
  }
@@ -263,7 +263,11 @@ async function previewRwaRedemption(signer, options) {
263
263
  return normalized;
264
264
  }
265
265
  catch (e) {
266
- core_1.Logger.log.error('previewRwaRedemption', e, { target, asset, amount });
266
+ (0, core_1.logChainError)('previewRwaRedemption', e, (0, core_1.isExpectedRevertError)(e), {
267
+ target,
268
+ asset,
269
+ amount,
270
+ });
267
271
  throw new Error(`Preview RWA redemption failed: ${e instanceof Error ? e.message : 'Unknown error'}`);
268
272
  }
269
273
  }
@@ -354,7 +358,10 @@ async function previewDeposit(signer, options) {
354
358
  if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
355
359
  throw e;
356
360
  }
357
- core_1.Logger.log.error('previewDeposit', e, { vault, amount: amount.toString() });
361
+ (0, core_1.logChainError)('previewDeposit', e, (0, core_1.isExpectedRevertError)(e), {
362
+ vault,
363
+ amount: amount.toString(),
364
+ });
358
365
  throw new core_1.AugustSDKError('UNKNOWN', `previewDeposit failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault, amount: amount.toString() } });
359
366
  }
360
367
  }
@@ -410,7 +417,7 @@ async function previewRedeem(signer, options) {
410
417
  if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
411
418
  throw e;
412
419
  }
413
- core_1.Logger.log.error('previewRedeem', e, {
420
+ (0, core_1.logChainError)('previewRedeem', e, (0, core_1.isExpectedRevertError)(e), {
414
421
  vault,
415
422
  shares: shares.toString(),
416
423
  });
@@ -480,7 +487,11 @@ async function allowance(signer, options) {
480
487
  if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
481
488
  throw e;
482
489
  }
483
- core_1.Logger.log.error('allowance', e, { vault, owner, asset });
490
+ (0, core_1.logChainError)('allowance', e, (0, core_1.isExpectedRevertError)(e), {
491
+ vault,
492
+ owner,
493
+ asset,
494
+ });
484
495
  throw new core_1.AugustSDKError('UNKNOWN', `allowance failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault, owner, asset } });
485
496
  }
486
497
  }
@@ -521,7 +532,7 @@ async function balanceOf(signer, options) {
521
532
  if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
522
533
  throw e;
523
534
  }
524
- core_1.Logger.log.error('balanceOf', e, { asset, owner });
535
+ (0, core_1.logChainError)('balanceOf', e, (0, core_1.isExpectedRevertError)(e), { asset, owner });
525
536
  throw new core_1.AugustSDKError('UNKNOWN', `balanceOf failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { asset, owner } });
526
537
  }
527
538
  }
@@ -575,7 +586,10 @@ async function maxDeposit(signer, options) {
575
586
  if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
576
587
  throw e;
577
588
  }
578
- core_1.Logger.log.error('maxDeposit', e, { vault, receiver });
589
+ (0, core_1.logChainError)('maxDeposit', e, (0, core_1.isExpectedRevertError)(e), {
590
+ vault,
591
+ receiver,
592
+ });
579
593
  throw new core_1.AugustSDKError('UNKNOWN', `maxDeposit failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault, receiver } });
580
594
  }
581
595
  }
@@ -1,6 +1,6 @@
1
1
  import { type Signer, type Wallet, type TransactionResponse } from 'ethers';
2
2
  import type { IAddress } from '../../types';
3
- import type { ISwapAndDepositOptions, ISwapRouterDirectDepositOptions, ISwapRouterNativeDepositOptions } from '../../types';
3
+ import type { ISwapAndDepositOptions, ISwapRouterDirectDepositOptions, ISwapRouterNativeDepositOptions, ISwapRouterDepositOptions } from '../../types';
4
4
  export type IContractWriteOptions = {
5
5
  target: IAddress;
6
6
  wallet: IAddress;
@@ -76,7 +76,6 @@ export declare function resolveSpender(args: {
76
76
  isMultiAssetVault: boolean;
77
77
  isAdapterDeposit: boolean;
78
78
  adapterWrapperAddress?: IAddress;
79
- swapRouterAddress?: IAddress;
80
79
  }): IAddress;
81
80
  /** @internal */
82
81
  export declare function validateAmountPrecision(amount: string | bigint | number): void;
@@ -438,3 +437,53 @@ export declare function depositViaSwapRouter(signer: Signer | Wallet, options: I
438
437
  * addresses, or zero amount.
439
438
  */
440
439
  export declare function depositNativeViaSwapRouter(signer: Signer | Wallet, options: ISwapRouterNativeDepositOptions): Promise<string>;
440
+ /**
441
+ * Deposit into an August vault through the on-chain `SwapRouter`, selecting the
442
+ * correct router path from the deposit asset. This is the high-level, explicit
443
+ * counterpart to the SwapRouter branch inside {@link vaultDeposit}.
444
+ *
445
+ * Where `vaultDeposit` decides whether to use the SwapRouter from the
446
+ * `VAULTS_USING_SWAP_ROUTER` allowlist, this function always routes through the
447
+ * SwapRouter because the caller asked it to. Making the intent explicit is the
448
+ * point: a native-deposit vault (e.g. a multi-asset Tokenized Vault V2 whose
449
+ * non-reference assets are accepted directly) is never accidentally swapped —
450
+ * the regression that implicit, allowlist-driven routing caused. Use
451
+ * `vaultDeposit` for native / adapter deposits and this for SwapRouter deposits.
452
+ *
453
+ * The vault's reference asset and its decimals are read on-chain (never trusted
454
+ * from the caller — a wrong reference asset would mis-route the swap). The path
455
+ * is then chosen from `depositAsset`:
456
+ * - equals the reference asset → direct router deposit, no swap
457
+ * ({@link depositViaSwapRouter});
458
+ * - the zero address → native-token deposit ({@link depositNativeViaSwapRouter}),
459
+ * valid only when the reference asset is the chain's wrapped-native token;
460
+ * - any other ERC-20 → a swap to the reference asset (Paraswap quote pinned to
461
+ * the chain's whitelisted aggregator, fail-closed on router/selector drift)
462
+ * bundled into {@link swapAndDeposit}.
463
+ *
464
+ * Side effects: reads tokenized-vault metadata, the vault's reference asset and
465
+ * decimals, and (on the swap path) one Paraswap quote; sends one ERC-20
466
+ * `approve` to the SwapRouter when allowance is short, then the deposit tx.
467
+ *
468
+ * @param signer - ethers `Signer` or `Wallet` that signs the approval + deposit.
469
+ * @param options - {@link ISwapRouterDepositOptions}.
470
+ * @returns The transaction hash of the router deposit call.
471
+ * @throws {@link AugustValidationError} for an unsupported chain (no SwapRouter
472
+ * deployment), an invalid vault or deposit-asset address, a missing or zero
473
+ * amount, a native deposit into a non-wrapped-native vault, or drift between
474
+ * the aggregator quote and the on-chain router whitelist.
475
+ * @worstCaseRpcCalls 5 on the swap path — tokenized-vault metadata, reference
476
+ * asset + decimals, deposit-token decimals, the quote, and the allowance read.
477
+ * @example
478
+ * ```ts
479
+ * // USDT deposited into a USDC-reference vault → swapped to USDC en route.
480
+ * const hash = await augustSdk.evm.swapRouterDeposit({
481
+ * chainId: 1,
482
+ * vault: '0xe9b725010a9e419412ed67d0fa5f3a5f40159d32',
483
+ * depositAsset: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
484
+ * amount: '100',
485
+ * slippageBps: 50,
486
+ * });
487
+ * ```
488
+ */
489
+ export declare function swapRouterDeposit(signer: Signer | Wallet, options: ISwapRouterDepositOptions): Promise<string>;