@augustdigital/sdk 8.24.0 → 8.26.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.
- package/lib/adapters/solana/idl/vault-idl.d.ts +185 -18
- package/lib/adapters/solana/idl/vault-idl.js +521 -28
- package/lib/adapters/sui/getters.d.ts +7 -1
- package/lib/adapters/sui/getters.js +53 -6
- package/lib/core/analytics/method-taxonomy.js +10 -0
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/constants/core.d.ts +11 -0
- package/lib/core/constants/core.js +54 -0
- package/lib/main.d.ts +28 -11
- package/lib/main.js +25 -3
- package/lib/modules/api/fetcher.d.ts +27 -1
- package/lib/modules/api/fetcher.js +38 -1
- package/lib/modules/api/main.d.ts +288 -14
- package/lib/modules/api/main.js +439 -13
- package/lib/modules/vaults/getters.d.ts +9 -2
- package/lib/modules/vaults/getters.js +9 -3
- package/lib/modules/vaults/main.d.ts +3 -28
- package/lib/modules/vaults/main.js +55 -19
- package/lib/modules/vaults/types.d.ts +52 -0
- package/lib/modules/vaults/utils.d.ts +7 -2
- package/lib/modules/vaults/utils.js +12 -4
- package/lib/modules/vaults/write.actions.d.ts +4 -0
- package/lib/modules/vaults/write.actions.js +9 -1
- package/lib/sdk.d.ts +11618 -10864
- package/lib/types/api.d.ts +218 -0
- package/package.json +1 -1
package/lib/modules/api/main.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AugustApi = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The August backend API Module — read-only client for public backend
|
|
6
|
+
* endpoints (transparency dashboard, unrealized PnL) and authenticated
|
|
7
|
+
* loan-book / risk / OTC reads. Accessible as `sdk.apiModule`.
|
|
8
|
+
*
|
|
9
|
+
* @module AugustApi
|
|
10
|
+
*/
|
|
4
11
|
const ethers_1 = require("ethers");
|
|
5
12
|
const fetcher_1 = require("./fetcher");
|
|
6
13
|
const base_class_1 = require("../../core/base.class");
|
|
@@ -32,6 +39,71 @@ function assertVaultAddress(vault, method) {
|
|
|
32
39
|
throw new errors_1.AugustValidationError('INVALID_ADDRESS', `${method}: "${vault}" is not a valid vault address — pass the vault's EVM (0x…), Solana, or Stellar address.`);
|
|
33
40
|
}
|
|
34
41
|
}
|
|
42
|
+
/** Transparency endpoints are EVM-only and require a positive integer chain id. */
|
|
43
|
+
function assertTransparencyArgs(method, vault, chainId) {
|
|
44
|
+
if (!(0, ethers_1.isAddress)(vault)) {
|
|
45
|
+
throw new errors_1.AugustValidationError('INVALID_ADDRESS', `${method}: vault must be an EVM address (transparency endpoints are EVM-only), got ${String(vault)}.`);
|
|
46
|
+
}
|
|
47
|
+
if (!Number.isInteger(chainId) || chainId <= 0) {
|
|
48
|
+
throw new errors_1.AugustValidationError('INVALID_CHAIN', `${method}: chainId must be a positive integer EVM chain id, got ${chainId}. Transparency endpoints are EVM-only.`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
52
|
+
/** Date-window params are plain `YYYY-MM-DD` strings; anything else is rejected before the request. */
|
|
53
|
+
function assertIsoDate(method, name, value) {
|
|
54
|
+
if (value !== undefined && !ISO_DATE.test(value)) {
|
|
55
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: ${name} must be YYYY-MM-DD, got "${value}".`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Cheap contract-drift guard for the chain-scoped transparency responses.
|
|
60
|
+
* Every one of them (`positions`, `historical_allocations`, `fees`,
|
|
61
|
+
* `governance/*`) is an object keyed by `vault_address` + `chain_id`; if the
|
|
62
|
+
* body is not that, the backend contract has changed and partner code must
|
|
63
|
+
* not receive a silently-malformed object. Leaves are deliberately NOT
|
|
64
|
+
* validated — full validation of eight nested shapes is not worth the
|
|
65
|
+
* weight, and the top-level check catches the common drift (envelope
|
|
66
|
+
* wrapping, error-object-over-200, renamed root).
|
|
67
|
+
*/
|
|
68
|
+
function assertTransparencyEnvelope(data, method) {
|
|
69
|
+
const valid = data !== null &&
|
|
70
|
+
typeof data === 'object' &&
|
|
71
|
+
!Array.isArray(data) &&
|
|
72
|
+
typeof data.vault_address === 'string' &&
|
|
73
|
+
typeof data.chain_id === 'number';
|
|
74
|
+
if (!valid) {
|
|
75
|
+
throw new errors_1.AugustServerError(200, `${method}: unexpected response shape from the August API — expected an object with vault_address and chain_id. The backend contract may have changed; refresh packages/sdk/api-spec and update the SDK.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Same guard for the backing-series endpoint, whose body is a bare array of
|
|
80
|
+
* ratio points (no envelope). Anything else is contract drift.
|
|
81
|
+
*/
|
|
82
|
+
function assertTransparencyArray(data, method) {
|
|
83
|
+
if (!Array.isArray(data)) {
|
|
84
|
+
throw new errors_1.AugustServerError(200, `${method}: unexpected response shape from the August API — expected an array of ratio points. The backend contract may have changed; refresh packages/sdk/api-spec and update the SDK.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Runtime mirror of {@link ITransparencyTimelockStatus} (+ `'all'`) — plain-JS callers bypass the type. */
|
|
88
|
+
const TRANSPARENCY_TIMELOCK_STATUSES = [
|
|
89
|
+
'scheduled',
|
|
90
|
+
'executed',
|
|
91
|
+
'cancelled',
|
|
92
|
+
'all',
|
|
93
|
+
];
|
|
94
|
+
/** Runtime mirror of {@link ITransparencyAuditCategory} — plain-JS callers bypass the type. */
|
|
95
|
+
const TRANSPARENCY_AUDIT_CATEGORIES = [
|
|
96
|
+
'Strategy',
|
|
97
|
+
'Role',
|
|
98
|
+
'Permission',
|
|
99
|
+
'Attestation',
|
|
100
|
+
];
|
|
101
|
+
/** Rejects a filter value outside its allowlist before any request is made (types only guard TS callers). */
|
|
102
|
+
function assertOneOf(method, name, value, allowed) {
|
|
103
|
+
if (value !== undefined && !allowed.includes(value)) {
|
|
104
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: ${name} must be one of ${allowed.map((v) => `'${v}'`).join(', ')}, got "${String(value)}".`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
35
107
|
function assertAddressArg(value, label, method) {
|
|
36
108
|
const valid = typeof value === 'string' &&
|
|
37
109
|
value.length > 0 &&
|
|
@@ -70,20 +142,15 @@ function assertSnapshotArray(data, method) {
|
|
|
70
142
|
}
|
|
71
143
|
/**
|
|
72
144
|
* Read-only client for August backend REST endpoints that have no on-chain
|
|
73
|
-
* equivalent
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* Every method makes exactly one HTTPS request to the public
|
|
77
|
-
* (unauthenticated) August API and zero RPC calls. Responses are not cached
|
|
78
|
-
* by the SDK: this is time-sensitive PnL state where staleness is worse
|
|
79
|
-
* than request latency.
|
|
145
|
+
* equivalent: the unrealized-PnL series, the transparency dashboard
|
|
146
|
+
* (position snapshot, backing series, smoothed APY, allocations, fee config,
|
|
147
|
+
* governance), plus authenticated loan-book / risk / OTC reads.
|
|
80
148
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* constructor; each such method documents the requirement.
|
|
149
|
+
* Every public method makes exactly one HTTPS request to the August API and
|
|
150
|
+
* zero RPC calls. Responses are not cached by the SDK: this is time-sensitive
|
|
151
|
+
* state where staleness is worse than a request. Accessible as
|
|
152
|
+
* `sdk.apiModule`; only the unrealized-PnL methods are also mirrored on the
|
|
153
|
+
* root `AugustSDK` class.
|
|
87
154
|
*/
|
|
88
155
|
class AugustApi extends base_class_1.AugustBase {
|
|
89
156
|
headers = null;
|
|
@@ -421,6 +488,365 @@ class AugustApi extends base_class_1.AugustBase {
|
|
|
421
488
|
}
|
|
422
489
|
return (0, fetcher_1.fetchVaultOracleClassification)(vault, chainId, this.headers ?? undefined);
|
|
423
490
|
}
|
|
491
|
+
// -------------------------------------------------------------------------
|
|
492
|
+
// Transparency dashboard
|
|
493
|
+
//
|
|
494
|
+
// One method per card/tab of the Upshift per-vault transparency page so a
|
|
495
|
+
// partner can compose exactly the subset they want (e.g. Performance without
|
|
496
|
+
// the collateral-ratio card). Every method: public endpoint, no API key, one
|
|
497
|
+
// HTTPS request, zero RPC, snapshot-backed (hourly-ish; cache ≥60s).
|
|
498
|
+
// -------------------------------------------------------------------------
|
|
499
|
+
/**
|
|
500
|
+
* Fetch the latest position snapshot for a vault, grouped per wallet — the
|
|
501
|
+
* data behind the transparency Overview tab (strategy breakdown, backing
|
|
502
|
+
* composition, vault buffer, per-wallet table, headline TVL).
|
|
503
|
+
*
|
|
504
|
+
* Public `GET /upshift/positions/{vault_address}`; no API key. One HTTPS
|
|
505
|
+
* request, no RPC. Snapshots land hourly; every field is from the single
|
|
506
|
+
* `snapshot_at` instant. Vault buffer = `total_nav − Σ subaccounts[].total_usd`;
|
|
507
|
+
* `reported_tvl` is the vault-contract-reported total assets from the same snapshot.
|
|
508
|
+
*
|
|
509
|
+
* @param params.vault EVM vault address.
|
|
510
|
+
* @param params.chainId Numeric chain id the vault lives on.
|
|
511
|
+
* @returns {@link ITransparencyPositions}.
|
|
512
|
+
* @throws AugustValidationError When arguments fail validation (no request is made).
|
|
513
|
+
* @throws AugustServerError When the API responds non-2xx (e.g. unknown vault 404, non-EVM vault 422).
|
|
514
|
+
* @throws AugustServerError (status 200) When the body is not the documented shape — backend contract drift.
|
|
515
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
516
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
517
|
+
* @example
|
|
518
|
+
* ```ts
|
|
519
|
+
* const p = await sdk.apiModule.getVaultPositionSnapshot({ vault: '0x36eDbF0C834591BFdfCaC0Ef9605528c75c406aA', chainId: 143 });
|
|
520
|
+
* const buffer = p.total_nav - p.subaccounts.reduce((a, s) => a + s.total_usd, 0);
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
async getVaultPositionSnapshot(params) {
|
|
524
|
+
const method = 'getVaultPositionSnapshot';
|
|
525
|
+
assertTransparencyArgs(method, params.vault, params.chainId);
|
|
526
|
+
const data = await (0, fetcher_1.fetchTransparencyPositions)(params.vault, params.chainId, this.headers ?? undefined);
|
|
527
|
+
assertTransparencyEnvelope(data, method);
|
|
528
|
+
return data;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Fetch the backing / supply / collateral-ratio time series behind the
|
|
532
|
+
* Performance tab's "Backing vs Supply" and "Collateral Ratio" charts, and
|
|
533
|
+
* the Overview sidebar's 7-day deltas.
|
|
534
|
+
*
|
|
535
|
+
* Public `GET /upshift/unrealized_pnl?fields=ratio`; no API key. One HTTPS
|
|
536
|
+
* request, no RPC. Points are hourly, returned newest-first — sort before
|
|
537
|
+
* charting. `actual_tvl` = backing (mark-to-market), `tvl_on_vault` = supply
|
|
538
|
+
* (vault-reported), `adjusted_redeem_ratio` = collateral ratio.
|
|
539
|
+
*
|
|
540
|
+
* Unlike the chain-scoped transparency endpoints (positions, fees,
|
|
541
|
+
* governance…), this one is keyed by vault address only and accepts
|
|
542
|
+
* non-EVM (Solana / Stellar) vaults — same contract as
|
|
543
|
+
* {@link AugustApi.getVaultUnrealizedPnlHistory}, which it shares a route with.
|
|
544
|
+
*
|
|
545
|
+
* @param params.vault Vault address (EVM, Solana, or Stellar).
|
|
546
|
+
* @param params.startDate Optional inclusive lower bound, `YYYY-MM-DD`.
|
|
547
|
+
* @param params.endDate Optional inclusive upper bound, `YYYY-MM-DD`.
|
|
548
|
+
* @param params.limit Optional max points.
|
|
549
|
+
* @returns Array of {@link ITransparencyRatioPoint}; empty when no history.
|
|
550
|
+
* @throws AugustValidationError When arguments fail validation (no request is made).
|
|
551
|
+
* @throws AugustServerError When the API responds non-2xx (e.g. unknown vault 404, non-EVM vault 422).
|
|
552
|
+
* @throws AugustServerError (status 200) When the body is not the documented shape — backend contract drift.
|
|
553
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
554
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
555
|
+
* @example
|
|
556
|
+
* ```ts
|
|
557
|
+
* const pts = await sdk.apiModule.getVaultBackingSeries({ vault, startDate: '2026-08-01' });
|
|
558
|
+
* const ratio = pts.map((p) => p.adjusted_redeem_ratio * 100); // percent
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
async getVaultBackingSeries(params) {
|
|
562
|
+
const method = 'getVaultBackingSeries';
|
|
563
|
+
assertVaultAddress(params.vault, method);
|
|
564
|
+
assertIsoDate(method, 'startDate', params.startDate);
|
|
565
|
+
assertIsoDate(method, 'endDate', params.endDate);
|
|
566
|
+
if (params.limit !== undefined &&
|
|
567
|
+
(!Number.isInteger(params.limit) ||
|
|
568
|
+
params.limit < 1 ||
|
|
569
|
+
params.limit > 1000)) {
|
|
570
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: limit must be an integer between 1 and 1000, got ${params.limit}.`);
|
|
571
|
+
}
|
|
572
|
+
const data = await (0, fetcher_1.fetchTransparencyRatioSeries)(params.vault, params.startDate, params.endDate, params.limit, this.headers ?? undefined);
|
|
573
|
+
assertTransparencyArray(data, method);
|
|
574
|
+
return data;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Fetch the smoothed 7-day APY series — the exact series the Upshift app
|
|
578
|
+
* charts (Overview "APY last 30 days" and Performance "APY Over Time").
|
|
579
|
+
*
|
|
580
|
+
* Public `GET /upshift/historical_apy/chart`; no API key. One HTTPS request,
|
|
581
|
+
* no RPC. The backend marks this route deprecated in its OpenAPI spec but it
|
|
582
|
+
* remains the series the Upshift app itself charts; this wrapper tracks it.
|
|
583
|
+
* The backend applies a rolling-median/mean smoothing filter server-side
|
|
584
|
+
* when `applySmoothing` is true (the app default); computing APY locally from
|
|
585
|
+
* raw share ratios will NOT match the published figures.
|
|
586
|
+
*
|
|
587
|
+
* Unlike the chain-scoped transparency endpoints (positions, fees,
|
|
588
|
+
* governance…), this one is keyed by vault address only and accepts
|
|
589
|
+
* non-EVM (Solana / Stellar) vaults.
|
|
590
|
+
*
|
|
591
|
+
* @param params.vault Vault address (EVM, Solana, or Stellar).
|
|
592
|
+
* @param params.daysAgo Window length in days; pass `-1` for the full history since inception. Default 30.
|
|
593
|
+
* @param params.averagingPeriodDays Rolling window for the annualized return; must be ≥ 2. Default 7 (the app's "7D APY").
|
|
594
|
+
* @param params.applySmoothing Apply the backend smoothing filter. Default true.
|
|
595
|
+
* @returns {@link ITransparencyApySeries} — `labels` are `M/D/YYYY`, `values` are decimal fractions (0.0245 = 2.45%). Empty arrays when the vault has no data.
|
|
596
|
+
* @throws AugustValidationError When arguments fail validation (no request is made).
|
|
597
|
+
* @throws AugustServerError When the API responds non-2xx (e.g. unknown vault 404, non-EVM vault 422).
|
|
598
|
+
* @throws AugustServerError (status 200) When the body is not the documented shape — backend contract drift.
|
|
599
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
600
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
601
|
+
* @example
|
|
602
|
+
* ```ts
|
|
603
|
+
* const apy = await sdk.apiModule.getVaultSmoothedApy({ vault, daysAgo: 30 });
|
|
604
|
+
* console.log(apy.values.at(-1)); // latest 7D APY as a fraction
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
async getVaultSmoothedApy(params) {
|
|
608
|
+
const method = 'getVaultSmoothedApy';
|
|
609
|
+
assertVaultAddress(params.vault, method);
|
|
610
|
+
const daysAgo = params.daysAgo ?? 30;
|
|
611
|
+
// `0` is deliberately rejected: the backend happens to treat `days_ago=0`
|
|
612
|
+
// as "full history" (same as -1) but only -1 is documented, and a caller
|
|
613
|
+
// passing 0 almost certainly means "today", not "everything". Forcing the
|
|
614
|
+
// explicit sentinel avoids silently returning the whole series.
|
|
615
|
+
if (!Number.isInteger(daysAgo) || (daysAgo < 1 && daysAgo !== -1)) {
|
|
616
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: daysAgo must be a positive integer (≥ 1) or -1 for full history, got ${params.daysAgo}. 0 is not accepted — pass -1 for the full series.`);
|
|
617
|
+
}
|
|
618
|
+
const averaging = params.averagingPeriodDays ?? 7;
|
|
619
|
+
if (!Number.isInteger(averaging) || averaging < 2) {
|
|
620
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: averagingPeriodDays must be an integer ≥ 2, got ${params.averagingPeriodDays}.`);
|
|
621
|
+
}
|
|
622
|
+
const envelope = await (0, fetcher_1.fetchTransparencySmoothedApy)(params.vault, daysAgo, averaging, params.applySmoothing ?? true, this.headers ?? undefined);
|
|
623
|
+
// The endpoint reports not-found / bad-args IN-BODY over HTTP 200. The
|
|
624
|
+
// live shape for those is
|
|
625
|
+
// { data: { labels: [], values: [] }, average_apy: null, status: 404|400, error: "…" }
|
|
626
|
+
// i.e. `data` is never null — it passes `shapeOk` below and falls through
|
|
627
|
+
// to the normal return as an empty series (charts render their empty
|
|
628
|
+
// state). The `!shapeOk && status 404/400` branch is a defensive mirror
|
|
629
|
+
// in case the backend ever sends `data: null` with those statuses.
|
|
630
|
+
// `data: null` with `status: 200` has never been observed; if it shows up
|
|
631
|
+
// it IS a contract change and must fail loudly rather than hand partners
|
|
632
|
+
// a bogus empty chart.
|
|
633
|
+
const data = envelope?.data;
|
|
634
|
+
const shapeOk = data !== null &&
|
|
635
|
+
typeof data === 'object' &&
|
|
636
|
+
Array.isArray(data.labels) &&
|
|
637
|
+
Array.isArray(data.values);
|
|
638
|
+
if (!shapeOk) {
|
|
639
|
+
if (envelope?.status === 404 || envelope?.status === 400) {
|
|
640
|
+
return { labels: [], values: [], average_apy: null };
|
|
641
|
+
}
|
|
642
|
+
throw new errors_1.AugustServerError(200, `${method}: unexpected response shape from the August API — expected { data: { labels, values } }. The backend contract may have changed; refresh packages/sdk/api-spec and update the SDK.`);
|
|
643
|
+
}
|
|
644
|
+
return {
|
|
645
|
+
labels: data.labels,
|
|
646
|
+
values: data.values,
|
|
647
|
+
// average_apy sits at the envelope top level, beside `data`.
|
|
648
|
+
average_apy: envelope?.average_apy ?? null,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Fetch daily allocation history per protocol — the Performance tab's
|
|
653
|
+
* "Allocation Over Time" chart.
|
|
654
|
+
*
|
|
655
|
+
* Public `GET /upshift/historical_allocations/{vault_address}`; no API key.
|
|
656
|
+
* One HTTPS request, no RPC.
|
|
657
|
+
*
|
|
658
|
+
* @param params.vault EVM vault address.
|
|
659
|
+
* @param params.chainId Numeric chain id.
|
|
660
|
+
* @param params.startDate Optional inclusive lower bound, `YYYY-MM-DD`.
|
|
661
|
+
* @param params.endDate Optional inclusive upper bound, `YYYY-MM-DD`.
|
|
662
|
+
* @returns {@link ITransparencyHistoricalAllocations}.
|
|
663
|
+
* @throws AugustValidationError When arguments fail validation (no request is made).
|
|
664
|
+
* @throws AugustServerError When the API responds non-2xx (e.g. unknown vault 404, non-EVM vault 422).
|
|
665
|
+
* @throws AugustServerError (status 200) When the body is not the documented shape — backend contract drift.
|
|
666
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
667
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
668
|
+
* @example
|
|
669
|
+
* ```ts
|
|
670
|
+
* const h = await sdk.apiModule.getVaultHistoricalAllocations({ vault, chainId: 143, startDate: '2026-08-01' });
|
|
671
|
+
* const byDate = Map.groupBy(h.points, (p) => p.date);
|
|
672
|
+
* ```
|
|
673
|
+
*/
|
|
674
|
+
async getVaultHistoricalAllocations(params) {
|
|
675
|
+
const method = 'getVaultHistoricalAllocations';
|
|
676
|
+
assertTransparencyArgs(method, params.vault, params.chainId);
|
|
677
|
+
assertIsoDate(method, 'startDate', params.startDate);
|
|
678
|
+
assertIsoDate(method, 'endDate', params.endDate);
|
|
679
|
+
const data = await (0, fetcher_1.fetchTransparencyHistoricalAllocations)(params.vault, params.chainId, params.startDate, params.endDate, this.headers ?? undefined);
|
|
680
|
+
assertTransparencyEnvelope(data, method);
|
|
681
|
+
return data;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Fetch a vault's fee configuration — the Performance tab's fee card.
|
|
685
|
+
*
|
|
686
|
+
* Public `GET /upshift/fees/{vault_address}`; no API key. One HTTPS
|
|
687
|
+
* request, no RPC. Percent fields are already scaled (`management_fee_pct`
|
|
688
|
+
* of `1.5` means 1.5%).
|
|
689
|
+
*
|
|
690
|
+
* @param params.vault EVM vault address.
|
|
691
|
+
* @param params.chainId Numeric chain id.
|
|
692
|
+
* @returns {@link ITransparencyFees}.
|
|
693
|
+
* @throws AugustValidationError When arguments fail validation (no request is made).
|
|
694
|
+
* @throws AugustServerError When the API responds non-2xx (e.g. unknown vault 404, non-EVM vault 422).
|
|
695
|
+
* @throws AugustServerError (status 200) When the body is not the documented shape — backend contract drift.
|
|
696
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
697
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
698
|
+
* @example
|
|
699
|
+
* ```ts
|
|
700
|
+
* const fees = await sdk.apiModule.getVaultFeeConfig({ vault, chainId: 143 });
|
|
701
|
+
* console.log(`${fees.management_fee_pct}% mgmt / ${fees.performance_fee_pct}% perf`);
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
704
|
+
async getVaultFeeConfig(params) {
|
|
705
|
+
const method = 'getVaultFeeConfig';
|
|
706
|
+
assertTransparencyArgs(method, params.vault, params.chainId);
|
|
707
|
+
const data = await (0, fetcher_1.fetchTransparencyFees)(params.vault, params.chainId, this.headers ?? undefined);
|
|
708
|
+
assertTransparencyEnvelope(data, method);
|
|
709
|
+
return data;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Fetch the vault's privileged addresses (owner / operators) with custody
|
|
713
|
+
* enrichment — the Governance tab's "Vault Roles" card.
|
|
714
|
+
*
|
|
715
|
+
* Public `GET /upshift/governance/{vault_address}/roles`; no API key. One
|
|
716
|
+
* HTTPS request from the SDK (the backend performs the on-chain reads).
|
|
717
|
+
* Third-party enrichment failures (Safe / Fordefi) degrade rows and append
|
|
718
|
+
* to `warnings` rather than failing.
|
|
719
|
+
*
|
|
720
|
+
* @param params.vault EVM vault address.
|
|
721
|
+
* @param params.chainId Numeric chain id.
|
|
722
|
+
* @returns {@link ITransparencyGovernanceRoles}.
|
|
723
|
+
* @throws AugustValidationError When arguments fail validation (no request is made).
|
|
724
|
+
* @throws AugustServerError When the API responds non-2xx (e.g. unknown vault 404, non-EVM vault 422).
|
|
725
|
+
* @throws AugustServerError (status 200) When the body is not the documented shape — backend contract drift.
|
|
726
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
727
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
728
|
+
* @example
|
|
729
|
+
* ```ts
|
|
730
|
+
* const { roles, warnings } = await sdk.apiModule.getVaultGovernanceRoles({ vault, chainId: 143 });
|
|
731
|
+
* const owner = roles.find((r) => r.role === 'owner'); // owner?.is_safe → Safe threshold in safe_threshold
|
|
732
|
+
* ```
|
|
733
|
+
*/
|
|
734
|
+
async getVaultGovernanceRoles(params) {
|
|
735
|
+
const method = 'getVaultGovernanceRoles';
|
|
736
|
+
assertTransparencyArgs(method, params.vault, params.chainId);
|
|
737
|
+
const data = await (0, fetcher_1.fetchTransparencyGovernanceRoles)(params.vault, params.chainId, this.headers ?? undefined);
|
|
738
|
+
assertTransparencyEnvelope(data, method);
|
|
739
|
+
return data;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Fetch the integrations each vault wallet is whitelisted to operate —
|
|
743
|
+
* the Governance tab's "Vault Permissions" table.
|
|
744
|
+
*
|
|
745
|
+
* Public `GET /upshift/governance/{vault_address}/permissions`; no API key.
|
|
746
|
+
* One HTTPS request, no RPC.
|
|
747
|
+
*
|
|
748
|
+
* @param params.vault EVM vault address.
|
|
749
|
+
* @param params.chainId Numeric chain id.
|
|
750
|
+
* @returns {@link ITransparencyGovernancePermissions}.
|
|
751
|
+
* @throws AugustValidationError When arguments fail validation (no request is made).
|
|
752
|
+
* @throws AugustServerError When the API responds non-2xx (e.g. unknown vault 404, non-EVM vault 422).
|
|
753
|
+
* @throws AugustServerError (status 200) When the body is not the documented shape — backend contract drift.
|
|
754
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
755
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
756
|
+
* @example
|
|
757
|
+
* ```ts
|
|
758
|
+
* const { permissions } = await sdk.apiModule.getVaultGovernancePermissions({ vault, chainId: 143 });
|
|
759
|
+
* for (const p of permissions) console.log(p.integration, p.functions.join(','));
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
async getVaultGovernancePermissions(params) {
|
|
763
|
+
const method = 'getVaultGovernancePermissions';
|
|
764
|
+
assertTransparencyArgs(method, params.vault, params.chainId);
|
|
765
|
+
const data = await (0, fetcher_1.fetchTransparencyGovernancePermissions)(params.vault, params.chainId, this.headers ?? undefined);
|
|
766
|
+
assertTransparencyEnvelope(data, method);
|
|
767
|
+
return data;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Fetch the vault's timelock queue — the Governance tab's "Pending
|
|
771
|
+
* Timelocks" table. Defaults to pending (`scheduled`) requests.
|
|
772
|
+
*
|
|
773
|
+
* Public `GET /upshift/governance/{vault_address}/timelocks`; no API key.
|
|
774
|
+
* `executable_at` is `scheduled_at + TIMELOCK_DURATION()` read live from
|
|
775
|
+
* the timelock contract; null (plus a warning) when that read failed.
|
|
776
|
+
* The default filter is pending only — the list is often empty; pass
|
|
777
|
+
* `status: 'all'` for history. `getTimelockRequests` returns the raw
|
|
778
|
+
* backend rows; this returns the dashboard view (labels, `executable_at`,
|
|
779
|
+
* warnings).
|
|
780
|
+
*
|
|
781
|
+
* @param params.vault EVM vault address.
|
|
782
|
+
* @param params.chainId Numeric chain id.
|
|
783
|
+
* @param params.status Filter: a single {@link ITransparencyTimelockStatus} or `'all'`. Default `'scheduled'`. Any other string is rejected with `AugustValidationError` before a request is made.
|
|
784
|
+
* @returns {@link ITransparencyTimelocks}.
|
|
785
|
+
* @throws AugustValidationError When arguments fail validation (no request is made).
|
|
786
|
+
* @throws AugustServerError When the API responds non-2xx (e.g. unknown vault 404, non-EVM vault 422).
|
|
787
|
+
* @throws AugustServerError (status 200) When the body is not the documented shape — backend contract drift.
|
|
788
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
789
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
790
|
+
* @example
|
|
791
|
+
* ```ts
|
|
792
|
+
* const { timelocks } = await sdk.apiModule.getVaultGovernanceTimelocks({ vault, chainId: 1 }); // pending only
|
|
793
|
+
* const ready = timelocks.filter((t) => t.executable_at && Date.parse(`${t.executable_at}Z`) <= Date.now());
|
|
794
|
+
* ```
|
|
795
|
+
*/
|
|
796
|
+
async getVaultGovernanceTimelocks(params) {
|
|
797
|
+
const method = 'getVaultGovernanceTimelocks';
|
|
798
|
+
assertTransparencyArgs(method, params.vault, params.chainId);
|
|
799
|
+
assertOneOf(method, 'status', params.status, TRANSPARENCY_TIMELOCK_STATUSES);
|
|
800
|
+
const data = await (0, fetcher_1.fetchTransparencyGovernanceTimelocks)(params.vault, params.chainId, params.status, this.headers ?? undefined);
|
|
801
|
+
assertTransparencyEnvelope(data, method);
|
|
802
|
+
return data;
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Fetch one page of the vault's governance audit log, newest first — the
|
|
806
|
+
* Governance tab's "Audit Log" timeline. Merges live timelock events with
|
|
807
|
+
* manually recorded entries (attestations, permission changes).
|
|
808
|
+
*
|
|
809
|
+
* Public `GET /upshift/governance/{vault_address}/audit_log`; no API key.
|
|
810
|
+
* Paginate with `before` = the last returned entry's `timestamp` while
|
|
811
|
+
* `has_more` is true (exclusive cursor; ties at the exact boundary
|
|
812
|
+
* timestamp are skipped, never duplicated).
|
|
813
|
+
*
|
|
814
|
+
* @param params.vault EVM vault address.
|
|
815
|
+
* @param params.chainId Numeric chain id.
|
|
816
|
+
* @param params.category Optional {@link ITransparencyAuditCategory} filter. Any other string is rejected with `AugustValidationError` before a request is made.
|
|
817
|
+
* @param params.before Optional exclusive cursor — pass the previous page's last `entry.timestamp` back verbatim (naive-UTC, no offset).
|
|
818
|
+
* @param params.limit Page size, 1–200. Backend default 50.
|
|
819
|
+
* @returns {@link ITransparencyAuditLog}.
|
|
820
|
+
* @throws AugustValidationError When arguments fail validation (no request is made).
|
|
821
|
+
* @throws AugustServerError When the API responds non-2xx (e.g. unknown vault 404, non-EVM vault 422).
|
|
822
|
+
* @throws AugustServerError (status 200) When the body is not the documented shape — backend contract drift.
|
|
823
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
824
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
825
|
+
* @example
|
|
826
|
+
* ```ts
|
|
827
|
+
* // Walk the whole log, newest first.
|
|
828
|
+
* let before: string | undefined;
|
|
829
|
+
* do {
|
|
830
|
+
* const page = await sdk.apiModule.getVaultGovernanceAuditLog({ vault, chainId: 1, before, limit: 50 });
|
|
831
|
+
* for (const e of page.entries) console.log(e.timestamp, e.type, e.summary);
|
|
832
|
+
* before = page.has_more ? page.entries.at(-1)?.timestamp : undefined;
|
|
833
|
+
* } while (before);
|
|
834
|
+
* ```
|
|
835
|
+
*/
|
|
836
|
+
async getVaultGovernanceAuditLog(params) {
|
|
837
|
+
const method = 'getVaultGovernanceAuditLog';
|
|
838
|
+
assertTransparencyArgs(method, params.vault, params.chainId);
|
|
839
|
+
assertOneOf(method, 'category', params.category, TRANSPARENCY_AUDIT_CATEGORIES);
|
|
840
|
+
if (params.limit !== undefined &&
|
|
841
|
+
(!Number.isInteger(params.limit) ||
|
|
842
|
+
params.limit < 1 ||
|
|
843
|
+
params.limit > 200)) {
|
|
844
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: limit must be an integer between 1 and 200, got ${params.limit}.`);
|
|
845
|
+
}
|
|
846
|
+
const data = await (0, fetcher_1.fetchTransparencyGovernanceAuditLog)(params.vault, params.chainId, params.category, params.before, params.limit, this.headers ?? undefined);
|
|
847
|
+
assertTransparencyEnvelope(data, method);
|
|
848
|
+
return data;
|
|
849
|
+
}
|
|
424
850
|
/**
|
|
425
851
|
* Fetch the historical unrealized-PnL series for a vault, newest first,
|
|
426
852
|
* as computed by the August backend from periodic vault snapshots.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IAddress, type IHistoricalTimeseriesResponse, type INormalizedNumber, type ISubgraphWithdrawProccessed, type IVault, type IVaultAllocations, type IVaultAnnualizedApy, type IVaultAvailableRedemption, type IVaultLoan, type IVaultPosition, type IVaultRedemptionHistoryItem, type IVaultSummary, type IVaultWithdrawals, type IVaultPendingRedemptions, type IActiveStakingPosition, type IVaultHistoricalParams, type IVaultUserLifetimePnl, type IVaultBorrowerHealthFactor, type IVaultPnl, type VaultAddress } from '../../types';
|
|
1
|
+
import { type IAddress, type IHistoricalTimeseriesResponse, type INormalizedNumber, type ITokenizedVault, type ISubgraphWithdrawProccessed, type IVault, type IVaultAllocations, type IVaultAnnualizedApy, type IVaultAvailableRedemption, type IVaultLoan, type IVaultPosition, type IVaultRedemptionHistoryItem, type IVaultSummary, type IVaultWithdrawals, type IVaultPendingRedemptions, type IActiveStakingPosition, type IVaultHistoricalParams, type IVaultUserLifetimePnl, type IVaultBorrowerHealthFactor, type IVaultPnl, type VaultAddress } from '../../types';
|
|
2
2
|
import type { IVaultBaseOptions } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Vault Data Getters
|
|
@@ -23,15 +23,22 @@ import type { IVaultBaseOptions } from './types';
|
|
|
23
23
|
* @param loans - Include active loan data
|
|
24
24
|
* @param allocations - Include DeFi/CeFi allocation breakdowns
|
|
25
25
|
* @param options - RPC and service configuration
|
|
26
|
+
* @param tokenizedVault - Optional pre-fetched backend row for `vault`. When a
|
|
27
|
+
* caller already holds the row (e.g. `getVaults` fetched the whole list one
|
|
28
|
+
* call earlier), passing it skips this function's own
|
|
29
|
+
* `GET /tokenized_vault/{address}` — a pure de-duplication of backend
|
|
30
|
+
* traffic. The row must have been fetched with the same
|
|
31
|
+
* `loadSubaccounts`/`loadSnapshots` flags the caller passes here.
|
|
26
32
|
* @returns Complete vault object with optional enrichments
|
|
27
33
|
*/
|
|
28
|
-
export declare function getVault({ vault, loans, allocations, options, loadSubaccounts, loadSnapshots, }: {
|
|
34
|
+
export declare function getVault({ vault, loans, allocations, options, loadSubaccounts, loadSnapshots, tokenizedVault: prefetchedRow, }: {
|
|
29
35
|
vault: IAddress;
|
|
30
36
|
loans?: boolean;
|
|
31
37
|
allocations?: boolean;
|
|
32
38
|
options: IVaultBaseOptions;
|
|
33
39
|
loadSubaccounts?: boolean;
|
|
34
40
|
loadSnapshots?: boolean;
|
|
41
|
+
tokenizedVault?: ITokenizedVault;
|
|
35
42
|
}): Promise<IVault>;
|
|
36
43
|
/**
|
|
37
44
|
* Vault Loans
|
|
@@ -112,13 +112,19 @@ const errors_1 = require("../../core/errors");
|
|
|
112
112
|
* @param loans - Include active loan data
|
|
113
113
|
* @param allocations - Include DeFi/CeFi allocation breakdowns
|
|
114
114
|
* @param options - RPC and service configuration
|
|
115
|
+
* @param tokenizedVault - Optional pre-fetched backend row for `vault`. When a
|
|
116
|
+
* caller already holds the row (e.g. `getVaults` fetched the whole list one
|
|
117
|
+
* call earlier), passing it skips this function's own
|
|
118
|
+
* `GET /tokenized_vault/{address}` — a pure de-duplication of backend
|
|
119
|
+
* traffic. The row must have been fetched with the same
|
|
120
|
+
* `loadSubaccounts`/`loadSnapshots` flags the caller passes here.
|
|
115
121
|
* @returns Complete vault object with optional enrichments
|
|
116
122
|
*/
|
|
117
|
-
async function getVault({ vault, loans = false, allocations = false, options, loadSubaccounts, loadSnapshots, }) {
|
|
123
|
+
async function getVault({ vault, loans = false, allocations = false, options, loadSubaccounts, loadSnapshots, tokenizedVault: prefetchedRow, }) {
|
|
118
124
|
let returnedVault;
|
|
119
125
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
126
|
+
const tokenizedVault = prefetchedRow ??
|
|
127
|
+
(await (0, core_1.fetchTokenizedVault)(vault, undefined, loadSubaccounts, loadSnapshots))?.[0];
|
|
122
128
|
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
123
129
|
switch (vaultVersion) {
|
|
124
130
|
case 'sol-0': {
|
|
@@ -13,8 +13,8 @@ import { AugustBase, type IAugustBase } from '../../core';
|
|
|
13
13
|
import SuiAdapter from '../../adapters/sui';
|
|
14
14
|
import { type IContractWriteOptions, type INativeDepositOptions } from './write.actions';
|
|
15
15
|
import type { Signer, Wallet } from 'ethers';
|
|
16
|
-
import type { IVaultBaseOptions, IVaultCustomOptions } from './types';
|
|
17
|
-
export type { IVaultBaseOptions, IVaultCustomOptions } from './types';
|
|
16
|
+
import type { IGetVaultsOptions, IVaultBaseOptions, IVaultCustomOptions } from './types';
|
|
17
|
+
export type { IGetVaultsOptions, IVaultBaseOptions, IVaultCustomOptions, } from './types';
|
|
18
18
|
/**
|
|
19
19
|
* Vault operations class handling multi-chain vault queries and user positions.
|
|
20
20
|
* Supports both EVM and Solana vaults with unified interface.
|
|
@@ -64,32 +64,7 @@ export declare class AugustVaults extends AugustBase {
|
|
|
64
64
|
* @param options Filtering and enrichment configuration
|
|
65
65
|
* @returns Array of vault objects with optional loans/allocations/positions
|
|
66
66
|
*/
|
|
67
|
-
getVaults(options?:
|
|
68
|
-
chainIds?: number[];
|
|
69
|
-
loadSubaccounts?: boolean;
|
|
70
|
-
loadSnapshots?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Portfolio mode: include closed vaults in the result.
|
|
73
|
-
*
|
|
74
|
-
* By default (`false`) closed vaults are excluded, so marketplace /
|
|
75
|
-
* discovery callers never receive a `status: 'closed'` vault. When set,
|
|
76
|
-
* closed vaults are returned regardless of `is_visible` (closed +
|
|
77
|
-
* invisible vaults bucket as closed), so a consumer joining user
|
|
78
|
-
* positions can render a position held in a closed vault on the
|
|
79
|
-
* portfolio page.
|
|
80
|
-
*
|
|
81
|
-
* In this mode, loans/allocations enrichment is also skipped for closed
|
|
82
|
-
* vaults: they have none, and the per-vault enrichment
|
|
83
|
-
* (`getVault` → `getVaultAllocations`) otherwise re-throws when a closed
|
|
84
|
-
* vault has no live strategy/debank data or no subaccounts, which would
|
|
85
|
-
* land the vault in the `failed` bucket and silently drop it before it
|
|
86
|
-
* reaches the filter. Skipping enrichment lets the vault survive on its
|
|
87
|
-
* backend metadata + base on-chain read.
|
|
88
|
-
*
|
|
89
|
-
* @default false
|
|
90
|
-
*/
|
|
91
|
-
includeClosed?: boolean;
|
|
92
|
-
} & IVaultCustomOptions): Promise<import("../../types").IVault[]>;
|
|
67
|
+
getVaults(options?: IGetVaultsOptions): Promise<import("../../types").IVault[]>;
|
|
93
68
|
/**
|
|
94
69
|
* Calculate total deposited across all tokenized vaults by summing latest_reported_tvl.
|
|
95
70
|
* Uses the /tokenized_vault endpoint which returns latest_reported_tvl in USD.
|