@augustdigital/sdk 8.8.0 → 8.9.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/core/analytics/method-taxonomy.js +16 -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 +32 -0
- package/lib/core/constants/core.js +72 -0
- package/lib/core/constants/vaults.d.ts +5 -0
- package/lib/core/constants/vaults.js +7 -0
- package/lib/main.js +1 -1
- package/lib/modules/api/fetcher.d.ts +82 -0
- package/lib/modules/api/fetcher.js +150 -0
- package/lib/modules/api/main.d.ts +263 -2
- package/lib/modules/api/main.js +353 -4
- package/lib/modules/sub-accounts/fetcher.d.ts +28 -1
- package/lib/modules/sub-accounts/fetcher.js +51 -1
- package/lib/modules/sub-accounts/main.d.ts +93 -1
- package/lib/modules/sub-accounts/main.js +123 -0
- package/lib/sdk.d.ts +757 -1
- package/lib/types/api.d.ts +280 -0
- package/lib/types/api.js +3 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/sub-accounts.d.ts +36 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { AugustBase, type IAugustBase } from '../../core/base.class';
|
|
2
|
+
import type { ICollateralExcessOrDeficit, ICollateralSimulationInput, ICollateralSimulationResults, ICuratorWhitelistStatus, IDiscountFactorLadder, ILoanBookInfo, IOracleClassification, IOtcMarginRequirement, IOtcPositionRead, IRevertReason, ITimelockRequest, IUnrealizedPnlSnapshot, IVaultPerformanceFees, IWSSubaccountListItem } from '../../types';
|
|
2
3
|
/**
|
|
3
4
|
* Read-only client for August backend REST endpoints that have no on-chain
|
|
4
5
|
* equivalent — currently the unrealized-PnL series the backend computes
|
|
@@ -11,8 +12,268 @@ import type { IUnrealizedPnlSnapshot } from '../../types';
|
|
|
11
12
|
*
|
|
12
13
|
* Accessible as `apiModule` on the SDK instance; the same methods are also
|
|
13
14
|
* exposed directly on the SDK class.
|
|
15
|
+
*
|
|
16
|
+
* A subset of methods (loan book, risk) hit authenticated admin-only backend
|
|
17
|
+
* endpoints and require an admin-scoped August API key on the SDK
|
|
18
|
+
* constructor; each such method documents the requirement.
|
|
14
19
|
*/
|
|
15
|
-
export declare class AugustApi {
|
|
20
|
+
export declare class AugustApi extends AugustBase {
|
|
21
|
+
private headers;
|
|
22
|
+
constructor(baseConfig: IAugustBase);
|
|
23
|
+
/**
|
|
24
|
+
* Retrieve the global loan-book aggregate across every active client
|
|
25
|
+
* subaccount — one {@link ILoanBookInfo} entry per loan, with principal /
|
|
26
|
+
* interest amounts, APRs, state, and the next upcoming payment.
|
|
27
|
+
*
|
|
28
|
+
* Backed by the admin-only `GET /dashboard/loans` backend endpoint (60-second
|
|
29
|
+
* server-side cache), so the August API key configured on the SDK must
|
|
30
|
+
* belong to an admin user. Makes exactly one HTTP request and no RPC calls.
|
|
31
|
+
*
|
|
32
|
+
* @returns Array of loan-book entries; empty when there are no active loans.
|
|
33
|
+
* @throws AugustAuthError When the API key is missing or not admin-scoped.
|
|
34
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
35
|
+
* @example
|
|
36
|
+
* const loans = await sdk.apiModule.getDashboardLoans();
|
|
37
|
+
* const active = loans.filter((l) => l.state === 'ACTIVE');
|
|
38
|
+
*/
|
|
39
|
+
getDashboardLoans(): Promise<ILoanBookInfo[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieve every token discount-factor ladder the risk engine applies when
|
|
42
|
+
* valuing collateral.
|
|
43
|
+
*
|
|
44
|
+
* Backed by `GET /risk/discount_factors` (60-second server-side cache),
|
|
45
|
+
* which requires an authenticated August user; an admin-scoped API key
|
|
46
|
+
* works. Makes exactly one HTTP request and no RPC calls.
|
|
47
|
+
*
|
|
48
|
+
* @returns Array of {@link IDiscountFactorLadder}, one per whitelisted token that has a configured ladder.
|
|
49
|
+
* @throws AugustAuthError When the API key is missing or not authorized.
|
|
50
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
51
|
+
* @example
|
|
52
|
+
* const ladders = await sdk.apiModule.getDiscountFactors();
|
|
53
|
+
* console.log(ladders.map((d) => `${d.address}@${d.chain}`));
|
|
54
|
+
*/
|
|
55
|
+
getDiscountFactors(): Promise<IDiscountFactorLadder[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Compute how much collateral a subaccount has in excess of — or is short
|
|
58
|
+
* of — what it needs to hold a target health factor, for one collateral
|
|
59
|
+
* token.
|
|
60
|
+
*
|
|
61
|
+
* Backed by `GET /risk/collateral_excess_or_deficit` (60-second server-side
|
|
62
|
+
* cache), which resolves the subaccount and reads its current health factor,
|
|
63
|
+
* so an authenticated (admin-scoped) August API key is required. Makes
|
|
64
|
+
* exactly one HTTP request and no RPC calls.
|
|
65
|
+
*
|
|
66
|
+
* @param params.subaccount Subaccount (smart-contract wallet) address.
|
|
67
|
+
* @param params.tokenAddress Collateral token address to evaluate.
|
|
68
|
+
* @param params.tokenChain Numeric August chain id of the token (e.g. `1` for Ethereum mainnet).
|
|
69
|
+
* @param params.targetHealthFactor Health factor to solve for. Defaults server-side to the minimum healthy factor (1.2); when supplied must be a finite number greater than 0.
|
|
70
|
+
* @returns The signed excess (positive) or deficit (negative) in USD and token units. Zeroes when the subaccount has no debt.
|
|
71
|
+
* @throws AugustValidationError When an address is invalid, `tokenChain` is not an integer, or `targetHealthFactor` is out of range.
|
|
72
|
+
* @throws AugustServerError When the token has no discount factor (backend 404) or the API otherwise responds non-2xx.
|
|
73
|
+
* @example
|
|
74
|
+
* const r = await sdk.apiModule.getCollateralExcessOrDeficit({
|
|
75
|
+
* subaccount: '0xabc…',
|
|
76
|
+
* tokenAddress: '0xdef…',
|
|
77
|
+
* tokenChain: 1,
|
|
78
|
+
* });
|
|
79
|
+
* console.log(r.amount_usd > 0 ? 'excess' : 'deficit');
|
|
80
|
+
*/
|
|
81
|
+
getCollateralExcessOrDeficit(params: {
|
|
82
|
+
subaccount: string;
|
|
83
|
+
tokenAddress: string;
|
|
84
|
+
tokenChain: number;
|
|
85
|
+
targetHealthFactor?: number;
|
|
86
|
+
}): Promise<ICollateralExcessOrDeficit>;
|
|
87
|
+
/**
|
|
88
|
+
* Simulate the collateral required to open a hypothetical loan against a
|
|
89
|
+
* chosen basket of collateral tokens.
|
|
90
|
+
*
|
|
91
|
+
* This is a pure, read-only simulation: the backend `POST
|
|
92
|
+
* /risk/collateral_simulation` endpoint (60-second server-side cache)
|
|
93
|
+
* computes required collateral and effective discount factors and changes
|
|
94
|
+
* no state. It runs against the authenticated backend, so an
|
|
95
|
+
* (admin-scoped) August API key is required. Makes exactly one HTTP request
|
|
96
|
+
* and no RPC calls.
|
|
97
|
+
*
|
|
98
|
+
* @param input Simulation parameters — see {@link ICollateralSimulationInput}. `collateral_tokens` and `collateral_token_allocation` must be non-empty and equal length; when `on_platform` is `true`, both `loan_redeployed_token_*` fields are required.
|
|
99
|
+
* @returns The simulated {@link ICollateralSimulationResults}: total debt, required collateral, resulting health factor, and a per-token breakdown.
|
|
100
|
+
* @throws AugustValidationError When addresses are invalid, `loan_amount` is not a finite non-negative number, the collateral arrays are empty / mismatched, or `on_platform` is set without redeployed-token details.
|
|
101
|
+
* @throws AugustServerError When the API responds with a non-2xx status (e.g. a token missing a discount factor).
|
|
102
|
+
* @example
|
|
103
|
+
* const sim = await sdk.apiModule.simulateCollateral({
|
|
104
|
+
* loan_token_chain: 1,
|
|
105
|
+
* loan_token_address: '0xloan…',
|
|
106
|
+
* loan_amount: 1_000_000,
|
|
107
|
+
* collateral_tokens: [[1, '0xcol…']],
|
|
108
|
+
* collateral_token_allocation: [1],
|
|
109
|
+
* });
|
|
110
|
+
* console.log(sim.total_required_collateral_usd);
|
|
111
|
+
*/
|
|
112
|
+
simulateCollateral(input: ICollateralSimulationInput): Promise<ICollateralSimulationResults>;
|
|
113
|
+
/**
|
|
114
|
+
* Fetch the decoded revert reason(s) for a transaction — error messages,
|
|
115
|
+
* revert strings, and recognized universal-subaccount errors extracted from
|
|
116
|
+
* a `debug_traceTransaction` call tree.
|
|
117
|
+
*
|
|
118
|
+
* Backed by the public (unauthenticated) `GET /revert_reason` endpoint; no
|
|
119
|
+
* API key required. The backend relies on the target chain's RPC supporting
|
|
120
|
+
* `debug_trace*`; on chains/RPCs without it the backend returns a 5xx whose
|
|
121
|
+
* detail explains why, surfaced here as an {@link AugustServerError}. Makes
|
|
122
|
+
* exactly one HTTP request and no RPC calls from the SDK itself.
|
|
123
|
+
*
|
|
124
|
+
* @param txHash Transaction hash to trace.
|
|
125
|
+
* @param chain Numeric August chain id the transaction is on (e.g. `1` for Ethereum mainnet).
|
|
126
|
+
* @returns The decoded {@link IRevertReason}; all arrays empty when the trace yielded no matching signal.
|
|
127
|
+
* @throws AugustValidationError When `txHash` is empty or `chain` is not an integer.
|
|
128
|
+
* @throws AugustServerError When the chain/RPC does not support tracing, or the API otherwise responds non-2xx.
|
|
129
|
+
* @example
|
|
130
|
+
* const r = await sdk.apiModule.getRevertReason('0xabc…', 1);
|
|
131
|
+
* console.log(r.revert_reasons);
|
|
132
|
+
*/
|
|
133
|
+
getRevertReason(txHash: string, chain: number): Promise<IRevertReason>;
|
|
134
|
+
/**
|
|
135
|
+
* Retrieve every tracked OTC position.
|
|
136
|
+
*
|
|
137
|
+
* Backed by the admin-only `GET /otc/position` backend endpoint, so the
|
|
138
|
+
* configured August API key must belong to an admin user. Makes exactly one
|
|
139
|
+
* HTTP request and no RPC calls.
|
|
140
|
+
*
|
|
141
|
+
* @returns Array of {@link IOtcPositionRead}; empty when there are no OTC positions.
|
|
142
|
+
* @throws AugustAuthError When the API key is missing or not admin-scoped.
|
|
143
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
144
|
+
* @example
|
|
145
|
+
* const positions = await sdk.apiModule.getOtcPositions();
|
|
146
|
+
*/
|
|
147
|
+
getOtcPositions(): Promise<IOtcPositionRead[]>;
|
|
148
|
+
/**
|
|
149
|
+
* Retrieve OTC margin requirements, optionally filtered by counterparty
|
|
150
|
+
* and/or payer.
|
|
151
|
+
*
|
|
152
|
+
* Backed by the admin-only `GET /otc/margin_requirement` backend endpoint,
|
|
153
|
+
* so the configured August API key must belong to an admin user. Makes
|
|
154
|
+
* exactly one HTTP request and no RPC calls.
|
|
155
|
+
*
|
|
156
|
+
* @param options - Optional filters
|
|
157
|
+
* @param options.otcCounterpartyId - Restrict to a single counterparty (UUID)
|
|
158
|
+
* @param options.payer - Restrict to a single payer address
|
|
159
|
+
* @returns Array of {@link IOtcMarginRequirement} matching the filters (all when none given).
|
|
160
|
+
* @throws AugustAuthError When the API key is missing or not admin-scoped.
|
|
161
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
162
|
+
* @example
|
|
163
|
+
* const reqs = await sdk.apiModule.getOtcMarginRequirements({ payer: '0xabc…' });
|
|
164
|
+
*/
|
|
165
|
+
getOtcMarginRequirements(options?: {
|
|
166
|
+
otcCounterpartyId?: string;
|
|
167
|
+
payer?: string;
|
|
168
|
+
}): Promise<IOtcMarginRequirement[]>;
|
|
169
|
+
/**
|
|
170
|
+
* List the subaccounts linked to a vault (curator surface).
|
|
171
|
+
*
|
|
172
|
+
* Backed by the curator-or-admin `GET
|
|
173
|
+
* /curator/vaults/{vault_address}/subaccounts` backend endpoint, so the
|
|
174
|
+
* configured August API key must belong to the vault's curator or an admin.
|
|
175
|
+
* Makes exactly one HTTP request and no RPC calls.
|
|
176
|
+
*
|
|
177
|
+
* @param vaultAddress - The vault address (EVM `0x…`, Solana, or Stellar)
|
|
178
|
+
* @returns Array of subaccount records linked to the vault (same shape as the subaccount directory); empty when none are linked.
|
|
179
|
+
* @throws AugustValidationError When `vaultAddress` is not a valid address.
|
|
180
|
+
* @throws AugustAuthError When the API key is missing or not curator/admin for the vault.
|
|
181
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
182
|
+
* @example
|
|
183
|
+
* const subs = await sdk.apiModule.getCuratorVaultSubaccounts('0xvault…');
|
|
184
|
+
*/
|
|
185
|
+
getCuratorVaultSubaccounts(vaultAddress: string): Promise<IWSSubaccountListItem[]>;
|
|
186
|
+
/**
|
|
187
|
+
* Get on-chain whitelist status for every subaccount linked to a vault
|
|
188
|
+
* (curator surface).
|
|
189
|
+
*
|
|
190
|
+
* Backed by the curator-or-admin `GET
|
|
191
|
+
* /curator/vaults/{vault_address}/whitelist` backend endpoint. EVM vaults
|
|
192
|
+
* only — non-EVM vaults manage access internally and the backend returns a
|
|
193
|
+
* 400 (surfaced as {@link AugustServerError}). Makes exactly one HTTP
|
|
194
|
+
* request and no RPC calls from the SDK.
|
|
195
|
+
*
|
|
196
|
+
* @param vaultAddress - The EVM vault address (`0x…`)
|
|
197
|
+
* @returns Array of {@link ICuratorWhitelistStatus}, one per linked subaccount; empty when the vault has no subaccounts.
|
|
198
|
+
* @throws AugustValidationError When `vaultAddress` is not a valid address.
|
|
199
|
+
* @throws AugustAuthError When the API key is missing or not curator/admin for the vault.
|
|
200
|
+
* @throws AugustServerError When the vault is non-EVM (backend 400) or the API otherwise responds non-2xx.
|
|
201
|
+
* @example
|
|
202
|
+
* const status = await sdk.apiModule.getCuratorVaultWhitelist('0xvault…');
|
|
203
|
+
* console.log(status.filter((s) => !s.is_whitelisted));
|
|
204
|
+
*/
|
|
205
|
+
getCuratorVaultWhitelist(vaultAddress: string): Promise<ICuratorWhitelistStatus[]>;
|
|
206
|
+
/**
|
|
207
|
+
* List timelock (governance) requests for a vault on a chain, optionally
|
|
208
|
+
* filtered by status.
|
|
209
|
+
*
|
|
210
|
+
* Backed by the `GET /timelock-requests` backend endpoint. Makes exactly one
|
|
211
|
+
* HTTP request and no RPC calls.
|
|
212
|
+
*
|
|
213
|
+
* @param params.vaultAddress The vault address the requests target.
|
|
214
|
+
* @param params.chainId Numeric August chain id (must be a positive integer).
|
|
215
|
+
* @param params.status Status filter: `"scheduled"` (backend default), `"executed"`, `"cancelled"`, or `"all"`. Omit to use the backend default.
|
|
216
|
+
* @returns Array of {@link ITimelockRequest}; empty when the vault has no matching requests.
|
|
217
|
+
* @throws AugustValidationError When `vaultAddress` is invalid or `chainId` is not a positive integer.
|
|
218
|
+
* @throws AugustServerError When the API responds with a non-2xx status (e.g. an invalid status filter).
|
|
219
|
+
* @example
|
|
220
|
+
* const reqs = await sdk.apiModule.getTimelockRequests({ vaultAddress: '0xvault…', chainId: 1 });
|
|
221
|
+
*/
|
|
222
|
+
getTimelockRequests(params: {
|
|
223
|
+
vaultAddress: string;
|
|
224
|
+
chainId: number;
|
|
225
|
+
status?: string;
|
|
226
|
+
}): Promise<ITimelockRequest[]>;
|
|
227
|
+
/**
|
|
228
|
+
* Compute a vault's performance fees over a period (backend-computed from
|
|
229
|
+
* its snapshot history).
|
|
230
|
+
*
|
|
231
|
+
* Backed by `GET /metrics/vault_performance_fees`. The backend runs pandas
|
|
232
|
+
* over the vault's full snapshot history, so the first call is slow; results
|
|
233
|
+
* are cached server-side for 20 minutes. Makes exactly one HTTP request and
|
|
234
|
+
* no RPC calls.
|
|
235
|
+
*
|
|
236
|
+
* @param params.vault The vault address (EVM `0x…`, Solana, or Stellar).
|
|
237
|
+
* @param params.annualizedFeesPct Annualized performance-fee percentage. Defaults to 20.
|
|
238
|
+
* @param params.nativeDenominated Whether to denominate in the vault's native token. Defaults to `true`.
|
|
239
|
+
* @param params.calculationPeriod Period preset — `"YearToDate"` (default) or `"MonthToDate"`. Ignored by the backend when a custom `startDate`/`endDate` range is supplied.
|
|
240
|
+
* @param params.startDate ISO-8601 datetime range start. Must be supplied together with `endDate`.
|
|
241
|
+
* @param params.endDate ISO-8601 datetime range end. Must be supplied together with `startDate`.
|
|
242
|
+
* @returns The vault's {@link IVaultPerformanceFees} computation.
|
|
243
|
+
* @throws AugustValidationError When `vault` is invalid, or exactly one of `startDate`/`endDate` is supplied.
|
|
244
|
+
* @throws AugustServerError When there is insufficient snapshot data for the period, or the API otherwise responds non-2xx.
|
|
245
|
+
* @example
|
|
246
|
+
* const fees = await sdk.apiModule.getVaultPerformanceFees({ vault: '0xvault…' });
|
|
247
|
+
* console.log(fees.total_perf_fees_asset);
|
|
248
|
+
*/
|
|
249
|
+
getVaultPerformanceFees(params: {
|
|
250
|
+
vault: string;
|
|
251
|
+
annualizedFeesPct?: number;
|
|
252
|
+
nativeDenominated?: boolean;
|
|
253
|
+
calculationPeriod?: string;
|
|
254
|
+
startDate?: string;
|
|
255
|
+
endDate?: string;
|
|
256
|
+
}): Promise<IVaultPerformanceFees>;
|
|
257
|
+
/**
|
|
258
|
+
* Fetch a vault's NAV-oracle classification table — how each position/token
|
|
259
|
+
* is priced (Primary / Secondary Market / CeFi) and its USD value, plus
|
|
260
|
+
* warnings for tokens that could not be resolved.
|
|
261
|
+
*
|
|
262
|
+
* Backed by the public (unauthenticated) `GET
|
|
263
|
+
* /upshift/oracle_classification/{vault_address}` endpoint; no API key
|
|
264
|
+
* required. Reads the newest daily snapshot. Makes exactly one HTTP request
|
|
265
|
+
* and no RPC calls from the SDK.
|
|
266
|
+
*
|
|
267
|
+
* @param vault The vault address (EVM `0x…`, Solana, or Stellar).
|
|
268
|
+
* @param chainId Numeric August chain id the vault lives on.
|
|
269
|
+
* @returns The vault's {@link IOracleClassification}.
|
|
270
|
+
* @throws AugustValidationError When `vault` is invalid or `chainId` is not an integer.
|
|
271
|
+
* @throws AugustServerError When the vault or its snapshot is not found, or the API otherwise responds non-2xx.
|
|
272
|
+
* @example
|
|
273
|
+
* const cls = await sdk.apiModule.getVaultOracleClassification('0xvault…', 1);
|
|
274
|
+
* console.log(cls.warnings);
|
|
275
|
+
*/
|
|
276
|
+
getVaultOracleClassification(vault: string, chainId: number): Promise<IOracleClassification>;
|
|
16
277
|
/**
|
|
17
278
|
* Fetch the historical unrealized-PnL series for a vault, newest first,
|
|
18
279
|
* as computed by the August backend from periodic vault snapshots.
|
package/lib/modules/api/main.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AugustApi = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
|
+
const fetcher_1 = require("./fetcher");
|
|
6
|
+
const base_class_1 = require("../../core/base.class");
|
|
5
7
|
const core_1 = require("../../core/constants/core");
|
|
6
8
|
const errors_1 = require("../../core/errors");
|
|
7
|
-
const
|
|
9
|
+
const fetcher_2 = require("../../core/fetcher");
|
|
8
10
|
const chain_address_1 = require("../../core/helpers/chain-address");
|
|
9
11
|
function toUnrealizedPnlSnapshot(raw) {
|
|
10
12
|
return {
|
|
@@ -30,6 +32,14 @@ function assertVaultAddress(vault, method) {
|
|
|
30
32
|
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.`);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
35
|
+
function assertAddressArg(value, label, method) {
|
|
36
|
+
const valid = typeof value === 'string' &&
|
|
37
|
+
value.length > 0 &&
|
|
38
|
+
((0, ethers_1.isAddress)(value) || (0, chain_address_1.isSolanaAddress)(value) || (0, chain_address_1.isStellarAddress)(value));
|
|
39
|
+
if (!valid) {
|
|
40
|
+
throw new errors_1.AugustValidationError('INVALID_ADDRESS', `${method}: "${value}" is not a valid ${label} — pass an EVM (0x…), Solana, or Stellar address.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
33
43
|
const SNAPSHOT_STRING_FIELDS = [
|
|
34
44
|
'timestamp',
|
|
35
45
|
'vault_name',
|
|
@@ -70,8 +80,347 @@ function assertSnapshotArray(data, method) {
|
|
|
70
80
|
*
|
|
71
81
|
* Accessible as `apiModule` on the SDK instance; the same methods are also
|
|
72
82
|
* exposed directly on the SDK class.
|
|
83
|
+
*
|
|
84
|
+
* A subset of methods (loan book, risk) hit authenticated admin-only backend
|
|
85
|
+
* endpoints and require an admin-scoped August API key on the SDK
|
|
86
|
+
* constructor; each such method documents the requirement.
|
|
73
87
|
*/
|
|
74
|
-
class AugustApi {
|
|
88
|
+
class AugustApi extends base_class_1.AugustBase {
|
|
89
|
+
headers = null;
|
|
90
|
+
constructor(baseConfig) {
|
|
91
|
+
super(baseConfig);
|
|
92
|
+
this.headers = {
|
|
93
|
+
'x-environment': this.monitoring?.['x-environment'],
|
|
94
|
+
'x-user-id': this.monitoring?.['x-user-id'],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Retrieve the global loan-book aggregate across every active client
|
|
99
|
+
* subaccount — one {@link ILoanBookInfo} entry per loan, with principal /
|
|
100
|
+
* interest amounts, APRs, state, and the next upcoming payment.
|
|
101
|
+
*
|
|
102
|
+
* Backed by the admin-only `GET /dashboard/loans` backend endpoint (60-second
|
|
103
|
+
* server-side cache), so the August API key configured on the SDK must
|
|
104
|
+
* belong to an admin user. Makes exactly one HTTP request and no RPC calls.
|
|
105
|
+
*
|
|
106
|
+
* @returns Array of loan-book entries; empty when there are no active loans.
|
|
107
|
+
* @throws AugustAuthError When the API key is missing or not admin-scoped.
|
|
108
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
109
|
+
* @example
|
|
110
|
+
* const loans = await sdk.apiModule.getDashboardLoans();
|
|
111
|
+
* const active = loans.filter((l) => l.state === 'ACTIVE');
|
|
112
|
+
*/
|
|
113
|
+
async getDashboardLoans() {
|
|
114
|
+
return (0, fetcher_1.fetchDashboardLoans)(this.keys.august, this.headers ?? undefined);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Retrieve every token discount-factor ladder the risk engine applies when
|
|
118
|
+
* valuing collateral.
|
|
119
|
+
*
|
|
120
|
+
* Backed by `GET /risk/discount_factors` (60-second server-side cache),
|
|
121
|
+
* which requires an authenticated August user; an admin-scoped API key
|
|
122
|
+
* works. Makes exactly one HTTP request and no RPC calls.
|
|
123
|
+
*
|
|
124
|
+
* @returns Array of {@link IDiscountFactorLadder}, one per whitelisted token that has a configured ladder.
|
|
125
|
+
* @throws AugustAuthError When the API key is missing or not authorized.
|
|
126
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
127
|
+
* @example
|
|
128
|
+
* const ladders = await sdk.apiModule.getDiscountFactors();
|
|
129
|
+
* console.log(ladders.map((d) => `${d.address}@${d.chain}`));
|
|
130
|
+
*/
|
|
131
|
+
async getDiscountFactors() {
|
|
132
|
+
return (0, fetcher_1.fetchDiscountFactors)(this.keys.august, this.headers ?? undefined);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Compute how much collateral a subaccount has in excess of — or is short
|
|
136
|
+
* of — what it needs to hold a target health factor, for one collateral
|
|
137
|
+
* token.
|
|
138
|
+
*
|
|
139
|
+
* Backed by `GET /risk/collateral_excess_or_deficit` (60-second server-side
|
|
140
|
+
* cache), which resolves the subaccount and reads its current health factor,
|
|
141
|
+
* so an authenticated (admin-scoped) August API key is required. Makes
|
|
142
|
+
* exactly one HTTP request and no RPC calls.
|
|
143
|
+
*
|
|
144
|
+
* @param params.subaccount Subaccount (smart-contract wallet) address.
|
|
145
|
+
* @param params.tokenAddress Collateral token address to evaluate.
|
|
146
|
+
* @param params.tokenChain Numeric August chain id of the token (e.g. `1` for Ethereum mainnet).
|
|
147
|
+
* @param params.targetHealthFactor Health factor to solve for. Defaults server-side to the minimum healthy factor (1.2); when supplied must be a finite number greater than 0.
|
|
148
|
+
* @returns The signed excess (positive) or deficit (negative) in USD and token units. Zeroes when the subaccount has no debt.
|
|
149
|
+
* @throws AugustValidationError When an address is invalid, `tokenChain` is not an integer, or `targetHealthFactor` is out of range.
|
|
150
|
+
* @throws AugustServerError When the token has no discount factor (backend 404) or the API otherwise responds non-2xx.
|
|
151
|
+
* @example
|
|
152
|
+
* const r = await sdk.apiModule.getCollateralExcessOrDeficit({
|
|
153
|
+
* subaccount: '0xabc…',
|
|
154
|
+
* tokenAddress: '0xdef…',
|
|
155
|
+
* tokenChain: 1,
|
|
156
|
+
* });
|
|
157
|
+
* console.log(r.amount_usd > 0 ? 'excess' : 'deficit');
|
|
158
|
+
*/
|
|
159
|
+
async getCollateralExcessOrDeficit(params) {
|
|
160
|
+
const method = 'getCollateralExcessOrDeficit';
|
|
161
|
+
assertAddressArg(params.subaccount, 'subaccount address', method);
|
|
162
|
+
assertAddressArg(params.tokenAddress, 'token address', method);
|
|
163
|
+
if (!Number.isInteger(params.tokenChain)) {
|
|
164
|
+
throw new errors_1.AugustValidationError('INVALID_CHAIN', `${method}: tokenChain must be an integer August chain id, got ${params.tokenChain}.`);
|
|
165
|
+
}
|
|
166
|
+
if (params.targetHealthFactor !== undefined &&
|
|
167
|
+
(!Number.isFinite(params.targetHealthFactor) ||
|
|
168
|
+
params.targetHealthFactor <= 0)) {
|
|
169
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: targetHealthFactor must be a finite number greater than 0, got ${params.targetHealthFactor}.`);
|
|
170
|
+
}
|
|
171
|
+
return (0, fetcher_1.fetchCollateralExcessOrDeficit)(params, this.keys.august, this.headers ?? undefined);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Simulate the collateral required to open a hypothetical loan against a
|
|
175
|
+
* chosen basket of collateral tokens.
|
|
176
|
+
*
|
|
177
|
+
* This is a pure, read-only simulation: the backend `POST
|
|
178
|
+
* /risk/collateral_simulation` endpoint (60-second server-side cache)
|
|
179
|
+
* computes required collateral and effective discount factors and changes
|
|
180
|
+
* no state. It runs against the authenticated backend, so an
|
|
181
|
+
* (admin-scoped) August API key is required. Makes exactly one HTTP request
|
|
182
|
+
* and no RPC calls.
|
|
183
|
+
*
|
|
184
|
+
* @param input Simulation parameters — see {@link ICollateralSimulationInput}. `collateral_tokens` and `collateral_token_allocation` must be non-empty and equal length; when `on_platform` is `true`, both `loan_redeployed_token_*` fields are required.
|
|
185
|
+
* @returns The simulated {@link ICollateralSimulationResults}: total debt, required collateral, resulting health factor, and a per-token breakdown.
|
|
186
|
+
* @throws AugustValidationError When addresses are invalid, `loan_amount` is not a finite non-negative number, the collateral arrays are empty / mismatched, or `on_platform` is set without redeployed-token details.
|
|
187
|
+
* @throws AugustServerError When the API responds with a non-2xx status (e.g. a token missing a discount factor).
|
|
188
|
+
* @example
|
|
189
|
+
* const sim = await sdk.apiModule.simulateCollateral({
|
|
190
|
+
* loan_token_chain: 1,
|
|
191
|
+
* loan_token_address: '0xloan…',
|
|
192
|
+
* loan_amount: 1_000_000,
|
|
193
|
+
* collateral_tokens: [[1, '0xcol…']],
|
|
194
|
+
* collateral_token_allocation: [1],
|
|
195
|
+
* });
|
|
196
|
+
* console.log(sim.total_required_collateral_usd);
|
|
197
|
+
*/
|
|
198
|
+
async simulateCollateral(input) {
|
|
199
|
+
const method = 'simulateCollateral';
|
|
200
|
+
assertAddressArg(input.loan_token_address, 'loan token address', method);
|
|
201
|
+
if (!Number.isFinite(input.loan_amount) || input.loan_amount < 0) {
|
|
202
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: loan_amount must be a finite non-negative number, got ${input.loan_amount}.`);
|
|
203
|
+
}
|
|
204
|
+
if (!Array.isArray(input.collateral_tokens) ||
|
|
205
|
+
input.collateral_tokens.length === 0 ||
|
|
206
|
+
!Array.isArray(input.collateral_token_allocation) ||
|
|
207
|
+
input.collateral_token_allocation.length === 0) {
|
|
208
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: collateral_tokens and collateral_token_allocation must both be non-empty.`);
|
|
209
|
+
}
|
|
210
|
+
if (input.collateral_tokens.length !==
|
|
211
|
+
input.collateral_token_allocation.length) {
|
|
212
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: collateral_tokens (${input.collateral_tokens.length}) and collateral_token_allocation (${input.collateral_token_allocation.length}) must be the same length.`);
|
|
213
|
+
}
|
|
214
|
+
for (const [, address] of input.collateral_tokens) {
|
|
215
|
+
assertAddressArg(address, 'collateral token address', method);
|
|
216
|
+
}
|
|
217
|
+
if (input.on_platform &&
|
|
218
|
+
(input.loan_redeployed_token_chain === undefined ||
|
|
219
|
+
input.loan_redeployed_token_chain === null ||
|
|
220
|
+
!input.loan_redeployed_token_address)) {
|
|
221
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: on_platform requires both loan_redeployed_token_chain and loan_redeployed_token_address.`);
|
|
222
|
+
}
|
|
223
|
+
return (0, fetcher_1.fetchCollateralSimulation)(input, this.keys.august, this.headers ?? undefined);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Fetch the decoded revert reason(s) for a transaction — error messages,
|
|
227
|
+
* revert strings, and recognized universal-subaccount errors extracted from
|
|
228
|
+
* a `debug_traceTransaction` call tree.
|
|
229
|
+
*
|
|
230
|
+
* Backed by the public (unauthenticated) `GET /revert_reason` endpoint; no
|
|
231
|
+
* API key required. The backend relies on the target chain's RPC supporting
|
|
232
|
+
* `debug_trace*`; on chains/RPCs without it the backend returns a 5xx whose
|
|
233
|
+
* detail explains why, surfaced here as an {@link AugustServerError}. Makes
|
|
234
|
+
* exactly one HTTP request and no RPC calls from the SDK itself.
|
|
235
|
+
*
|
|
236
|
+
* @param txHash Transaction hash to trace.
|
|
237
|
+
* @param chain Numeric August chain id the transaction is on (e.g. `1` for Ethereum mainnet).
|
|
238
|
+
* @returns The decoded {@link IRevertReason}; all arrays empty when the trace yielded no matching signal.
|
|
239
|
+
* @throws AugustValidationError When `txHash` is empty or `chain` is not an integer.
|
|
240
|
+
* @throws AugustServerError When the chain/RPC does not support tracing, or the API otherwise responds non-2xx.
|
|
241
|
+
* @example
|
|
242
|
+
* const r = await sdk.apiModule.getRevertReason('0xabc…', 1);
|
|
243
|
+
* console.log(r.revert_reasons);
|
|
244
|
+
*/
|
|
245
|
+
async getRevertReason(txHash, chain) {
|
|
246
|
+
const method = 'getRevertReason';
|
|
247
|
+
if (typeof txHash !== 'string' || txHash.trim().length === 0) {
|
|
248
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: txHash must be a non-empty transaction hash.`);
|
|
249
|
+
}
|
|
250
|
+
if (!Number.isInteger(chain)) {
|
|
251
|
+
throw new errors_1.AugustValidationError('INVALID_CHAIN', `${method}: chain must be an integer August chain id, got ${chain}.`);
|
|
252
|
+
}
|
|
253
|
+
return (0, fetcher_1.fetchRevertReason)(txHash, chain, this.headers ?? undefined);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Retrieve every tracked OTC position.
|
|
257
|
+
*
|
|
258
|
+
* Backed by the admin-only `GET /otc/position` backend endpoint, so the
|
|
259
|
+
* configured August API key must belong to an admin user. Makes exactly one
|
|
260
|
+
* HTTP request and no RPC calls.
|
|
261
|
+
*
|
|
262
|
+
* @returns Array of {@link IOtcPositionRead}; empty when there are no OTC positions.
|
|
263
|
+
* @throws AugustAuthError When the API key is missing or not admin-scoped.
|
|
264
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
265
|
+
* @example
|
|
266
|
+
* const positions = await sdk.apiModule.getOtcPositions();
|
|
267
|
+
*/
|
|
268
|
+
async getOtcPositions() {
|
|
269
|
+
return (0, fetcher_1.fetchOtcPositions)(this.keys.august, this.headers ?? undefined);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Retrieve OTC margin requirements, optionally filtered by counterparty
|
|
273
|
+
* and/or payer.
|
|
274
|
+
*
|
|
275
|
+
* Backed by the admin-only `GET /otc/margin_requirement` backend endpoint,
|
|
276
|
+
* so the configured August API key must belong to an admin user. Makes
|
|
277
|
+
* exactly one HTTP request and no RPC calls.
|
|
278
|
+
*
|
|
279
|
+
* @param options - Optional filters
|
|
280
|
+
* @param options.otcCounterpartyId - Restrict to a single counterparty (UUID)
|
|
281
|
+
* @param options.payer - Restrict to a single payer address
|
|
282
|
+
* @returns Array of {@link IOtcMarginRequirement} matching the filters (all when none given).
|
|
283
|
+
* @throws AugustAuthError When the API key is missing or not admin-scoped.
|
|
284
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
285
|
+
* @example
|
|
286
|
+
* const reqs = await sdk.apiModule.getOtcMarginRequirements({ payer: '0xabc…' });
|
|
287
|
+
*/
|
|
288
|
+
async getOtcMarginRequirements(options = {}) {
|
|
289
|
+
return (0, fetcher_1.fetchOtcMarginRequirements)(options, this.keys.august, this.headers ?? undefined);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* List the subaccounts linked to a vault (curator surface).
|
|
293
|
+
*
|
|
294
|
+
* Backed by the curator-or-admin `GET
|
|
295
|
+
* /curator/vaults/{vault_address}/subaccounts` backend endpoint, so the
|
|
296
|
+
* configured August API key must belong to the vault's curator or an admin.
|
|
297
|
+
* Makes exactly one HTTP request and no RPC calls.
|
|
298
|
+
*
|
|
299
|
+
* @param vaultAddress - The vault address (EVM `0x…`, Solana, or Stellar)
|
|
300
|
+
* @returns Array of subaccount records linked to the vault (same shape as the subaccount directory); empty when none are linked.
|
|
301
|
+
* @throws AugustValidationError When `vaultAddress` is not a valid address.
|
|
302
|
+
* @throws AugustAuthError When the API key is missing or not curator/admin for the vault.
|
|
303
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
304
|
+
* @example
|
|
305
|
+
* const subs = await sdk.apiModule.getCuratorVaultSubaccounts('0xvault…');
|
|
306
|
+
*/
|
|
307
|
+
async getCuratorVaultSubaccounts(vaultAddress) {
|
|
308
|
+
assertVaultAddress(vaultAddress, 'getCuratorVaultSubaccounts');
|
|
309
|
+
return (0, fetcher_1.fetchCuratorVaultSubaccounts)(vaultAddress, this.keys.august, this.headers ?? undefined);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Get on-chain whitelist status for every subaccount linked to a vault
|
|
313
|
+
* (curator surface).
|
|
314
|
+
*
|
|
315
|
+
* Backed by the curator-or-admin `GET
|
|
316
|
+
* /curator/vaults/{vault_address}/whitelist` backend endpoint. EVM vaults
|
|
317
|
+
* only — non-EVM vaults manage access internally and the backend returns a
|
|
318
|
+
* 400 (surfaced as {@link AugustServerError}). Makes exactly one HTTP
|
|
319
|
+
* request and no RPC calls from the SDK.
|
|
320
|
+
*
|
|
321
|
+
* @param vaultAddress - The EVM vault address (`0x…`)
|
|
322
|
+
* @returns Array of {@link ICuratorWhitelistStatus}, one per linked subaccount; empty when the vault has no subaccounts.
|
|
323
|
+
* @throws AugustValidationError When `vaultAddress` is not a valid address.
|
|
324
|
+
* @throws AugustAuthError When the API key is missing or not curator/admin for the vault.
|
|
325
|
+
* @throws AugustServerError When the vault is non-EVM (backend 400) or the API otherwise responds non-2xx.
|
|
326
|
+
* @example
|
|
327
|
+
* const status = await sdk.apiModule.getCuratorVaultWhitelist('0xvault…');
|
|
328
|
+
* console.log(status.filter((s) => !s.is_whitelisted));
|
|
329
|
+
*/
|
|
330
|
+
async getCuratorVaultWhitelist(vaultAddress) {
|
|
331
|
+
assertVaultAddress(vaultAddress, 'getCuratorVaultWhitelist');
|
|
332
|
+
return (0, fetcher_1.fetchCuratorVaultWhitelist)(vaultAddress, this.keys.august, this.headers ?? undefined);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* List timelock (governance) requests for a vault on a chain, optionally
|
|
336
|
+
* filtered by status.
|
|
337
|
+
*
|
|
338
|
+
* Backed by the `GET /timelock-requests` backend endpoint. Makes exactly one
|
|
339
|
+
* HTTP request and no RPC calls.
|
|
340
|
+
*
|
|
341
|
+
* @param params.vaultAddress The vault address the requests target.
|
|
342
|
+
* @param params.chainId Numeric August chain id (must be a positive integer).
|
|
343
|
+
* @param params.status Status filter: `"scheduled"` (backend default), `"executed"`, `"cancelled"`, or `"all"`. Omit to use the backend default.
|
|
344
|
+
* @returns Array of {@link ITimelockRequest}; empty when the vault has no matching requests.
|
|
345
|
+
* @throws AugustValidationError When `vaultAddress` is invalid or `chainId` is not a positive integer.
|
|
346
|
+
* @throws AugustServerError When the API responds with a non-2xx status (e.g. an invalid status filter).
|
|
347
|
+
* @example
|
|
348
|
+
* const reqs = await sdk.apiModule.getTimelockRequests({ vaultAddress: '0xvault…', chainId: 1 });
|
|
349
|
+
*/
|
|
350
|
+
async getTimelockRequests(params) {
|
|
351
|
+
const method = 'getTimelockRequests';
|
|
352
|
+
assertVaultAddress(params.vaultAddress, method);
|
|
353
|
+
if (!Number.isInteger(params.chainId) || params.chainId <= 0) {
|
|
354
|
+
throw new errors_1.AugustValidationError('INVALID_CHAIN', `${method}: chainId must be a positive integer August chain id, got ${params.chainId}.`);
|
|
355
|
+
}
|
|
356
|
+
return (0, fetcher_1.fetchTimelockRequests)(params, this.keys.august, this.headers ?? undefined);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Compute a vault's performance fees over a period (backend-computed from
|
|
360
|
+
* its snapshot history).
|
|
361
|
+
*
|
|
362
|
+
* Backed by `GET /metrics/vault_performance_fees`. The backend runs pandas
|
|
363
|
+
* over the vault's full snapshot history, so the first call is slow; results
|
|
364
|
+
* are cached server-side for 20 minutes. Makes exactly one HTTP request and
|
|
365
|
+
* no RPC calls.
|
|
366
|
+
*
|
|
367
|
+
* @param params.vault The vault address (EVM `0x…`, Solana, or Stellar).
|
|
368
|
+
* @param params.annualizedFeesPct Annualized performance-fee percentage. Defaults to 20.
|
|
369
|
+
* @param params.nativeDenominated Whether to denominate in the vault's native token. Defaults to `true`.
|
|
370
|
+
* @param params.calculationPeriod Period preset — `"YearToDate"` (default) or `"MonthToDate"`. Ignored by the backend when a custom `startDate`/`endDate` range is supplied.
|
|
371
|
+
* @param params.startDate ISO-8601 datetime range start. Must be supplied together with `endDate`.
|
|
372
|
+
* @param params.endDate ISO-8601 datetime range end. Must be supplied together with `startDate`.
|
|
373
|
+
* @returns The vault's {@link IVaultPerformanceFees} computation.
|
|
374
|
+
* @throws AugustValidationError When `vault` is invalid, or exactly one of `startDate`/`endDate` is supplied.
|
|
375
|
+
* @throws AugustServerError When there is insufficient snapshot data for the period, or the API otherwise responds non-2xx.
|
|
376
|
+
* @example
|
|
377
|
+
* const fees = await sdk.apiModule.getVaultPerformanceFees({ vault: '0xvault…' });
|
|
378
|
+
* console.log(fees.total_perf_fees_asset);
|
|
379
|
+
*/
|
|
380
|
+
async getVaultPerformanceFees(params) {
|
|
381
|
+
const method = 'getVaultPerformanceFees';
|
|
382
|
+
assertVaultAddress(params.vault, method);
|
|
383
|
+
const hasStart = params.startDate !== undefined;
|
|
384
|
+
const hasEnd = params.endDate !== undefined;
|
|
385
|
+
if (hasStart !== hasEnd) {
|
|
386
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: startDate and endDate must be supplied together (both or neither).`);
|
|
387
|
+
}
|
|
388
|
+
return (0, fetcher_1.fetchVaultPerformanceFees)({
|
|
389
|
+
vaultAddress: params.vault,
|
|
390
|
+
annualizedFeesPct: params.annualizedFeesPct ?? 20,
|
|
391
|
+
nativeDenominated: params.nativeDenominated ?? true,
|
|
392
|
+
calculationPeriod: params.calculationPeriod ?? 'YearToDate',
|
|
393
|
+
startDate: params.startDate,
|
|
394
|
+
endDate: params.endDate,
|
|
395
|
+
}, this.keys.august, this.headers ?? undefined);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Fetch a vault's NAV-oracle classification table — how each position/token
|
|
399
|
+
* is priced (Primary / Secondary Market / CeFi) and its USD value, plus
|
|
400
|
+
* warnings for tokens that could not be resolved.
|
|
401
|
+
*
|
|
402
|
+
* Backed by the public (unauthenticated) `GET
|
|
403
|
+
* /upshift/oracle_classification/{vault_address}` endpoint; no API key
|
|
404
|
+
* required. Reads the newest daily snapshot. Makes exactly one HTTP request
|
|
405
|
+
* and no RPC calls from the SDK.
|
|
406
|
+
*
|
|
407
|
+
* @param vault The vault address (EVM `0x…`, Solana, or Stellar).
|
|
408
|
+
* @param chainId Numeric August chain id the vault lives on.
|
|
409
|
+
* @returns The vault's {@link IOracleClassification}.
|
|
410
|
+
* @throws AugustValidationError When `vault` is invalid or `chainId` is not an integer.
|
|
411
|
+
* @throws AugustServerError When the vault or its snapshot is not found, or the API otherwise responds non-2xx.
|
|
412
|
+
* @example
|
|
413
|
+
* const cls = await sdk.apiModule.getVaultOracleClassification('0xvault…', 1);
|
|
414
|
+
* console.log(cls.warnings);
|
|
415
|
+
*/
|
|
416
|
+
async getVaultOracleClassification(vault, chainId) {
|
|
417
|
+
const method = 'getVaultOracleClassification';
|
|
418
|
+
assertVaultAddress(vault, method);
|
|
419
|
+
if (!Number.isInteger(chainId)) {
|
|
420
|
+
throw new errors_1.AugustValidationError('INVALID_CHAIN', `${method}: chainId must be an integer August chain id, got ${chainId}.`);
|
|
421
|
+
}
|
|
422
|
+
return (0, fetcher_1.fetchVaultOracleClassification)(vault, chainId, this.headers ?? undefined);
|
|
423
|
+
}
|
|
75
424
|
/**
|
|
76
425
|
* Fetch the historical unrealized-PnL series for a vault, newest first,
|
|
77
426
|
* as computed by the August backend from periodic vault snapshots.
|
|
@@ -99,7 +448,7 @@ class AugustApi {
|
|
|
99
448
|
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: limit must be an integer between 1 and 1000, got ${params.limit}.`);
|
|
100
449
|
}
|
|
101
450
|
const endpoint = core_1.WEBSERVER_ENDPOINTS.public.pnl.unrealizedHistory(params.vault, params.limit);
|
|
102
|
-
const response = await (0,
|
|
451
|
+
const response = await (0, fetcher_2.fetchAugustPublic)(endpoint);
|
|
103
452
|
const data = await response.json();
|
|
104
453
|
assertSnapshotArray(data, method);
|
|
105
454
|
return data.map(toUnrealizedPnlSnapshot);
|
|
@@ -120,7 +469,7 @@ class AugustApi {
|
|
|
120
469
|
*/
|
|
121
470
|
async getLatestUnrealizedPnl() {
|
|
122
471
|
const method = 'getLatestUnrealizedPnl';
|
|
123
|
-
const response = await (0,
|
|
472
|
+
const response = await (0, fetcher_2.fetchAugustPublic)(core_1.WEBSERVER_ENDPOINTS.public.pnl.unrealizedLatest);
|
|
124
473
|
const data = await response.json();
|
|
125
474
|
assertSnapshotArray(data, method);
|
|
126
475
|
return data.map(toUnrealizedPnlSnapshot);
|