@augustdigital/sdk 8.6.1 → 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.
@@ -1,5 +1,5 @@
1
1
  import { type IContractWriteOptions, type INativeDepositOptions, type ApproveResult } from '../../modules/vaults/write.actions';
2
- import type { ISwapAndDepositOptions, ISwapRouterDirectDepositOptions, ISwapRouterNativeDepositOptions } from '../../types';
2
+ import type { ISwapAndDepositOptions, ISwapRouterDirectDepositOptions, ISwapRouterNativeDepositOptions, ISwapRouterDepositOptions } from '../../types';
3
3
  import { type IPreviewDepositOptions, type IPreviewRedeemOptions, type IAllowanceOptions, type IBalanceOfOptions, type IMaxDepositOptions } from '../../modules/vaults/read.actions';
4
4
  import { type CompatibleSigner } from '../../core/helpers/signer';
5
5
  import type { IAddress } from '../../types';
@@ -191,6 +191,29 @@ declare class EVMAdapter {
191
191
  * @returns The transaction hash of the `depositNativeToken` call.
192
192
  */
193
193
  depositNativeViaSwapRouter(options: ISwapRouterNativeDepositOptions): Promise<string>;
194
+ /**
195
+ * Deposit into a vault through the on-chain `SwapRouter`, choosing the router
196
+ * path from `depositAsset` (direct deposit, native wrap, or a swap to the
197
+ * reference asset). The high-level, explicit counterpart to the SwapRouter
198
+ * branch inside {@link vaultDeposit} — the caller opts into the router
199
+ * deliberately, so a native-deposit vault is never accidentally swapped.
200
+ *
201
+ * Reads the vault's reference asset + decimals on-chain, resolves the swap
202
+ * quote and fail-closes on aggregator/whitelist drift, and sends the ERC-20
203
+ * approval to the SwapRouter when allowance is short.
204
+ *
205
+ * @param options - {@link ISwapRouterDepositOptions}.
206
+ * @returns The transaction hash of the router deposit call.
207
+ * @throws AugustValidationError on unsupported chain, invalid address, zero
208
+ * amount, a native deposit into a non-wrapped-native vault, or quote drift.
209
+ * @example
210
+ * ```ts
211
+ * const hash = await augustSdk.evm.swapRouterDeposit({
212
+ * chainId: 1, vault, depositAsset: USDT, amount: '100', slippageBps: 50,
213
+ * });
214
+ * ```
215
+ */
216
+ swapRouterDeposit(options: ISwapRouterDepositOptions): Promise<string>;
194
217
  /**
195
218
  * Claim assets from a matured redemption request on a dated-redemption
196
219
  * (RWA-style) vault. The `year`, `month`, `day`, and `receiverIndex` tuple
@@ -251,6 +251,32 @@ class EVMAdapter {
251
251
  const signer = await this.getSigner();
252
252
  return (0, write_actions_1.depositNativeViaSwapRouter)(signer, options);
253
253
  }
254
+ /**
255
+ * Deposit into a vault through the on-chain `SwapRouter`, choosing the router
256
+ * path from `depositAsset` (direct deposit, native wrap, or a swap to the
257
+ * reference asset). The high-level, explicit counterpart to the SwapRouter
258
+ * branch inside {@link vaultDeposit} — the caller opts into the router
259
+ * deliberately, so a native-deposit vault is never accidentally swapped.
260
+ *
261
+ * Reads the vault's reference asset + decimals on-chain, resolves the swap
262
+ * quote and fail-closes on aggregator/whitelist drift, and sends the ERC-20
263
+ * approval to the SwapRouter when allowance is short.
264
+ *
265
+ * @param options - {@link ISwapRouterDepositOptions}.
266
+ * @returns The transaction hash of the router deposit call.
267
+ * @throws AugustValidationError on unsupported chain, invalid address, zero
268
+ * amount, a native deposit into a non-wrapped-native vault, or quote drift.
269
+ * @example
270
+ * ```ts
271
+ * const hash = await augustSdk.evm.swapRouterDeposit({
272
+ * chainId: 1, vault, depositAsset: USDT, amount: '100', slippageBps: 50,
273
+ * });
274
+ * ```
275
+ */
276
+ async swapRouterDeposit(options) {
277
+ const signer = await this.getSigner();
278
+ return (0, write_actions_1.swapRouterDeposit)(signer, options);
279
+ }
254
280
  /**
255
281
  * Claim assets from a matured redemption request on a dated-redemption
256
282
  * (RWA-style) vault. The `year`, `month`, `day`, and `receiverIndex` tuple
@@ -2,6 +2,24 @@ import { type web3 } from '@coral-xyz/anchor';
2
2
  import { type Connection, PublicKey, Transaction } from '@solana/web3.js';
3
3
  import type { ISolanaConnectionOptions } from './types';
4
4
  import type { SendTransactionOptions } from '@solana/wallet-adapter-base';
5
+ /**
6
+ * Extract a human- and machine-readable reason from a thrown Solana/Anchor
7
+ * error.
8
+ *
9
+ * Anchor's {@link https://github.com/coral-xyz/anchor `ProgramError`} calls
10
+ * `super()` with no argument, so its `.message` is the empty string by
11
+ * construction — the real reason lives on `.msg`/`.code` (and `.toString()`).
12
+ * `AnchorError` puts it on `.error.errorMessage` / `.error.errorCode.number`.
13
+ * Reading `.message` directly (as this file used to) therefore rendered
14
+ * `"Solana deposit failed: "` for every recognized on-chain revert — dropping
15
+ * the numeric code the team needs to tell "Vault is paused" from
16
+ * "Insufficient amount" from an account-constraint violation.
17
+ *
18
+ * When no reason can be extracted, returns an actionable, user-facing fallback
19
+ * rather than an "unknown error" admission — the raw throwable is still
20
+ * preserved on the wrapped error's `cause` and in telemetry for diagnosis.
21
+ */
22
+ export declare function describeSolanaError(e: unknown): string;
5
23
  /**
6
24
  * Deposit funds into a Solana August vault and mint share tokens.
7
25
  *
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.describeSolanaError = describeSolanaError;
3
4
  exports.handleSolanaDeposit = handleSolanaDeposit;
4
5
  exports.handleSolanaRedeem = handleSolanaRedeem;
5
6
  const anchor_1 = require("@coral-xyz/anchor");
@@ -8,6 +9,46 @@ const spl_token_1 = require("@solana/spl-token");
8
9
  const constants_1 = require("./constants");
9
10
  const utils_1 = require("./utils");
10
11
  const core_1 = require("../../core");
12
+ /**
13
+ * User-facing fallback for a throwable that carries no extractable reason.
14
+ * Surfaces as e.g. `"Solana deposit failed: please try again"` — actionable,
15
+ * and without telling the user we couldn't classify the failure.
16
+ */
17
+ const REASONLESS_SOLANA_ERROR = 'please try again';
18
+ /**
19
+ * Extract a human- and machine-readable reason from a thrown Solana/Anchor
20
+ * error.
21
+ *
22
+ * Anchor's {@link https://github.com/coral-xyz/anchor `ProgramError`} calls
23
+ * `super()` with no argument, so its `.message` is the empty string by
24
+ * construction — the real reason lives on `.msg`/`.code` (and `.toString()`).
25
+ * `AnchorError` puts it on `.error.errorMessage` / `.error.errorCode.number`.
26
+ * Reading `.message` directly (as this file used to) therefore rendered
27
+ * `"Solana deposit failed: "` for every recognized on-chain revert — dropping
28
+ * the numeric code the team needs to tell "Vault is paused" from
29
+ * "Insufficient amount" from an account-constraint violation.
30
+ *
31
+ * When no reason can be extracted, returns an actionable, user-facing fallback
32
+ * rather than an "unknown error" admission — the raw throwable is still
33
+ * preserved on the wrapped error's `cause` and in telemetry for diagnosis.
34
+ */
35
+ function describeSolanaError(e) {
36
+ if (!(e instanceof Error))
37
+ return REASONLESS_SOLANA_ERROR;
38
+ const anchor = e;
39
+ const reason = anchor.error?.errorMessage ?? anchor.msg ?? '';
40
+ const code = anchor.error?.errorCode?.number ?? anchor.code;
41
+ if (reason)
42
+ return code === undefined ? reason : `${reason} (code ${code})`;
43
+ // SendTransactionError / generic Error carry a non-empty `.message`.
44
+ if (e.message)
45
+ return e.message;
46
+ // Last resort: a subclass may override `toString()` (never the empty string).
47
+ const str = e.toString();
48
+ return str && str !== e.name && str !== `${e.name}: `
49
+ ? str
50
+ : REASONLESS_SOLANA_ERROR;
51
+ }
11
52
  /**
12
53
  * Deposit funds into a Solana August vault and mint share tokens.
13
54
  *
@@ -159,7 +200,7 @@ async function handleSolanaDeposit({ provider, connection, network = constants_1
159
200
  vaultAddress: vaultAddress ? String(vaultAddress) : undefined,
160
201
  depositAmount: depositAmountForLog,
161
202
  });
162
- throw new core_1.AugustSDKError('UNKNOWN', `Solana deposit failed: ${e instanceof Error ? e.message : 'Unknown error'}`, {
203
+ throw new core_1.AugustSDKError('UNKNOWN', `Solana deposit failed: ${describeSolanaError(e)}`, {
163
204
  cause: e,
164
205
  context: {
165
206
  vaultProgramId: String(vaultProgramId),
@@ -325,7 +366,7 @@ async function handleSolanaRedeem({ provider, connection, vaultProgramId, vaultA
325
366
  vaultAddress: vaultAddress ? String(vaultAddress) : undefined,
326
367
  redeemShares: redeemSharesForLog,
327
368
  });
328
- throw new core_1.AugustSDKError('UNKNOWN', `Solana redeem failed: ${e instanceof Error ? e.message : 'Unknown error'}`, {
369
+ throw new core_1.AugustSDKError('UNKNOWN', `Solana redeem failed: ${describeSolanaError(e)}`, {
329
370
  cause: e,
330
371
  context: {
331
372
  vaultProgramId: String(vaultProgramId),
@@ -26,6 +26,7 @@ exports.METHOD_CATEGORIES = {
26
26
  getLatestUnrealizedPnl: 'read.vault',
27
27
  getVaultBorrowerHealthFactor: 'read.vault',
28
28
  getYieldLastRealizedOn: 'read.vault',
29
+ getVaultActivity: 'read.vault',
29
30
  getVaultPositions: 'read.position',
30
31
  getVaultUserHistory: 'read.position',
31
32
  getUserHistory: 'read.position',
@@ -82,6 +83,7 @@ exports.METHOD_CATEGORIES = {
82
83
  swapAndDeposit: 'write.deposit',
83
84
  depositViaSwapRouter: 'write.deposit',
84
85
  depositNativeViaSwapRouter: 'write.deposit',
86
+ swapRouterDeposit: 'write.deposit',
85
87
  vaultRedeem: 'write.redeem',
86
88
  vaultRequestRedeem: 'write.redeem',
87
89
  rwaRedeemAsset: 'write.redeem',
@@ -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.6.1";
6
+ export declare const SDK_VERSION = "8.7.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.6.1';
9
+ exports.SDK_VERSION = '8.7.0';
10
10
  //# sourceMappingURL=version.js.map
@@ -9,17 +9,35 @@ import type { IAddress } from '../../types';
9
9
  */
10
10
  export declare const SWAP_ROUTER_ADDRESSES: Readonly<Record<number, IAddress>>;
11
11
  /**
12
- * Vault addresses registered on a `SwapRouter` via `enableVault`. The
13
- * presence of a vault here is the signal to route its deposits through the
14
- * SwapRouter rather than the legacy adapter path.
12
+ * Vaults whose UI **may offer the any-token SwapRouter deposit surface**
13
+ * i.e. the SwapRouter is `enableVault`-ed for them on-chain.
15
14
  *
16
- * Entries mirror the on-chain `vaultInfo[addr].referenceAsset != 0` state of
17
- * the `SwapRouter` deployment. Verify against the deployed contract before
18
- * adding a new entry — a vault that is not registered on-chain will revert
19
- * with `InvalidVault` at deposit time.
15
+ * This is *eligibility metadata only*. It is consumed by:
16
+ * - the app UI, to decide whether to render the (flag-gated) swap-router
17
+ * deposit surface for a vault; and
18
+ * - {@link swapRouterDeposit}, optionally, as a fail-fast eligibility check.
19
+ *
20
+ * It is deliberately **NOT** read by {@link vaultDeposit}: `vaultDeposit` is the
21
+ * native/multiasset/adapter path and never routes through the SwapRouter. That
22
+ * separation is what stops a natively-accepted asset from being silently
23
+ * swapped — the regression that implicit auto-routing caused. Any-token swap
24
+ * deposits are the explicit, opt-in job of {@link swapRouterDeposit}.
25
+ *
26
+ * Membership requires the vault to be registered on-chain
27
+ * (`vaultInfo[addr].referenceAsset != 0`) — an unregistered vault reverts with
28
+ * `InvalidVault` at deposit time. A listed vault's natively-accepted assets
29
+ * (for a multi-asset vault, its whole deposit-asset set) still deposit via
30
+ * `vaultDeposit`; only tokens OUTSIDE that set go through `swapRouterDeposit`.
20
31
  *
21
32
  * Lowercase comparison is required when checking — use
22
- * {@link vaultUsesSwapRouter} rather than reading this set directly.
33
+ * {@link isSwapRouterEligible} rather than reading this set directly.
34
+ */
35
+ export declare const SWAP_ROUTER_ELIGIBLE_VAULTS: ReadonlySet<string>;
36
+ /**
37
+ * @deprecated Renamed to {@link SWAP_ROUTER_ELIGIBLE_VAULTS}, and the semantics
38
+ * changed: this set no longer drives `vaultDeposit` auto-routing (that branch
39
+ * was removed) — it now only marks vaults whose UI may offer the swap-router
40
+ * deposit surface. Kept as an alias for one release; migrate to the new name.
23
41
  */
24
42
  export declare const VAULTS_USING_SWAP_ROUTER: ReadonlySet<string>;
25
43
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
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_ELIGIBLE_VAULTS = exports.SWAP_ROUTER_ADDRESSES = void 0;
4
4
  /**
5
5
  * Address of the `SwapRouter` periphery contract on each supported chain.
6
6
  *
@@ -13,26 +13,42 @@ exports.SWAP_ROUTER_ADDRESSES = {
13
13
  1: '0xAC771209FF2b71EECfF6E85a9AD01db8Ff2618B0',
14
14
  };
15
15
  /**
16
- * Vault addresses registered on a `SwapRouter` via `enableVault`. The
17
- * presence of a vault here is the signal to route its deposits through the
18
- * SwapRouter rather than the legacy adapter path.
16
+ * Vaults whose UI **may offer the any-token SwapRouter deposit surface**
17
+ * i.e. the SwapRouter is `enableVault`-ed for them on-chain.
19
18
  *
20
- * Entries mirror the on-chain `vaultInfo[addr].referenceAsset != 0` state of
21
- * the `SwapRouter` deployment. Verify against the deployed contract before
22
- * adding a new entry — a vault that is not registered on-chain will revert
23
- * with `InvalidVault` at deposit time.
19
+ * This is *eligibility metadata only*. It is consumed by:
20
+ * - the app UI, to decide whether to render the (flag-gated) swap-router
21
+ * deposit surface for a vault; and
22
+ * - {@link swapRouterDeposit}, optionally, as a fail-fast eligibility check.
23
+ *
24
+ * It is deliberately **NOT** read by {@link vaultDeposit}: `vaultDeposit` is the
25
+ * native/multiasset/adapter path and never routes through the SwapRouter. That
26
+ * separation is what stops a natively-accepted asset from being silently
27
+ * swapped — the regression that implicit auto-routing caused. Any-token swap
28
+ * deposits are the explicit, opt-in job of {@link swapRouterDeposit}.
29
+ *
30
+ * Membership requires the vault to be registered on-chain
31
+ * (`vaultInfo[addr].referenceAsset != 0`) — an unregistered vault reverts with
32
+ * `InvalidVault` at deposit time. A listed vault's natively-accepted assets
33
+ * (for a multi-asset vault, its whole deposit-asset set) still deposit via
34
+ * `vaultDeposit`; only tokens OUTSIDE that set go through `swapRouterDeposit`.
24
35
  *
25
36
  * Lowercase comparison is required when checking — use
26
- * {@link vaultUsesSwapRouter} rather than reading this set directly.
37
+ * {@link isSwapRouterEligible} rather than reading this set directly.
27
38
  */
28
- exports.VAULTS_USING_SWAP_ROUTER = new Set([
29
- // Upshift Core USDC ERC-4626 vault, reference asset USDC. Enabled on
30
- // the mainnet SwapRouter at vaultType=1 (VAULT_TYPE_ERC4626).
31
- '0xe9b725010a9e419412ed67d0fa5f3a5f40159d32',
32
- // Sentora USD — Tokenized Vault V2, reference asset USDC. Enabled on the
33
- // mainnet SwapRouter at vaultType=2 (VAULT_TYPE_TOKENIZED_VAULT_V2).
39
+ exports.SWAP_ROUTER_ELIGIBLE_VAULTS = new Set([
40
+ // Sentora USDnative multi-asset Tokenized Vault V2 (reference asset
41
+ // USDC). Its native assets (USDC/RLUSD/PYUSD/USDT) deposit via vaultDeposit;
42
+ // the swap-router surface adds deposits of tokens outside that set.
34
43
  '0x74ad2f789ed583dbd141bbdafc673fe1f033718b',
35
44
  ]);
45
+ /**
46
+ * @deprecated Renamed to {@link SWAP_ROUTER_ELIGIBLE_VAULTS}, and the semantics
47
+ * changed: this set no longer drives `vaultDeposit` auto-routing (that branch
48
+ * was removed) — it now only marks vaults whose UI may offer the swap-router
49
+ * deposit surface. Kept as an alias for one release; migrate to the new name.
50
+ */
51
+ exports.VAULTS_USING_SWAP_ROUTER = exports.SWAP_ROUTER_ELIGIBLE_VAULTS;
36
52
  /**
37
53
  * 32-byte origin codes registered on the `SwapRouter` via `addOrigin`.
38
54
  * Drives origin/referral-fee accrual. The on-chain admin must register a
@@ -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
  *
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
@@ -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>;