@augustdigital/sdk 9.5.0 → 9.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/adapters/evm/index.d.ts +1 -1
- package/lib/adapters/evm/index.js +29 -29
- package/lib/adapters/solana/types.d.ts +8 -0
- package/lib/adapters/solana/vault.actions.d.ts +6 -1
- package/lib/adapters/solana/vault.actions.js +99 -21
- package/lib/core/analytics/app-name.js +1 -1
- package/lib/core/analytics/constants.d.ts +10 -0
- package/lib/core/analytics/constants.js +17 -1
- package/lib/core/analytics/index.d.ts +7 -4
- package/lib/core/analytics/index.js +8 -4
- package/lib/core/analytics/instrumentation.js +8 -4
- package/lib/core/analytics/method-taxonomy.js +13 -0
- package/lib/core/analytics/metrics.d.ts +25 -10
- package/lib/core/analytics/metrics.js +41 -15
- package/lib/core/analytics/sentry.d.ts +24 -3
- package/lib/core/analytics/sentry.js +49 -18
- package/lib/core/analytics/types.d.ts +11 -4
- package/lib/core/analytics/user-identity.d.ts +19 -5
- package/lib/core/analytics/user-identity.js +35 -21
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/auth/verify.js +7 -3
- package/lib/core/base.class.d.ts +8 -1
- package/lib/core/base.class.js +7 -1
- package/lib/core/constants/core.d.ts +3 -0
- package/lib/core/constants/core.js +3 -0
- package/lib/core/constants/swap-router.d.ts +16 -0
- package/lib/core/constants/swap-router.js +16 -0
- package/lib/core/errors/index.d.ts +36 -1
- package/lib/core/errors/index.js +40 -1
- package/lib/core/fetcher.d.ts +24 -5
- package/lib/core/fetcher.js +43 -7
- package/lib/main.d.ts +6 -0
- package/lib/main.js +6 -0
- package/lib/modules/api/main.d.ts +6 -6
- package/lib/modules/api/main.js +6 -6
- package/lib/modules/sub-accounts/main.d.ts +7 -1
- package/lib/modules/sub-accounts/main.js +7 -1
- package/lib/modules/vaults/getters.d.ts +151 -10
- package/lib/modules/vaults/getters.js +226 -30
- package/lib/modules/vaults/main.d.ts +5 -0
- package/lib/modules/vaults/main.js +5 -0
- package/lib/modules/vaults/write.actions.d.ts +57 -1
- package/lib/modules/vaults/write.actions.js +86 -2
- package/lib/sdk.d.ts +13171 -12810
- package/lib/services/debank/fetcher.js +1 -1
- package/lib/services/subgraph/vaults.d.ts +18 -1
- package/lib/services/subgraph/vaults.js +19 -3
- package/lib/types/vaults.d.ts +5 -0
- package/package.json +2 -2
|
@@ -63,6 +63,7 @@ exports.WEBSERVER_URL = {
|
|
|
63
63
|
};
|
|
64
64
|
exports.WEBSERVER_ENDPOINTS = {
|
|
65
65
|
default: {
|
|
66
|
+
/** @deprecated No backend route. Removed in the next major release. */
|
|
66
67
|
hello: '/hello',
|
|
67
68
|
protected: '/protected',
|
|
68
69
|
},
|
|
@@ -75,6 +76,7 @@ exports.WEBSERVER_ENDPOINTS = {
|
|
|
75
76
|
},
|
|
76
77
|
subaccount: {
|
|
77
78
|
list: (offset = 0, limit = 100) => `/subaccount?offset=${offset}&limit=${limit}`,
|
|
79
|
+
/** @deprecated No backend route. Removed in the next major release. */
|
|
78
80
|
rewards: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/rewards`,
|
|
79
81
|
tokens: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/tokens`,
|
|
80
82
|
twap: {
|
|
@@ -85,6 +87,7 @@ exports.WEBSERVER_ENDPOINTS = {
|
|
|
85
87
|
debank: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/debank`,
|
|
86
88
|
health_factor: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/health_factor`,
|
|
87
89
|
summary: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/summary`,
|
|
90
|
+
/** @deprecated No backend route. Removed in the next major release. */
|
|
88
91
|
batch: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/tx_batcher_integrations`,
|
|
89
92
|
loans: (subaccount, side = 'BOTH', active = true) => `/subaccount/${subaccountSegment(subaccount)}/loans?side=${side}&active=${active}`,
|
|
90
93
|
cefi: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/cefi_position`,
|
|
@@ -108,6 +108,22 @@ export declare const SWAP_ROUTER_MAX_SWAPS = 9;
|
|
|
108
108
|
* every dispatch. Used to validate that native-token deposits target a
|
|
109
109
|
* vault whose reference asset is the wrapped native — the only configuration
|
|
110
110
|
* the contract's `depositNativeToken` / `swapAndDepositNativeToken` accept.
|
|
111
|
+
*
|
|
112
|
+
* **Wrap-only, WETH-vaults-only limitation.** Both payable entry points on the
|
|
113
|
+
* deployed router (`depositNativeToken` and `swapAndDepositNativeToken`) only
|
|
114
|
+
* wrap native ETH to this address and deposit — neither has an ETH→other-asset
|
|
115
|
+
* swap leg. `swapAndDepositNativeToken`'s ABI takes no swap payload, so a DEX
|
|
116
|
+
* swap is structurally impossible on that path too; its only difference from
|
|
117
|
+
* `depositNativeToken` is applying the vault swap fee on the pure wrap. The
|
|
118
|
+
* practical consequence: **native ETH can only be deposited into a vault whose
|
|
119
|
+
* reference asset is this wrapped-native token** (e.g. a WETH-reference
|
|
120
|
+
* vault). There is no atomic native-ETH deposit into a non-WETH-reference
|
|
121
|
+
* vault (e.g. a USDC vault) — deposit the wrapped native token instead
|
|
122
|
+
* (already whitelisted, and it routes through the swap leg for a vault whose
|
|
123
|
+
* reference asset differs). True atomic ETH→any-asset support would require a
|
|
124
|
+
* contract change (a payable `swapAndDeposit` variant), which is out of scope
|
|
125
|
+
* for this SDK. Use {@link isNativeSwapRouterDepositSupported} to check a
|
|
126
|
+
* vault's eligibility for the native path before offering it in a UI.
|
|
111
127
|
*/
|
|
112
128
|
export declare const SWAP_ROUTER_WRAPPED_NATIVE: Readonly<Record<number, IAddress>>;
|
|
113
129
|
/**
|
|
@@ -121,6 +121,22 @@ exports.SWAP_ROUTER_MAX_SWAPS = 9;
|
|
|
121
121
|
* every dispatch. Used to validate that native-token deposits target a
|
|
122
122
|
* vault whose reference asset is the wrapped native — the only configuration
|
|
123
123
|
* the contract's `depositNativeToken` / `swapAndDepositNativeToken` accept.
|
|
124
|
+
*
|
|
125
|
+
* **Wrap-only, WETH-vaults-only limitation.** Both payable entry points on the
|
|
126
|
+
* deployed router (`depositNativeToken` and `swapAndDepositNativeToken`) only
|
|
127
|
+
* wrap native ETH to this address and deposit — neither has an ETH→other-asset
|
|
128
|
+
* swap leg. `swapAndDepositNativeToken`'s ABI takes no swap payload, so a DEX
|
|
129
|
+
* swap is structurally impossible on that path too; its only difference from
|
|
130
|
+
* `depositNativeToken` is applying the vault swap fee on the pure wrap. The
|
|
131
|
+
* practical consequence: **native ETH can only be deposited into a vault whose
|
|
132
|
+
* reference asset is this wrapped-native token** (e.g. a WETH-reference
|
|
133
|
+
* vault). There is no atomic native-ETH deposit into a non-WETH-reference
|
|
134
|
+
* vault (e.g. a USDC vault) — deposit the wrapped native token instead
|
|
135
|
+
* (already whitelisted, and it routes through the swap leg for a vault whose
|
|
136
|
+
* reference asset differs). True atomic ETH→any-asset support would require a
|
|
137
|
+
* contract change (a payable `swapAndDeposit` variant), which is out of scope
|
|
138
|
+
* for this SDK. Use {@link isNativeSwapRouterDepositSupported} to check a
|
|
139
|
+
* vault's eligibility for the native path before offering it in a UI.
|
|
124
140
|
*/
|
|
125
141
|
exports.SWAP_ROUTER_WRAPPED_NATIVE = {
|
|
126
142
|
1: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
/** Stable error codes attached to SDK errors. */
|
|
18
|
-
export type AugustErrorCode = 'AUTH_MISSING_KEY' | 'AUTH_INVALID_KEY' | 'AUTH_FORBIDDEN' | 'AUTH_UNAUTHORIZED' | 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS' | 'ACCOUNT_NOT_FUNDED' | 'NETWORK_ERROR' | 'TIMEOUT' | 'RATE_LIMITED' | 'SERVER_ERROR' | 'HISTORY_UNAVAILABLE' | 'UNKNOWN';
|
|
18
|
+
export type AugustErrorCode = 'AUTH_MISSING_KEY' | 'AUTH_INVALID_KEY' | 'AUTH_FORBIDDEN' | 'AUTH_UNAUTHORIZED' | 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS' | 'ACCOUNT_NOT_FUNDED' | 'NETWORK_ERROR' | 'TIMEOUT' | 'RATE_LIMITED' | 'SERVER_ERROR' | 'HISTORY_UNAVAILABLE' | 'PRICE_UNAVAILABLE' | 'UNKNOWN';
|
|
19
19
|
/** Options accepted by every SDK error constructor. */
|
|
20
20
|
export interface AugustErrorOptions {
|
|
21
21
|
/** Original error preserved for stack-trace chaining. */
|
|
@@ -110,5 +110,40 @@ export declare class AugustHistoryUnavailableError extends AugustSDKError {
|
|
|
110
110
|
*/
|
|
111
111
|
constructor(message: string, options?: AugustErrorOptions);
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* The USD price needed to convert a computed value could not be resolved, so
|
|
115
|
+
* any USD figure derived from it would be fabricated rather than merely
|
|
116
|
+
* missing.
|
|
117
|
+
*
|
|
118
|
+
* Motivation — `getVaultUserLifetimePnl` used to substitute a price of `1`
|
|
119
|
+
* whenever the price server returned nothing, which reported every
|
|
120
|
+
* USD field of a non-dollar vault (lsETH, tETH, BTC) at $1 per asset: a
|
|
121
|
+
* position worth ~$40k read as ~$13, indistinguishable from a real result.
|
|
122
|
+
* Throwing this typed error makes a missing price explicit so callers can hide
|
|
123
|
+
* the USD value instead of displaying a wrong one.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* try {
|
|
128
|
+
* await sdk.getVaultUserLifetimePnl({ vault, wallet, chainId });
|
|
129
|
+
* } catch (err) {
|
|
130
|
+
* if (err instanceof AugustPriceUnavailableError) {
|
|
131
|
+
* // No USD price for the vault asset — hide the USD figures rather than
|
|
132
|
+
* // show a fabricated one.
|
|
133
|
+
* hideUsd(err.context);
|
|
134
|
+
* } else throw err;
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare class AugustPriceUnavailableError extends AugustSDKError {
|
|
139
|
+
/**
|
|
140
|
+
* @param message - Human-readable description of the missing price. Callers
|
|
141
|
+
* pass the same `#<method>::<vault>::<wallet>` prefix the surrounding getter
|
|
142
|
+
* uses so log grouping stays consistent.
|
|
143
|
+
* @param options - Standard SDK error options. `context` should carry the
|
|
144
|
+
* identifiers that scope the failure (e.g. `{ vault, wallet, asset }`).
|
|
145
|
+
*/
|
|
146
|
+
constructor(message: string, options?: AugustErrorOptions);
|
|
147
|
+
}
|
|
113
148
|
/** Type guard. Works across realms (e.g. Web Worker / VM contexts). */
|
|
114
149
|
export declare function isAugustSDKError(err: unknown): err is AugustSDKError;
|
package/lib/core/errors/index.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.AugustHistoryUnavailableError = exports.AugustServerError = exports.AugustRateLimitError = exports.AugustValidationError = exports.AugustTimeoutError = exports.AugustNetworkError = exports.AugustAuthError = exports.AugustSDKError = void 0;
|
|
19
|
+
exports.AugustPriceUnavailableError = exports.AugustHistoryUnavailableError = exports.AugustServerError = exports.AugustRateLimitError = exports.AugustValidationError = exports.AugustTimeoutError = exports.AugustNetworkError = exports.AugustAuthError = exports.AugustSDKError = void 0;
|
|
20
20
|
exports.isAugustSDKError = isAugustSDKError;
|
|
21
21
|
/** Base class for all SDK errors. */
|
|
22
22
|
class AugustSDKError extends Error {
|
|
@@ -173,6 +173,45 @@ class AugustHistoryUnavailableError extends AugustSDKError {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
exports.AugustHistoryUnavailableError = AugustHistoryUnavailableError;
|
|
176
|
+
/**
|
|
177
|
+
* The USD price needed to convert a computed value could not be resolved, so
|
|
178
|
+
* any USD figure derived from it would be fabricated rather than merely
|
|
179
|
+
* missing.
|
|
180
|
+
*
|
|
181
|
+
* Motivation — `getVaultUserLifetimePnl` used to substitute a price of `1`
|
|
182
|
+
* whenever the price server returned nothing, which reported every
|
|
183
|
+
* USD field of a non-dollar vault (lsETH, tETH, BTC) at $1 per asset: a
|
|
184
|
+
* position worth ~$40k read as ~$13, indistinguishable from a real result.
|
|
185
|
+
* Throwing this typed error makes a missing price explicit so callers can hide
|
|
186
|
+
* the USD value instead of displaying a wrong one.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* try {
|
|
191
|
+
* await sdk.getVaultUserLifetimePnl({ vault, wallet, chainId });
|
|
192
|
+
* } catch (err) {
|
|
193
|
+
* if (err instanceof AugustPriceUnavailableError) {
|
|
194
|
+
* // No USD price for the vault asset — hide the USD figures rather than
|
|
195
|
+
* // show a fabricated one.
|
|
196
|
+
* hideUsd(err.context);
|
|
197
|
+
* } else throw err;
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
class AugustPriceUnavailableError extends AugustSDKError {
|
|
202
|
+
/**
|
|
203
|
+
* @param message - Human-readable description of the missing price. Callers
|
|
204
|
+
* pass the same `#<method>::<vault>::<wallet>` prefix the surrounding getter
|
|
205
|
+
* uses so log grouping stays consistent.
|
|
206
|
+
* @param options - Standard SDK error options. `context` should carry the
|
|
207
|
+
* identifiers that scope the failure (e.g. `{ vault, wallet, asset }`).
|
|
208
|
+
*/
|
|
209
|
+
constructor(message, options) {
|
|
210
|
+
super('PRICE_UNAVAILABLE', message, options);
|
|
211
|
+
this.name = 'AugustPriceUnavailableError';
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
exports.AugustPriceUnavailableError = AugustPriceUnavailableError;
|
|
176
215
|
/** Type guard. Works across realms (e.g. Web Worker / VM contexts). */
|
|
177
216
|
function isAugustSDKError(err) {
|
|
178
217
|
return (err instanceof AugustSDKError ||
|
package/lib/core/fetcher.d.ts
CHANGED
|
@@ -21,8 +21,8 @@ export type IFetchAugustOptions = {
|
|
|
21
21
|
/** Per-request timeout in ms. Defaults to `REQUEST_TIMEOUT_MS`. */
|
|
22
22
|
timeoutMs?: number;
|
|
23
23
|
/**
|
|
24
|
-
* @deprecated
|
|
25
|
-
* Will be removed in a future major version;
|
|
24
|
+
* @deprecated No longer has any effect: an absent `apiKey` already sends an
|
|
25
|
+
* anonymous request. Will be removed in a future major version; drop it.
|
|
26
26
|
*/
|
|
27
27
|
override?: boolean;
|
|
28
28
|
};
|
|
@@ -41,6 +41,19 @@ export declare function setSdkRequestTimeout(ms?: number | null): void;
|
|
|
41
41
|
* otherwise the compiled-in `REQUEST_TIMEOUT_MS`.
|
|
42
42
|
*/
|
|
43
43
|
export declare function getSdkRequestTimeout(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Record the consuming application's `appName` so every request to the
|
|
46
|
+
* August backend carries it as `x-august-app`, next to
|
|
47
|
+
* `x-august-sdk-version`. This gives the backend per-integrator request
|
|
48
|
+
* counts that do not depend on Sentry sampling.
|
|
49
|
+
*
|
|
50
|
+
* Process-global, last writer wins — the same contract as
|
|
51
|
+
* `setSdkRequestTimeout` and `setPublicApiBaseUrl`. The `AugustSDK`
|
|
52
|
+
* constructor calls this with its validated `appName`.
|
|
53
|
+
*
|
|
54
|
+
* @param appName - Validated app-name slug, or `null` to stop sending it.
|
|
55
|
+
*/
|
|
56
|
+
export declare function setSdkAppName(appName?: string | null): void;
|
|
44
57
|
/**
|
|
45
58
|
* Override the base URL used for `WEBSERVER_URL.public` requests — the
|
|
46
59
|
* unauthenticated vault-catalog API that `getVault` / `fetchTokenizedVault`
|
|
@@ -79,15 +92,21 @@ export declare function getPublicApiBaseUrl(): string;
|
|
|
79
92
|
import { CACHE, getSafeCache, setSafeCache } from './cache';
|
|
80
93
|
export { CACHE, getSafeCache, setSafeCache };
|
|
81
94
|
/**
|
|
82
|
-
* Make
|
|
95
|
+
* Make requests to August backend services, sending an API key when one is
|
|
96
|
+
* configured. Many backend routes — vault-linked sub-account reads, the two
|
|
97
|
+
* collateral risk routes, timelock requests — answer anonymous callers, so a
|
|
98
|
+
* missing key is not an error here: the request goes out without the
|
|
99
|
+
* `x-api-key` header and the backend decides. Routes that do require a key
|
|
100
|
+
* answer `401`, which surfaces as an `AugustAuthError` with code
|
|
101
|
+
* `AUTH_UNAUTHORIZED`.
|
|
83
102
|
* Automatically logs errors with correlation IDs for debugging.
|
|
84
|
-
* @param apiKey - August API key for
|
|
103
|
+
* @param apiKey - August API key, or `undefined` for an anonymous request
|
|
85
104
|
* @param relativeUrl - Endpoint path relative to base URL
|
|
86
105
|
* @param options - Request configuration including method and headers
|
|
87
106
|
* @returns Response object if successful
|
|
88
107
|
* @throws Error with correlation ID if request fails
|
|
89
108
|
*/
|
|
90
|
-
export declare function fetchAugustWithKey(apiKey: string, relativeUrl: string, options?: IFetchAugustOptions): Promise<Response>;
|
|
109
|
+
export declare function fetchAugustWithKey(apiKey: string | undefined, relativeUrl: string, options?: IFetchAugustOptions): Promise<Response>;
|
|
91
110
|
/**
|
|
92
111
|
* Make unauthenticated requests to August public API endpoints.
|
|
93
112
|
* Used for fetching vault metadata and public market data.
|
package/lib/core/fetcher.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setSafeCache = exports.getSafeCache = exports.CACHE = void 0;
|
|
4
4
|
exports.setSdkRequestTimeout = setSdkRequestTimeout;
|
|
5
5
|
exports.getSdkRequestTimeout = getSdkRequestTimeout;
|
|
6
|
+
exports.setSdkAppName = setSdkAppName;
|
|
6
7
|
exports.setPublicApiBaseUrl = setPublicApiBaseUrl;
|
|
7
8
|
exports.getPublicApiBaseUrl = getPublicApiBaseUrl;
|
|
8
9
|
exports.fetchAugustWithKey = fetchAugustWithKey;
|
|
@@ -32,6 +33,7 @@ const core_2 = require("./constants/core");
|
|
|
32
33
|
const vault_version_1 = require("./helpers/vault-version");
|
|
33
34
|
const analytics_1 = require("./analytics");
|
|
34
35
|
const sanitize_1 = require("./analytics/sanitize");
|
|
36
|
+
const sentry_1 = require("./analytics/sentry");
|
|
35
37
|
const errors_1 = require("./errors");
|
|
36
38
|
/** Map an HTTP status to the appropriate typed SDK error subclass. */
|
|
37
39
|
function errorFromResponseStatus(status, message, options) {
|
|
@@ -76,6 +78,34 @@ function setSdkRequestTimeout(ms = null) {
|
|
|
76
78
|
function getSdkRequestTimeout() {
|
|
77
79
|
return SDK_REQUEST_TIMEOUT_OVERRIDE ?? core_2.REQUEST_TIMEOUT_MS;
|
|
78
80
|
}
|
|
81
|
+
let SDK_APP_NAME = null;
|
|
82
|
+
/**
|
|
83
|
+
* Record the consuming application's `appName` so every request to the
|
|
84
|
+
* August backend carries it as `x-august-app`, next to
|
|
85
|
+
* `x-august-sdk-version`. This gives the backend per-integrator request
|
|
86
|
+
* counts that do not depend on Sentry sampling.
|
|
87
|
+
*
|
|
88
|
+
* Process-global, last writer wins — the same contract as
|
|
89
|
+
* `setSdkRequestTimeout` and `setPublicApiBaseUrl`. The `AugustSDK`
|
|
90
|
+
* constructor calls this with its validated `appName`.
|
|
91
|
+
*
|
|
92
|
+
* @param appName - Validated app-name slug, or `null` to stop sending it.
|
|
93
|
+
*/
|
|
94
|
+
function setSdkAppName(appName = null) {
|
|
95
|
+
SDK_APP_NAME = appName;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Client-identification headers merged into every backend fetcher's
|
|
99
|
+
* defaults. Both values are low-cardinality slugs, never credentials.
|
|
100
|
+
*/
|
|
101
|
+
function sdkClientHeaders() {
|
|
102
|
+
const headers = {
|
|
103
|
+
'x-august-sdk-version': (0, sentry_1.getSDKVersion)(),
|
|
104
|
+
};
|
|
105
|
+
if (SDK_APP_NAME)
|
|
106
|
+
headers['x-august-app'] = SDK_APP_NAME;
|
|
107
|
+
return headers;
|
|
108
|
+
}
|
|
79
109
|
let PUBLIC_API_BASE_OVERRIDE = null;
|
|
80
110
|
/**
|
|
81
111
|
* Override the base URL used for `WEBSERVER_URL.public` requests — the
|
|
@@ -228,7 +258,7 @@ function warnOverrideDeprecation(callerTag) {
|
|
|
228
258
|
// notice must surface in the integrator's console in every environment.
|
|
229
259
|
// Logger.log.warn would downgrade it to a prod-silent Sentry breadcrumb.
|
|
230
260
|
// biome-ignore lint/suspicious/noConsole: integrator-facing deprecation notice must surface in every environment; Logger.log.warn would downgrade it to a prod-silent Sentry breadcrumb.
|
|
231
|
-
console.warn(`[@augustdigital/sdk] ${callerTag}: option "override" is deprecated and will be removed in a future major version
|
|
261
|
+
console.warn(`[@augustdigital/sdk] ${callerTag}: option "override" is deprecated and has no effect — an absent apiKey already sends an anonymous request. It will be removed in a future major version; drop it.`);
|
|
232
262
|
}
|
|
233
263
|
/**
|
|
234
264
|
* LRU cache for API responses and frequently accessed data.
|
|
@@ -354,9 +384,15 @@ function buildAugustUrl(server, relativeUrl) {
|
|
|
354
384
|
return url.toString();
|
|
355
385
|
}
|
|
356
386
|
/**
|
|
357
|
-
* Make
|
|
387
|
+
* Make requests to August backend services, sending an API key when one is
|
|
388
|
+
* configured. Many backend routes — vault-linked sub-account reads, the two
|
|
389
|
+
* collateral risk routes, timelock requests — answer anonymous callers, so a
|
|
390
|
+
* missing key is not an error here: the request goes out without the
|
|
391
|
+
* `x-api-key` header and the backend decides. Routes that do require a key
|
|
392
|
+
* answer `401`, which surfaces as an `AugustAuthError` with code
|
|
393
|
+
* `AUTH_UNAUTHORIZED`.
|
|
358
394
|
* Automatically logs errors with correlation IDs for debugging.
|
|
359
|
-
* @param apiKey - August API key for
|
|
395
|
+
* @param apiKey - August API key, or `undefined` for an anonymous request
|
|
360
396
|
* @param relativeUrl - Endpoint path relative to base URL
|
|
361
397
|
* @param options - Request configuration including method and headers
|
|
362
398
|
* @returns Response object if successful
|
|
@@ -366,11 +402,9 @@ async function fetchAugustWithKey(apiKey, relativeUrl, options) {
|
|
|
366
402
|
if (options?.override) {
|
|
367
403
|
warnOverrideDeprecation('fetchAugustWithKey');
|
|
368
404
|
}
|
|
369
|
-
if (!apiKey && !options?.override) {
|
|
370
|
-
throw new errors_1.AugustAuthError('AUTH_MISSING_KEY', 'fetchAugustWithKey: apiKey is required (set keys.august on the SDK constructor, or pass an explicit apiKey).');
|
|
371
|
-
}
|
|
372
405
|
const defaultHeaders = {
|
|
373
|
-
|
|
406
|
+
...sdkClientHeaders(),
|
|
407
|
+
...(apiKey ? { 'x-api-key': apiKey } : {}),
|
|
374
408
|
'content-type': 'application/json',
|
|
375
409
|
accept: 'application/json',
|
|
376
410
|
};
|
|
@@ -426,6 +460,7 @@ async function fetchAugustWithKey(apiKey, relativeUrl, options) {
|
|
|
426
460
|
*/
|
|
427
461
|
async function fetchAugustPublic(relativeUrl, options) {
|
|
428
462
|
const defaultHeaders = {
|
|
463
|
+
...sdkClientHeaders(),
|
|
429
464
|
'content-type': 'application/json',
|
|
430
465
|
accept: 'application/json',
|
|
431
466
|
};
|
|
@@ -480,6 +515,7 @@ async function fetchAugustPublic(relativeUrl, options) {
|
|
|
480
515
|
*/
|
|
481
516
|
async function fetchAugustWithBearer(bearerToken, relativeUrl, options) {
|
|
482
517
|
const defaultHeaders = {
|
|
518
|
+
...sdkClientHeaders(),
|
|
483
519
|
authorization: `Bearer ${bearerToken}`,
|
|
484
520
|
'content-type': 'application/json',
|
|
485
521
|
accept: 'application/json',
|
package/lib/main.d.ts
CHANGED
|
@@ -355,6 +355,12 @@ export declare class AugustSDK extends AugustBase {
|
|
|
355
355
|
* Calculates realized and unrealized PnL based on deposit/withdrawal history and current position.
|
|
356
356
|
* @param props - Vault address, wallet address, and optional chain ID
|
|
357
357
|
* @returns Lifetime PnL data including realized and unrealized PnL in both native token and USD
|
|
358
|
+
* @throws {@link AugustHistoryUnavailableError} (`HISTORY_UNAVAILABLE`) when a
|
|
359
|
+
* live position has no indexed deposits, withdrawals or priceable share
|
|
360
|
+
* transfers.
|
|
361
|
+
* @throws {@link AugustPriceUnavailableError} (`PRICE_UNAVAILABLE`) when the
|
|
362
|
+
* vault's underlying asset has no USD price — the USD fields are never
|
|
363
|
+
* computed from a stand-in price.
|
|
358
364
|
*/
|
|
359
365
|
getVaultUserLifetimePnl(props: {
|
|
360
366
|
vault: IAddress;
|
package/lib/main.js
CHANGED
|
@@ -430,6 +430,12 @@ class AugustSDK extends core_1.AugustBase {
|
|
|
430
430
|
* Calculates realized and unrealized PnL based on deposit/withdrawal history and current position.
|
|
431
431
|
* @param props - Vault address, wallet address, and optional chain ID
|
|
432
432
|
* @returns Lifetime PnL data including realized and unrealized PnL in both native token and USD
|
|
433
|
+
* @throws {@link AugustHistoryUnavailableError} (`HISTORY_UNAVAILABLE`) when a
|
|
434
|
+
* live position has no indexed deposits, withdrawals or priceable share
|
|
435
|
+
* transfers.
|
|
436
|
+
* @throws {@link AugustPriceUnavailableError} (`PRICE_UNAVAILABLE`) when the
|
|
437
|
+
* vault's underlying asset has no USD price — the USD fields are never
|
|
438
|
+
* computed from a stand-in price.
|
|
433
439
|
*/
|
|
434
440
|
async getVaultUserLifetimePnl(props) {
|
|
435
441
|
return await this.vaults.getVaultUserLifetimePnl(props);
|
|
@@ -54,9 +54,10 @@ export declare class AugustApi extends AugustBase {
|
|
|
54
54
|
* token.
|
|
55
55
|
*
|
|
56
56
|
* Backed by `GET /risk/collateral_excess_or_deficit` (60-second server-side
|
|
57
|
-
* cache), which resolves the subaccount and reads its current health factor
|
|
58
|
-
*
|
|
59
|
-
*
|
|
57
|
+
* cache), which resolves the subaccount and reads its current health factor.
|
|
58
|
+
* The backend serves this route to anonymous callers today, so no August API
|
|
59
|
+
* key is needed; pass one if you get `AUTH_UNAUTHORIZED`. Makes exactly one
|
|
60
|
+
* HTTP request and no RPC calls.
|
|
60
61
|
*
|
|
61
62
|
* @param params.subaccount Subaccount (smart-contract wallet) address.
|
|
62
63
|
* @param params.tokenAddress Collateral token address to evaluate.
|
|
@@ -86,9 +87,8 @@ export declare class AugustApi extends AugustBase {
|
|
|
86
87
|
* This is a pure, read-only simulation: the backend `POST
|
|
87
88
|
* /risk/collateral_simulation` endpoint (60-second server-side cache)
|
|
88
89
|
* computes required collateral and effective discount factors and changes
|
|
89
|
-
* no state.
|
|
90
|
-
*
|
|
91
|
-
* and no RPC calls.
|
|
90
|
+
* no state. The route is public, so no August API key is needed. Makes
|
|
91
|
+
* exactly one HTTP request and no RPC calls.
|
|
92
92
|
*
|
|
93
93
|
* @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.
|
|
94
94
|
* @returns The simulated {@link ICollateralSimulationResults}: total debt, required collateral, resulting health factor, and a per-token breakdown.
|
package/lib/modules/api/main.js
CHANGED
|
@@ -204,9 +204,10 @@ class AugustApi extends base_class_1.AugustBase {
|
|
|
204
204
|
* token.
|
|
205
205
|
*
|
|
206
206
|
* Backed by `GET /risk/collateral_excess_or_deficit` (60-second server-side
|
|
207
|
-
* cache), which resolves the subaccount and reads its current health factor
|
|
208
|
-
*
|
|
209
|
-
*
|
|
207
|
+
* cache), which resolves the subaccount and reads its current health factor.
|
|
208
|
+
* The backend serves this route to anonymous callers today, so no August API
|
|
209
|
+
* key is needed; pass one if you get `AUTH_UNAUTHORIZED`. Makes exactly one
|
|
210
|
+
* HTTP request and no RPC calls.
|
|
210
211
|
*
|
|
211
212
|
* @param params.subaccount Subaccount (smart-contract wallet) address.
|
|
212
213
|
* @param params.tokenAddress Collateral token address to evaluate.
|
|
@@ -244,9 +245,8 @@ class AugustApi extends base_class_1.AugustBase {
|
|
|
244
245
|
* This is a pure, read-only simulation: the backend `POST
|
|
245
246
|
* /risk/collateral_simulation` endpoint (60-second server-side cache)
|
|
246
247
|
* computes required collateral and effective discount factors and changes
|
|
247
|
-
* no state.
|
|
248
|
-
*
|
|
249
|
-
* and no RPC calls.
|
|
248
|
+
* no state. The route is public, so no August API key is needed. Makes
|
|
249
|
+
* exactly one HTTP request and no RPC calls.
|
|
250
250
|
*
|
|
251
251
|
* @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.
|
|
252
252
|
* @returns The simulated {@link ICollateralSimulationResults}: total debt, required collateral, resulting health factor, and a per-token breakdown.
|
|
@@ -4,7 +4,13 @@ import type { IAddress, ILoanBookInfo, ISubaccountDebank, ISubaccountTransaction
|
|
|
4
4
|
* Subaccount operation class interacting with August Subaccounts
|
|
5
5
|
* Subaccount is a smart contract wallet that serves as the fundamental infrastructure for August's platform.
|
|
6
6
|
* It functions as a cross-margin account designed for optimal capital efficiency.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
|
+
* `getSubaccountSummary`, `getSubaccountHealthFactor`, `getSubaccountLoans`,
|
|
9
|
+
* `getSubaccountCefiPositions` and `getSubaccountOtcPositions` work without an
|
|
10
|
+
* August API key for subaccounts linked to a vault; `getSubaccountDebank` is
|
|
11
|
+
* public. `getSubaccountTransactions` needs a key authorized for the
|
|
12
|
+
* subaccount, and `getAllSubaccounts` and `getSubaccountLoanByAddress` need an
|
|
13
|
+
* admin key.
|
|
8
14
|
*/
|
|
9
15
|
export declare class AugustSubAccounts extends AugustBase {
|
|
10
16
|
private headers;
|
|
@@ -25,7 +25,13 @@ function assertSubaccountAddress(address, method) {
|
|
|
25
25
|
* Subaccount operation class interacting with August Subaccounts
|
|
26
26
|
* Subaccount is a smart contract wallet that serves as the fundamental infrastructure for August's platform.
|
|
27
27
|
* It functions as a cross-margin account designed for optimal capital efficiency.
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* `getSubaccountSummary`, `getSubaccountHealthFactor`, `getSubaccountLoans`,
|
|
30
|
+
* `getSubaccountCefiPositions` and `getSubaccountOtcPositions` work without an
|
|
31
|
+
* August API key for subaccounts linked to a vault; `getSubaccountDebank` is
|
|
32
|
+
* public. `getSubaccountTransactions` needs a key authorized for the
|
|
33
|
+
* subaccount, and `getAllSubaccounts` and `getSubaccountLoanByAddress` need an
|
|
34
|
+
* admin key.
|
|
29
35
|
*/
|
|
30
36
|
class AugustSubAccounts extends core_1.AugustBase {
|
|
31
37
|
headers = null;
|