@augustdigital/sdk 8.6.1 → 8.7.1
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.
- package/lib/adapters/evm/index.d.ts +24 -1
- package/lib/adapters/evm/index.js +26 -0
- package/lib/adapters/solana/vault.actions.d.ts +18 -0
- package/lib/adapters/solana/vault.actions.js +43 -2
- package/lib/core/analytics/method-taxonomy.js +2 -0
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/constants/swap-router.d.ts +26 -8
- package/lib/core/constants/swap-router.js +31 -15
- package/lib/core/helpers/swap-router.d.ts +16 -4
- package/lib/core/helpers/swap-router.js +19 -6
- package/lib/core/helpers/vaults.d.ts +23 -1
- package/lib/core/helpers/vaults.js +24 -2
- package/lib/main.d.ts +26 -0
- package/lib/main.js +22 -0
- package/lib/modules/vaults/main.d.ts +46 -0
- package/lib/modules/vaults/main.js +88 -7
- package/lib/modules/vaults/write.actions.d.ts +51 -2
- package/lib/modules/vaults/write.actions.js +149 -44
- package/lib/sdk.d.ts +1181 -923
- package/lib/services/subgraph/schema.d.ts +45 -0
- package/lib/services/subgraph/schema.js +75 -0
- package/lib/services/subgraph/vaults.d.ts +3 -1
- package/lib/services/subgraph/vaults.js +148 -53
- package/lib/types/vaults.d.ts +37 -0
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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',
|
|
@@ -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
|
-
*
|
|
13
|
-
*
|
|
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
|
-
*
|
|
17
|
-
* the
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
|
|
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
|
-
*
|
|
17
|
-
*
|
|
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
|
-
*
|
|
21
|
-
* the
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|
|
37
|
+
* {@link isSwapRouterEligible} rather than reading this set directly.
|
|
27
38
|
*/
|
|
28
|
-
exports.
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
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 USD — native 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
|
|
16
|
-
*
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
24
|
-
*
|
|
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
|
|
33
|
+
* @returns `true` when the vault is in {@link SWAP_ROUTER_ELIGIBLE_VAULTS}.
|
|
28
34
|
*/
|
|
29
|
-
function
|
|
30
|
-
return swap_router_1.
|
|
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
|
*
|
|
@@ -23,4 +23,26 @@ export declare const SUBGRAPH_POOL_URLS: (apiKey: string, chainId?: number, pool
|
|
|
23
23
|
} | {
|
|
24
24
|
999: string;
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Previously fabricated a Goldsky subgraph URL from the chain name and vault
|
|
28
|
+
* symbol. That guess is unreliable and produced dead endpoints:
|
|
29
|
+
* - The path segment `/v1/subgraphs/name/goldsky/` is legacy hosted-service
|
|
30
|
+
* syntax, not Goldsky's current scheme (cf. {@link SUBGRAPH_VAULT_URLS}).
|
|
31
|
+
* - The chain name isn't the subgraph slug — ethers reports Citrea's network as
|
|
32
|
+
* `unknown`, and mainnet as `mainnet` where the subgraph uses `eth`.
|
|
33
|
+
* - A vault's symbol isn't its subgraph name — e.g. on-chain `EctUSD` vs the
|
|
34
|
+
* deployed `earn-ctusd`.
|
|
35
|
+
*
|
|
36
|
+
* A fabricated URL 404s silently, so a missing subgraph reads as "no data"
|
|
37
|
+
* rather than an error (this masked the Citrea Earn ctUSD outage). Subgraph URLs
|
|
38
|
+
* must now come from backend vault metadata (`fetchVaultMetadata → subgraph`).
|
|
39
|
+
* This returns `undefined` so callers hit their existing "Missing Subgraph"
|
|
40
|
+
* branch (warn + Slack alert) instead of querying a dead endpoint.
|
|
41
|
+
*
|
|
42
|
+
* @param _network - Unused. Kept for call-site compatibility.
|
|
43
|
+
* @param _symbol - Unused. Kept for call-site compatibility.
|
|
44
|
+
* @returns `undefined` — the SDK no longer guesses subgraph URLs.
|
|
45
|
+
* @deprecated Resolve subgraph URLs from `fetchVaultMetadata`; do not rely on a
|
|
46
|
+
* generated fallback.
|
|
47
|
+
*/
|
|
48
|
+
export declare const getDefaultSubgraphUrl: (_network: string, _symbol: string) => string | undefined;
|
|
@@ -153,8 +153,30 @@ const SUBGRAPH_POOL_URLS = (apiKey, chainId, pool) => {
|
|
|
153
153
|
return urls;
|
|
154
154
|
};
|
|
155
155
|
exports.SUBGRAPH_POOL_URLS = SUBGRAPH_POOL_URLS;
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Previously fabricated a Goldsky subgraph URL from the chain name and vault
|
|
158
|
+
* symbol. That guess is unreliable and produced dead endpoints:
|
|
159
|
+
* - The path segment `/v1/subgraphs/name/goldsky/` is legacy hosted-service
|
|
160
|
+
* syntax, not Goldsky's current scheme (cf. {@link SUBGRAPH_VAULT_URLS}).
|
|
161
|
+
* - The chain name isn't the subgraph slug — ethers reports Citrea's network as
|
|
162
|
+
* `unknown`, and mainnet as `mainnet` where the subgraph uses `eth`.
|
|
163
|
+
* - A vault's symbol isn't its subgraph name — e.g. on-chain `EctUSD` vs the
|
|
164
|
+
* deployed `earn-ctusd`.
|
|
165
|
+
*
|
|
166
|
+
* A fabricated URL 404s silently, so a missing subgraph reads as "no data"
|
|
167
|
+
* rather than an error (this masked the Citrea Earn ctUSD outage). Subgraph URLs
|
|
168
|
+
* must now come from backend vault metadata (`fetchVaultMetadata → subgraph`).
|
|
169
|
+
* This returns `undefined` so callers hit their existing "Missing Subgraph"
|
|
170
|
+
* branch (warn + Slack alert) instead of querying a dead endpoint.
|
|
171
|
+
*
|
|
172
|
+
* @param _network - Unused. Kept for call-site compatibility.
|
|
173
|
+
* @param _symbol - Unused. Kept for call-site compatibility.
|
|
174
|
+
* @returns `undefined` — the SDK no longer guesses subgraph URLs.
|
|
175
|
+
* @deprecated Resolve subgraph URLs from `fetchVaultMetadata`; do not rely on a
|
|
176
|
+
* generated fallback.
|
|
177
|
+
*/
|
|
178
|
+
const getDefaultSubgraphUrl = (_network, _symbol) => {
|
|
179
|
+
return undefined;
|
|
158
180
|
};
|
|
159
181
|
exports.getDefaultSubgraphUrl = getDefaultSubgraphUrl;
|
|
160
182
|
//# sourceMappingURL=vaults.js.map
|
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
|