@augustdigital/sdk 8.7.2 → 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.
@@ -24,6 +24,18 @@ exports.METHOD_CATEGORIES = {
24
24
  getVaultPnl: 'read.vault',
25
25
  getVaultUnrealizedPnlHistory: 'read.vault',
26
26
  getLatestUnrealizedPnl: 'read.vault',
27
+ getDashboardLoans: 'read.vault',
28
+ getDiscountFactors: 'read.vault',
29
+ getCollateralExcessOrDeficit: 'read.vault',
30
+ simulateCollateral: 'read.vault',
31
+ getRevertReason: 'read.vault',
32
+ getOtcPositions: 'read.vault',
33
+ getOtcMarginRequirements: 'read.vault',
34
+ getCuratorVaultSubaccounts: 'read.vault',
35
+ getCuratorVaultWhitelist: 'read.vault',
36
+ getTimelockRequests: 'read.vault',
37
+ getVaultPerformanceFees: 'read.vault',
38
+ getVaultOracleClassification: 'read.vault',
27
39
  getVaultBorrowerHealthFactor: 'read.vault',
28
40
  getYieldLastRealizedOn: 'read.vault',
29
41
  getVaultActivity: 'read.vault',
@@ -42,11 +54,15 @@ exports.METHOD_CATEGORIES = {
42
54
  getPrice: 'read.price',
43
55
  getUserPoints: 'read.points',
44
56
  fetchPointsLeaderboard: 'read.points',
57
+ getAllSubaccounts: 'read.subaccount',
45
58
  getSubaccountHealthFactor: 'read.subaccount',
46
59
  getSubaccountLoans: 'read.subaccount',
47
60
  getSubaccountCefiPositions: 'read.subaccount',
48
61
  getSubaccountOtcPositions: 'read.subaccount',
49
62
  getSubaccountSummary: 'read.subaccount',
63
+ getSubaccountTransactions: 'read.subaccount',
64
+ getSubaccountLoanByAddress: 'read.subaccount',
65
+ getSubaccountDebank: 'read.subaccount',
50
66
  getStakingPositions: 'read.staking',
51
67
  getVaultStakingPositions: 'read.staking',
52
68
  getLayerZeroDeposits: 'read.layerzero',
@@ -3,4 +3,4 @@
3
3
  * Generated during publish from package.json version
4
4
  * This file is gitignored and created at publish time
5
5
  */
6
- export declare const SDK_VERSION = "8.7.2";
6
+ export declare const SDK_VERSION = "8.9.0";
@@ -6,5 +6,5 @@ exports.SDK_VERSION = void 0;
6
6
  * Generated during publish from package.json version
7
7
  * This file is gitignored and created at publish time
8
8
  */
9
- exports.SDK_VERSION = '8.7.2';
9
+ exports.SDK_VERSION = '8.9.0';
10
10
  //# sourceMappingURL=version.js.map
@@ -63,6 +63,25 @@ export interface IAugustBase {
63
63
  * with different timeouts in the same process.
64
64
  */
65
65
  timeoutMs?: number;
66
+ /**
67
+ * Override the base URL for the SDK's unauthenticated `public` vault-catalog
68
+ * API (what `getVault` / `getVaults` / `fetchTokenizedVault` read from).
69
+ * Defaults to the compiled-in prod base
70
+ * (`https://api.augustdigital.io/api/v1`) when omitted — so production apps
71
+ * pass nothing and behaviour is unchanged.
72
+ *
73
+ * Set this ONLY for a non-prod deployment that runs against an isolated
74
+ * backend (e.g. a staging API serving staging-only vaults). Must be an
75
+ * absolute http(s) URL including any base path, e.g.
76
+ * `https://api.staging.augustdigital.io/api/v1`. Invalid values are ignored.
77
+ *
78
+ * Note: this is a process-global override on the underlying fetcher helpers,
79
+ * applied on EVERY construction — so the last `AugustSDK` instantiated is
80
+ * authoritative, and one that omits `publicApiBaseUrl` RESETS to the prod
81
+ * default. (Stricter than `timeoutMs`, which stays sticky when omitted, since
82
+ * a stale cross-environment base is higher blast-radius than a stale timeout.)
83
+ */
84
+ publicApiBaseUrl?: string;
66
85
  }
67
86
  interface IActiveNetwork {
68
87
  chainId: IChainId;
@@ -87,7 +106,7 @@ export declare class AugustBase {
87
106
  * @throws If `appName` is missing, malformed, or out of the allowed
88
107
  * length range — see {@link IAugustBase.appName}.
89
108
  */
90
- constructor({ appName, providers, keys, monitoring, analytics, versionCheck, timeoutMs, }: IAugustBase);
109
+ constructor({ appName, providers, keys, monitoring, analytics, versionCheck, timeoutMs, publicApiBaseUrl, }: IAugustBase);
91
110
  /**
92
111
  * Verify API keys and authorize SDK usage.
93
112
  * TODO: initialize class with appropriate keys and verify august key
@@ -55,7 +55,7 @@ class AugustBase {
55
55
  * @throws If `appName` is missing, malformed, or out of the allowed
56
56
  * length range — see {@link IAugustBase.appName}.
57
57
  */
58
- constructor({ appName, providers = {}, keys, monitoring, analytics, versionCheck, timeoutMs, }) {
58
+ constructor({ appName, providers = {}, keys, monitoring, analytics, versionCheck, timeoutMs, publicApiBaseUrl, }) {
59
59
  // Validate first so the failure mode is a clear, actionable error before
60
60
  // any provider / analytics side effects run.
61
61
  this.appName = validateAppName(appName);
@@ -88,6 +88,13 @@ class AugustBase {
88
88
  if (typeof timeoutMs === 'number') {
89
89
  (0, fetcher_1.setSdkRequestTimeout)(timeoutMs);
90
90
  }
91
+ // Repoint the unauthenticated `public` vault-catalog API when a non-prod
92
+ // deployment supplies an isolated backend. Called UNCONDITIONALLY so each
93
+ // instance is authoritative: an instance that omits `publicApiBaseUrl`
94
+ // passes `null` and RESETS to the compiled-in prod default. Without this a
95
+ // prior staging instance would leak into a later prod instance in the same
96
+ // process — the inverse of the isolation this option exists to provide.
97
+ (0, fetcher_1.setPublicApiBaseUrl)(publicApiBaseUrl ?? null);
91
98
  }
92
99
  /**
93
100
  * Verify API keys and authorize SDK usage.
@@ -30,6 +30,7 @@ export declare const WEBSERVER_ENDPOINTS: {
30
30
  refresh: string;
31
31
  };
32
32
  subaccount: {
33
+ list: (offset?: number, limit?: number) => string;
33
34
  rewards: (subaccount: IAddress) => string;
34
35
  tokens: (subaccount: IAddress) => string;
35
36
  twap: {
@@ -44,14 +45,43 @@ export declare const WEBSERVER_ENDPOINTS: {
44
45
  loans: (subaccount: IAddress, side?: "BORROWER" | "LENDER" | "BOTH", active?: boolean) => string;
45
46
  cefi: (subaccount: IAddress) => string;
46
47
  otc_positions: (subaccount: IAddress) => string;
48
+ loanByAddress: (loanAddress: string, chainId: number) => string;
47
49
  _: (subaccount: IAddress) => string;
48
50
  };
51
+ transactions: {
52
+ v2: (subaccount: string, startTime?: string, endTime?: string) => string;
53
+ };
54
+ otc: {
55
+ positions: string;
56
+ marginRequirements: (otcCounterpartyId?: string, payer?: string) => string;
57
+ };
58
+ curator: {
59
+ vaultSubaccounts: (vaultAddress: string) => string;
60
+ vaultWhitelist: (vaultAddress: string) => string;
61
+ };
62
+ timelockRequests: (vaultAddress: string, chainId: number, status?: string) => string;
49
63
  users: {
50
64
  get: string;
51
65
  };
66
+ dashboard: {
67
+ loans: string;
68
+ };
69
+ risk: {
70
+ discountFactors: string;
71
+ collateralExcessOrDeficit: (subaccount: string, tokenAddress: string, tokenChain: number, targetHealthFactor?: number) => string;
72
+ collateralSimulation: string;
73
+ };
52
74
  prices: (symbol: string) => string;
53
75
  metrics: {
54
76
  pnl: (subaccount: IAddress, startTime?: string, endTime?: string) => string;
77
+ vaultPerformanceFees: (params: {
78
+ vaultAddress: string;
79
+ annualizedFeesPct: number;
80
+ nativeDenominated: boolean;
81
+ calculationPeriod: string;
82
+ startDate?: string;
83
+ endDate?: string;
84
+ }) => string;
55
85
  };
56
86
  public: {
57
87
  integrations: {
@@ -85,6 +115,8 @@ export declare const WEBSERVER_ENDPOINTS: {
85
115
  unrealizedHistory: (vaultAddress: VaultAddress, limit?: number) => string;
86
116
  unrealizedLatest: string;
87
117
  };
118
+ revertReason: (txHash: string, chain: number) => string;
119
+ oracleClassification: (vaultAddress: string, chainId: number) => string;
88
120
  };
89
121
  upshift: {
90
122
  vaults: {
@@ -33,6 +33,7 @@ exports.WEBSERVER_ENDPOINTS = {
33
33
  refresh: '/auth/refresh',
34
34
  },
35
35
  subaccount: {
36
+ list: (offset = 0, limit = 100) => `/subaccount?offset=${offset}&limit=${limit}`,
36
37
  rewards: (subaccount) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}/rewards`,
37
38
  tokens: (subaccount) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}/tokens`,
38
39
  twap: {
@@ -47,14 +48,80 @@ exports.WEBSERVER_ENDPOINTS = {
47
48
  loans: (subaccount, side = 'BOTH', active = true) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}/loans?side=${side}&active=${active}`,
48
49
  cefi: (subaccount) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}/cefi_position`,
49
50
  otc_positions: (subaccount) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}/otc_positions`,
51
+ loanByAddress: (loanAddress, chainId) => `/subaccount/loans/${encodeURIComponent(loanAddress)}?chain_id=${chainId}`,
50
52
  _: (subaccount) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}`,
51
53
  },
54
+ transactions: {
55
+ v2: (subaccount, startTime, endTime) => {
56
+ const params = new URLSearchParams({ address: subaccount });
57
+ if (startTime !== undefined)
58
+ params.set('start_time', startTime);
59
+ if (endTime !== undefined)
60
+ params.set('end_time', endTime);
61
+ return `/transactions/v2?${params.toString()}`;
62
+ },
63
+ },
64
+ otc: {
65
+ positions: '/otc/position',
66
+ marginRequirements: (otcCounterpartyId, payer) => {
67
+ const params = new URLSearchParams();
68
+ if (otcCounterpartyId !== undefined)
69
+ params.set('otc_counter_party_id', otcCounterpartyId);
70
+ if (payer !== undefined)
71
+ params.set('payer', payer);
72
+ const query = params.toString();
73
+ return `/otc/margin_requirement${query ? `?${query}` : ''}`;
74
+ },
75
+ },
76
+ curator: {
77
+ vaultSubaccounts: (vaultAddress) => `/curator/vaults/${encodeURIComponent(vaultAddress)}/subaccounts`,
78
+ vaultWhitelist: (vaultAddress) => `/curator/vaults/${encodeURIComponent(vaultAddress)}/whitelist`,
79
+ },
80
+ timelockRequests: (vaultAddress, chainId, status) => {
81
+ const params = new URLSearchParams({
82
+ vaultAddress,
83
+ chainId: String(chainId),
84
+ });
85
+ if (status !== undefined)
86
+ params.set('status', status);
87
+ return `/timelock-requests?${params.toString()}`;
88
+ },
52
89
  users: {
53
90
  get: '/users',
54
91
  },
92
+ dashboard: {
93
+ loans: '/dashboard/loans',
94
+ },
95
+ risk: {
96
+ discountFactors: '/risk/discount_factors',
97
+ collateralExcessOrDeficit: (subaccount, tokenAddress, tokenChain, targetHealthFactor) => {
98
+ const params = new URLSearchParams({
99
+ address: subaccount,
100
+ token_address: tokenAddress,
101
+ token_chain: String(tokenChain),
102
+ });
103
+ if (targetHealthFactor !== undefined)
104
+ params.set('target_health_factor', String(targetHealthFactor));
105
+ return `/risk/collateral_excess_or_deficit?${params.toString()}`;
106
+ },
107
+ collateralSimulation: '/risk/collateral_simulation',
108
+ },
55
109
  prices: (symbol) => `/prices/${symbol}`,
56
110
  metrics: {
57
111
  pnl: (subaccount, startTime, endTime) => `/metrics/pnl?subaccount_address=${(0, ethers_1.getAddress)(subaccount)}${startTime && endTime ? `&start=${startTime}&end=${endTime}` : ''}`,
112
+ vaultPerformanceFees: (params) => {
113
+ const q = new URLSearchParams({
114
+ vault_address: params.vaultAddress,
115
+ annualized_fees_pct: String(params.annualizedFeesPct),
116
+ native_denominated: String(params.nativeDenominated),
117
+ calculation_period: params.calculationPeriod,
118
+ });
119
+ if (params.startDate !== undefined)
120
+ q.set('start_date', params.startDate);
121
+ if (params.endDate !== undefined)
122
+ q.set('end_date', params.endDate);
123
+ return `/metrics/vault_performance_fees?${q.toString()}`;
124
+ },
58
125
  },
59
126
  public: {
60
127
  integrations: {
@@ -92,6 +159,11 @@ exports.WEBSERVER_ENDPOINTS = {
92
159
  unrealizedHistory: (vaultAddress, limit) => `/upshift/unrealized_pnl?vault_address=${vaultAddress}${limit !== undefined ? `&limit=${limit}` : ''}`,
93
160
  unrealizedLatest: '/upshift/unrealized_pnl/latest',
94
161
  },
162
+ revertReason: (txHash, chain) => `/revert_reason?${new URLSearchParams({
163
+ tx_hash: txHash,
164
+ chain: String(chain),
165
+ }).toString()}`,
166
+ oracleClassification: (vaultAddress, chainId) => `/upshift/oracle_classification/${encodeURIComponent(vaultAddress)}?chain_id=${chainId}`,
95
167
  },
96
168
  upshift: {
97
169
  vaults: {
@@ -20,6 +20,11 @@ export declare const VAULT_ALLOCATION_SUBACCOUNTS: {
20
20
  subaccount: IAddress;
21
21
  useDebank: boolean;
22
22
  };
23
+ MonarqXRP: {
24
+ address: IAddress;
25
+ subaccount: IAddress;
26
+ useDebank: boolean;
27
+ };
23
28
  };
24
29
  /**
25
30
  * @deprecated use the backend responses /tokenized_vault internal_type field to determine if the vault is an old lending pool
@@ -26,6 +26,13 @@ exports.VAULT_ALLOCATION_SUBACCOUNTS = {
26
26
  subaccount: (0, ethers_1.getAddress)('0xC8c0Ffb8Ff3BDA26321224e800B3B38AEaB48799'),
27
27
  useDebank: true,
28
28
  },
29
+ // For the Monarq XRP Yield Vault (Flare), surface the borrower subaccount and
30
+ // keep vault-level Debank exposure (mirrors earnAUSD).
31
+ MonarqXRP: {
32
+ address: (0, ethers_1.getAddress)('0x2439D4bb753A0f3777d4C9011AFacc475ba6B951'),
33
+ subaccount: (0, ethers_1.getAddress)('0xF755B2244C1C1f20cA03C3Bb472175C9a4E250f2'),
34
+ useDebank: true,
35
+ },
29
36
  };
30
37
  /**
31
38
  * @deprecated use the backend responses /tokenized_vault internal_type field to determine if the vault is an old lending pool
@@ -12,6 +12,23 @@ export declare const SPECIAL_CHAINS: {
12
12
  };
13
13
  };
14
14
  export declare const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
15
+ /**
16
+ * Decimal precision of the native gas token on every EVM chain this SDK
17
+ * supports (ETH, Base, Arbitrum, Avalanche, Polygon, BNB, HyperEVM, Unichain,
18
+ * Mezo, Monad, Plasma, Ink, Flare, Katana, Citrea, Fluent, Tempo).
19
+ *
20
+ * All of them use 18-decimal native tokens, so this is a single constant rather
21
+ * than a per-chain map. It exists because the native token has no ERC-20
22
+ * `decimals()` to read on-chain: when a subgraph row denominates an amount in
23
+ * the native token it is flagged with a sentinel address ({@link NATIVE_ADDRESS}
24
+ * or the zero address) instead of a real contract, and callers must substitute
25
+ * this value rather than attempting (and failing) a `decimals()` read.
26
+ *
27
+ * Non-EVM natives differ (SOL is 9, XLM is 7) and are handled by their own
28
+ * adapters — those chains never flow through the EVM `decimals()` path this
29
+ * constant serves.
30
+ */
31
+ export declare const EVM_NATIVE_DECIMALS = 18;
15
32
  export declare const MIN_ABIS: {
16
33
  name: string;
17
34
  symbol: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FALLBACK_RPC_URLS = exports.FALLBACK_CHAINID = exports.FALLBACK_DECIMALS = exports.AVAILABLE_CHAINS = exports.NETWORKS = exports.ORACLE_CONTRACTS = exports.MIN_ABIS = exports.NATIVE_ADDRESS = exports.SPECIAL_CHAINS = void 0;
3
+ exports.FALLBACK_RPC_URLS = exports.FALLBACK_CHAINID = exports.FALLBACK_DECIMALS = exports.AVAILABLE_CHAINS = exports.NETWORKS = exports.ORACLE_CONTRACTS = exports.MIN_ABIS = exports.EVM_NATIVE_DECIMALS = exports.NATIVE_ADDRESS = exports.SPECIAL_CHAINS = void 0;
4
4
  // Special Chains
5
5
  exports.SPECIAL_CHAINS = {
6
6
  solana: {
@@ -16,6 +16,23 @@ exports.SPECIAL_CHAINS = {
16
16
  };
17
17
  // General
18
18
  exports.NATIVE_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
19
+ /**
20
+ * Decimal precision of the native gas token on every EVM chain this SDK
21
+ * supports (ETH, Base, Arbitrum, Avalanche, Polygon, BNB, HyperEVM, Unichain,
22
+ * Mezo, Monad, Plasma, Ink, Flare, Katana, Citrea, Fluent, Tempo).
23
+ *
24
+ * All of them use 18-decimal native tokens, so this is a single constant rather
25
+ * than a per-chain map. It exists because the native token has no ERC-20
26
+ * `decimals()` to read on-chain: when a subgraph row denominates an amount in
27
+ * the native token it is flagged with a sentinel address ({@link NATIVE_ADDRESS}
28
+ * or the zero address) instead of a real contract, and callers must substitute
29
+ * this value rather than attempting (and failing) a `decimals()` read.
30
+ *
31
+ * Non-EVM natives differ (SOL is 9, XLM is 7) and are handled by their own
32
+ * adapters — those chains never flow through the EVM `decimals()` path this
33
+ * constant serves.
34
+ */
35
+ exports.EVM_NATIVE_DECIMALS = 18;
19
36
  exports.MIN_ABIS = {
20
37
  name: 'function name() view returns (string)',
21
38
  symbol: 'function symbol() view returns (string)',
@@ -41,6 +41,41 @@ 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
+ * Override the base URL used for `WEBSERVER_URL.public` requests — the
46
+ * unauthenticated vault-catalog API that `getVault` / `fetchTokenizedVault`
47
+ * (and the other `fetchAugustPublic` callers) read from. Defaults to the
48
+ * compiled-in prod base (`https://api.augustdigital.io/api/v1`); pass `null`
49
+ * (or call with no arguments) to clear.
50
+ *
51
+ * Intended for non-prod deployments that run against an ISOLATED backend
52
+ * (e.g. a staging API): set it once at construction via
53
+ * `IAugustBase.publicApiBaseUrl` so a staging-only vault resolves. Production
54
+ * leaves it unset, so behaviour is unchanged.
55
+ *
56
+ * This is a process-global override on the fetcher helpers. The SDK constructor
57
+ * calls it on EVERY instantiation (with `null` when `publicApiBaseUrl` is
58
+ * omitted), so the last `AugustSDK` instantiated is authoritative — a prod
59
+ * instance resets it to the default even after a prior staging instance set it.
60
+ * An invalid or non-http(s) URL is treated as "no override": it RESETS to the
61
+ * compiled-in default (warned) rather than retaining a prior value, so a bad env
62
+ * value can neither break fetches nor silently leave a previous instance's base
63
+ * in place.
64
+ *
65
+ * Whenever the effective base CHANGES, the shared public-response cache is
66
+ * cleared, so catalog data fetched from the previous backend is never served for
67
+ * the new one (e.g. a prod-cached vault leaking into a staging instance). Base
68
+ * changes happen at construction, when the cache is cold, so this is ~free.
69
+ *
70
+ * @param url - Absolute http(s) base URL (trailing slash is trimmed). `null`, or
71
+ * an invalid / non-http(s) value, resets to the compiled-in public base.
72
+ */
73
+ export declare function setPublicApiBaseUrl(url?: string | null): void;
74
+ /**
75
+ * Read the active base for the `public` server — the SDK-level override if set,
76
+ * otherwise the compiled-in `WEBSERVER_URL.public`.
77
+ */
78
+ export declare function getPublicApiBaseUrl(): string;
44
79
  import { CACHE, getSafeCache, setSafeCache } from './cache';
45
80
  export { CACHE, getSafeCache, setSafeCache };
46
81
  /**
@@ -3,6 +3,8 @@ 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.setPublicApiBaseUrl = setPublicApiBaseUrl;
7
+ exports.getPublicApiBaseUrl = getPublicApiBaseUrl;
6
8
  exports.fetchAugustWithKey = fetchAugustWithKey;
7
9
  exports.fetchAugustPublic = fetchAugustPublic;
8
10
  exports.fetchAugustWithBearer = fetchAugustWithBearer;
@@ -73,6 +75,78 @@ function setSdkRequestTimeout(ms = null) {
73
75
  function getSdkRequestTimeout() {
74
76
  return SDK_REQUEST_TIMEOUT_OVERRIDE ?? core_2.REQUEST_TIMEOUT_MS;
75
77
  }
78
+ let PUBLIC_API_BASE_OVERRIDE = null;
79
+ /**
80
+ * Override the base URL used for `WEBSERVER_URL.public` requests — the
81
+ * unauthenticated vault-catalog API that `getVault` / `fetchTokenizedVault`
82
+ * (and the other `fetchAugustPublic` callers) read from. Defaults to the
83
+ * compiled-in prod base (`https://api.augustdigital.io/api/v1`); pass `null`
84
+ * (or call with no arguments) to clear.
85
+ *
86
+ * Intended for non-prod deployments that run against an ISOLATED backend
87
+ * (e.g. a staging API): set it once at construction via
88
+ * `IAugustBase.publicApiBaseUrl` so a staging-only vault resolves. Production
89
+ * leaves it unset, so behaviour is unchanged.
90
+ *
91
+ * This is a process-global override on the fetcher helpers. The SDK constructor
92
+ * calls it on EVERY instantiation (with `null` when `publicApiBaseUrl` is
93
+ * omitted), so the last `AugustSDK` instantiated is authoritative — a prod
94
+ * instance resets it to the default even after a prior staging instance set it.
95
+ * An invalid or non-http(s) URL is treated as "no override": it RESETS to the
96
+ * compiled-in default (warned) rather than retaining a prior value, so a bad env
97
+ * value can neither break fetches nor silently leave a previous instance's base
98
+ * in place.
99
+ *
100
+ * Whenever the effective base CHANGES, the shared public-response cache is
101
+ * cleared, so catalog data fetched from the previous backend is never served for
102
+ * the new one (e.g. a prod-cached vault leaking into a staging instance). Base
103
+ * changes happen at construction, when the cache is cold, so this is ~free.
104
+ *
105
+ * @param url - Absolute http(s) base URL (trailing slash is trimmed). `null`, or
106
+ * an invalid / non-http(s) value, resets to the compiled-in public base.
107
+ */
108
+ function setPublicApiBaseUrl(url = null) {
109
+ const previous = PUBLIC_API_BASE_OVERRIDE;
110
+ if (url === null) {
111
+ PUBLIC_API_BASE_OVERRIDE = null;
112
+ }
113
+ else {
114
+ let parsed = null;
115
+ try {
116
+ parsed = new URL(url);
117
+ }
118
+ catch {
119
+ parsed = null;
120
+ }
121
+ if (!parsed ||
122
+ (parsed.protocol !== 'https:' && parsed.protocol !== 'http:')) {
123
+ // Reset to the default rather than retaining a stale prior override, so
124
+ // each construction stays authoritative and a bad env value fails safe to
125
+ // prod instead of inheriting another instance's base.
126
+ logger_1.Logger.log.warn('setPublicApiBaseUrl', 'Ignoring invalid/non-http(s) URL; resetting to the default public base', { url });
127
+ PUBLIC_API_BASE_OVERRIDE = null;
128
+ }
129
+ else {
130
+ // Store WITHOUT a trailing slash: buildAugustUrl concatenates
131
+ // `${base}${relativeUrl}` (relativeUrl starts with '/'), so a trailing
132
+ // slash on the base would produce a double slash.
133
+ PUBLIC_API_BASE_OVERRIDE = url.replace(/\/+$/, '');
134
+ }
135
+ }
136
+ if (PUBLIC_API_BASE_OVERRIDE !== previous) {
137
+ // The public base moved (or reset). Drop cached public-catalog responses
138
+ // keyed against the previous base (see fetchTokenizedVault(s) etc.) so they
139
+ // aren't served for the new backend.
140
+ cache_1.CACHE.clear();
141
+ }
142
+ }
143
+ /**
144
+ * Read the active base for the `public` server — the SDK-level override if set,
145
+ * otherwise the compiled-in `WEBSERVER_URL.public`.
146
+ */
147
+ function getPublicApiBaseUrl() {
148
+ return PUBLIC_API_BASE_OVERRIDE ?? core_2.WEBSERVER_URL.public;
149
+ }
76
150
  /**
77
151
  * Combine the per-request timeout signal with any caller-supplied signal.
78
152
  * Uses `AbortSignal.any` (Node 22+) with a manual relay fallback.
@@ -182,7 +256,12 @@ const PRICE_REQUESTS = new Map();
182
256
  */
183
257
  function buildAugustUrl(server, relativeUrl) {
184
258
  const serverKey = server;
185
- const base = core_2.WEBSERVER_URL[serverKey];
259
+ // The `public` base is overridable (setPublicApiBaseUrl / IAugustBase
260
+ // .publicApiBaseUrl) so non-prod deployments can point vault-catalog reads at
261
+ // an isolated backend. Resolved once here via getPublicApiBaseUrl() (single
262
+ // source of truth), so the origin check below validates against the OVERRIDDEN
263
+ // origin.
264
+ const base = serverKey === 'public' ? getPublicApiBaseUrl() : core_2.WEBSERVER_URL[serverKey];
186
265
  if (!base) {
187
266
  throw new errors_1.AugustValidationError('INVALID_URL', `Unknown August server "${String(server)}". Expected one of: ${Object.keys(core_2.WEBSERVER_URL).join(', ')}`);
188
267
  }
package/lib/main.js CHANGED
@@ -111,7 +111,7 @@ class AugustSDK extends core_1.AugustBase {
111
111
  this.stellar = new stellar_1.default();
112
112
  this.vaults = new vaults_1.AugustVaults(baseConfig, this.solana, this.sui);
113
113
  this.subaccounts = new sub_accounts_1.AugustSubAccounts(baseConfig);
114
- this.api = new api_1.AugustApi();
114
+ this.api = new api_1.AugustApi(baseConfig);
115
115
  // Instrument all SDK methods for analytics tracking
116
116
  (0, analytics_1.instrumentClass)(this, () => this.activeNetwork?.chainId);
117
117
  (0, analytics_1.instrumentClass)(this.evm, () => this.activeNetwork?.chainId);
@@ -0,0 +1,82 @@
1
+ import { type IFetchAugustOptions } from '../../core';
2
+ import type { ICollateralExcessOrDeficit, ICollateralSimulationInput, ICollateralSimulationResults, ICuratorWhitelistStatus, IDiscountFactorLadder, ILoanBookInfo, IOracleClassification, IOtcMarginRequirement, IOtcPositionRead, IRevertReason, ITimelockRequest, IVaultPerformanceFees, IWSSubaccountListItem } from '../../types';
3
+ /**
4
+ * Fetch the global loan-book aggregate (admin-only `GET /dashboard/loans`).
5
+ */
6
+ export declare const fetchDashboardLoans: (augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ILoanBookInfo[]>;
7
+ /**
8
+ * Fetch every token discount-factor ladder (`GET /risk/discount_factors`).
9
+ */
10
+ export declare const fetchDiscountFactors: (augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IDiscountFactorLadder[]>;
11
+ /**
12
+ * Fetch a subaccount's collateral excess/deficit for one token
13
+ * (`GET /risk/collateral_excess_or_deficit`).
14
+ */
15
+ export declare const fetchCollateralExcessOrDeficit: (params: {
16
+ subaccount: string;
17
+ tokenAddress: string;
18
+ tokenChain: number;
19
+ targetHealthFactor?: number;
20
+ }, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ICollateralExcessOrDeficit>;
21
+ /**
22
+ * Run a collateral simulation (`POST /risk/collateral_simulation`). This is a
23
+ * pure, read-only simulation — the backend computes required collateral for a
24
+ * hypothetical loan and changes no state.
25
+ */
26
+ export declare const fetchCollateralSimulation: (body: ICollateralSimulationInput, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ICollateralSimulationResults>;
27
+ /**
28
+ * Fetch the decoded revert reason(s) for a transaction from the public
29
+ * `GET /revert_reason` endpoint. No API key required.
30
+ */
31
+ export declare const fetchRevertReason: (txHash: string, chain: number, headers?: IFetchAugustOptions["headers"]) => Promise<IRevertReason>;
32
+ /**
33
+ * Fetch all OTC positions (admin-only `GET /otc/position`).
34
+ */
35
+ export declare const fetchOtcPositions: (augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IOtcPositionRead[]>;
36
+ /**
37
+ * Fetch OTC margin requirements (admin-only `GET /otc/margin_requirement`),
38
+ * optionally filtered by counterparty id and/or payer.
39
+ */
40
+ export declare const fetchOtcMarginRequirements: (filters: {
41
+ otcCounterpartyId?: string;
42
+ payer?: string;
43
+ }, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IOtcMarginRequirement[]>;
44
+ /**
45
+ * Fetch the subaccounts linked to a vault (curator-or-admin
46
+ * `GET /curator/vaults/{vault_address}/subaccounts`).
47
+ */
48
+ export declare const fetchCuratorVaultSubaccounts: (vaultAddress: string, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountListItem[]>;
49
+ /**
50
+ * Fetch on-chain whitelist status for a vault's subaccounts (curator-or-admin
51
+ * `GET /curator/vaults/{vault_address}/whitelist`). EVM vaults only — the
52
+ * backend 400s for non-EVM vaults.
53
+ */
54
+ export declare const fetchCuratorVaultWhitelist: (vaultAddress: string, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ICuratorWhitelistStatus[]>;
55
+ /**
56
+ * Fetch timelock requests for a vault on a chain (`GET /timelock-requests`),
57
+ * optionally filtered by status.
58
+ */
59
+ export declare const fetchTimelockRequests: (params: {
60
+ vaultAddress: string;
61
+ chainId: number;
62
+ status?: string;
63
+ }, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ITimelockRequest[]>;
64
+ /**
65
+ * Fetch a vault's performance-fee computation
66
+ * (`GET /metrics/vault_performance_fees`). Slow first call (pandas over full
67
+ * snapshot history); 20-minute server-side cache.
68
+ */
69
+ export declare const fetchVaultPerformanceFees: (params: {
70
+ vaultAddress: string;
71
+ annualizedFeesPct: number;
72
+ nativeDenominated: boolean;
73
+ calculationPeriod: string;
74
+ startDate?: string;
75
+ endDate?: string;
76
+ }, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IVaultPerformanceFees>;
77
+ /**
78
+ * Fetch a vault's NAV-oracle classification table from the public
79
+ * `GET /upshift/oracle_classification/{vault_address}` endpoint. No API key
80
+ * required.
81
+ */
82
+ export declare const fetchVaultOracleClassification: (vaultAddress: string, chainId: number, headers?: IFetchAugustOptions["headers"]) => Promise<IOracleClassification>;