@augustdigital/sdk 8.5.0 → 8.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +207 -117
  2. package/lib/adapters/evm/index.d.ts +4 -4
  3. package/lib/adapters/evm/index.js +2 -0
  4. package/lib/adapters/solana/constants.d.ts +1 -1
  5. package/lib/adapters/solana/getters.d.ts +1 -1
  6. package/lib/adapters/solana/index.d.ts +4 -4
  7. package/lib/adapters/solana/index.js +4 -0
  8. package/lib/adapters/solana/types.d.ts +1 -1
  9. package/lib/adapters/solana/utils.d.ts +3 -3
  10. package/lib/adapters/solana/vault.actions.d.ts +4 -4
  11. package/lib/adapters/stellar/actions.d.ts +1 -1
  12. package/lib/adapters/stellar/index.d.ts +24 -2
  13. package/lib/adapters/stellar/index.js +25 -2
  14. package/lib/adapters/stellar/soroban.d.ts +1 -1
  15. package/lib/adapters/stellar/soroban.js +1 -1
  16. package/lib/adapters/stellar/submit.d.ts +20 -3
  17. package/lib/adapters/stellar/submit.js +74 -8
  18. package/lib/adapters/sui/getters.d.ts +1 -1
  19. package/lib/adapters/sui/index.d.ts +1 -1
  20. package/lib/adapters/sui/index.js +2 -0
  21. package/lib/adapters/sui/transformer.d.ts +2 -2
  22. package/lib/adapters/sui/transformer.js +1 -0
  23. package/lib/adapters/sui/types.d.ts +1 -1
  24. package/lib/core/analytics/instrumentation.js +7 -11
  25. package/lib/core/analytics/sentry-runtime.js +1 -1
  26. package/lib/core/analytics/sentry.d.ts +3 -3
  27. package/lib/core/analytics/sentry.js +31 -5
  28. package/lib/core/analytics/types.d.ts +1 -1
  29. package/lib/core/analytics/user-identity.d.ts +2 -2
  30. package/lib/core/analytics/user-identity.js +1 -1
  31. package/lib/core/analytics/version.d.ts +1 -1
  32. package/lib/core/analytics/version.js +1 -1
  33. package/lib/core/base.class.d.ts +3 -3
  34. package/lib/core/base.class.js +10 -4
  35. package/lib/core/constants/adapters.d.ts +1 -1
  36. package/lib/core/constants/core.d.ts +2 -0
  37. package/lib/core/constants/core.js +6 -0
  38. package/lib/core/constants/swap-router.d.ts +37 -1
  39. package/lib/core/constants/swap-router.js +41 -1
  40. package/lib/core/constants/vaults.d.ts +1 -1
  41. package/lib/core/constants/web3.d.ts +1 -1
  42. package/lib/core/constants/web3.js +0 -3
  43. package/lib/core/errors/index.d.ts +2 -2
  44. package/lib/core/errors/index.js +9 -0
  45. package/lib/core/fetcher.d.ts +39 -39
  46. package/lib/core/fetcher.js +75 -57
  47. package/lib/core/helpers/adapters.d.ts +1 -1
  48. package/lib/core/helpers/chain-error.d.ts +66 -0
  49. package/lib/core/helpers/chain-error.js +174 -0
  50. package/lib/core/helpers/core.d.ts +21 -18
  51. package/lib/core/helpers/core.js +22 -20
  52. package/lib/core/helpers/explorer-link.d.ts +1 -1
  53. package/lib/core/helpers/signer.d.ts +1 -1
  54. package/lib/core/helpers/swap-router.d.ts +1 -1
  55. package/lib/core/helpers/vault-version.d.ts +1 -1
  56. package/lib/core/helpers/vaults.d.ts +1 -1
  57. package/lib/core/helpers/web3.d.ts +2 -2
  58. package/lib/core/helpers/web3.js +9 -9
  59. package/lib/core/index.d.ts +1 -0
  60. package/lib/core/index.js +1 -0
  61. package/lib/core/vault-metadata.d.ts +1 -1
  62. package/lib/core/version-check.js +1 -1
  63. package/lib/evm/methods/crossChainVault.js +1 -1
  64. package/lib/evm/types/crossChain.js +1 -1
  65. package/lib/main.d.ts +1 -1
  66. package/lib/main.js +7 -0
  67. package/lib/modules/sub-accounts/fetcher.d.ts +2 -2
  68. package/lib/modules/sub-accounts/main.d.ts +2 -2
  69. package/lib/modules/sub-accounts/main.js +1 -1
  70. package/lib/modules/sub-accounts/utils.d.ts +1 -1
  71. package/lib/modules/vaults/adapter.helpers.d.ts +3 -3
  72. package/lib/modules/vaults/fetcher.d.ts +25 -0
  73. package/lib/modules/vaults/fetcher.js +51 -1
  74. package/lib/modules/vaults/getters.d.ts +50 -50
  75. package/lib/modules/vaults/getters.js +68 -67
  76. package/lib/modules/vaults/main.js +3 -1
  77. package/lib/modules/vaults/read.actions.d.ts +2 -2
  78. package/lib/modules/vaults/read.actions.js +26 -12
  79. package/lib/modules/vaults/utils/call-data-decoder.d.ts +1 -1
  80. package/lib/modules/vaults/utils.d.ts +19 -3
  81. package/lib/modules/vaults/utils.js +39 -6
  82. package/lib/modules/vaults/write.actions.js +73 -7
  83. package/lib/polyfills.js +3 -3
  84. package/lib/sdk.d.ts +1409 -1198
  85. package/lib/services/coingecko/fetcher.d.ts +10 -9
  86. package/lib/services/coingecko/fetcher.js +22 -18
  87. package/lib/services/debank/fetcher.d.ts +1 -1
  88. package/lib/services/debank/utils.d.ts +1 -1
  89. package/lib/services/debank/utils.js +1 -1
  90. package/lib/services/layerzero/deposits.d.ts +1 -1
  91. package/lib/services/layerzero/redeems.d.ts +1 -1
  92. package/lib/services/octavfi/fetcher.d.ts +1 -1
  93. package/lib/services/octavfi/types.d.ts +1 -1
  94. package/lib/services/octavfi/utils.d.ts +2 -2
  95. package/lib/services/subgraph/fetcher.js +1 -1
  96. package/lib/services/subgraph/vaults.js +86 -3
  97. package/lib/services/swap-quotes/index.d.ts +9 -0
  98. package/lib/services/swap-quotes/index.js +2 -1
  99. package/lib/services/swap-quotes/paraswap.d.ts +8 -0
  100. package/lib/services/swap-quotes/paraswap.js +8 -0
  101. package/lib/types/pools.d.ts +2 -2
  102. package/lib/types/staking.d.ts +1 -1
  103. package/lib/types/sub-accounts.d.ts +1 -1
  104. package/lib/types/subgraph.d.ts +10 -1
  105. package/lib/types/vaults.d.ts +26 -0
  106. package/lib/types/web3.d.ts +1 -1
  107. package/lib/types/webserver.d.ts +2 -2
  108. package/package.json +1 -1
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUserRejectionError = isUserRejectionError;
4
+ exports.isExpectedRevertError = isExpectedRevertError;
5
+ exports.logChainError = logChainError;
6
+ const logger_1 = require("../logger");
7
+ /**
8
+ * Classification of caught chain/RPC/wallet errors so the SDK can decide
9
+ * whether a failure is worth a standalone Sentry issue or is routine, expected
10
+ * noise that should ride along as a breadcrumb instead.
11
+ *
12
+ * Why this exists: most of the SDK's read/write paths `catch` and re-throw, and
13
+ * historically logged every caught error at `error` level — which the SDK's
14
+ * Sentry sink turns into a billed issue (see the severity policy on
15
+ * `SDKSentrySink` in `core/logger`). Two large, low-signal categories dominate
16
+ * that volume:
17
+ *
18
+ * 1. **User-rejected transactions** — the user clicked "reject" in their wallet.
19
+ * This is normal product behaviour, not an SDK fault, yet it fires on every
20
+ * cancelled deposit/redeem/approve.
21
+ * 2. **Expected on-chain read reverts** — reading a function a vault doesn't
22
+ * implement, or an address with no/incompatible bytecode, reverts. This is a
23
+ * routine outcome of probing heterogeneous vaults, not a defect.
24
+ *
25
+ * These predicates let call sites demote exactly those cases to `warn` while
26
+ * leaving genuine failures at `error`. They are intentionally dependency-free
27
+ * (no `ethers`/Sentry imports) so they stay cheap and safe in both browser and
28
+ * Node, and classify purely by inspecting the error's `code`/`message` shape.
29
+ *
30
+ * @module
31
+ */
32
+ /**
33
+ * Best-effort message extraction from an unknown thrown value. Reads
34
+ * `error.message` for `Error` and error-like objects, passes strings through,
35
+ * and falls back to `String(error)` for everything else. Never throws.
36
+ *
37
+ * @param error - The caught value, of unknown type.
38
+ * @returns The error's message text (never `undefined`).
39
+ */
40
+ function errorText(error) {
41
+ if (typeof error === 'string')
42
+ return error;
43
+ if (error instanceof Error)
44
+ return error.message;
45
+ if (error && typeof error === 'object') {
46
+ const maybe = error.message;
47
+ if (typeof maybe === 'string')
48
+ return maybe;
49
+ }
50
+ return String(error);
51
+ }
52
+ /**
53
+ * Collect the `code` fields an error-like value may carry. Wallet/provider
54
+ * errors stash their machine-readable code in different places depending on the
55
+ * stack: ethers sets a top-level string `code` (e.g. `'ACTION_REJECTED'`),
56
+ * EIP-1193 providers use a numeric `code` (e.g. `4001`), and some wrap the
57
+ * original under `error`/`info.error`/`cause`. We scan the common locations so
58
+ * callers needn't know which library produced the error.
59
+ *
60
+ * @param error - The caught value, of unknown type.
61
+ * @returns Every string/number `code` found (possibly empty).
62
+ */
63
+ function errorCodes(error) {
64
+ const codes = [];
65
+ if (error && typeof error === 'object') {
66
+ const e = error;
67
+ const candidates = [
68
+ e.code,
69
+ e.error?.code,
70
+ e.info?.error?.code,
71
+ e.cause?.code,
72
+ ];
73
+ for (const c of candidates) {
74
+ if (typeof c === 'string' || typeof c === 'number')
75
+ codes.push(c);
76
+ }
77
+ }
78
+ return codes;
79
+ }
80
+ /**
81
+ * Is this error a wallet/user rejection of a transaction or signature request?
82
+ *
83
+ * Detects ethers v6's `ACTION_REJECTED` code, the EIP-1193 `4001`
84
+ * ("User rejected the request") code (top-level or nested), and the common
85
+ * human-readable phrasings as a fallback for providers that omit a code.
86
+ *
87
+ * @param error - The caught value, of unknown type.
88
+ * @returns `true` when the failure was the user declining in their wallet.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * try { await vault.deposit(...); }
93
+ * catch (e) {
94
+ * if (isUserRejectionError(e)) return; // user cancelled — not an error
95
+ * throw e;
96
+ * }
97
+ * ```
98
+ */
99
+ function isUserRejectionError(error) {
100
+ const codes = errorCodes(error);
101
+ if (codes.includes('ACTION_REJECTED') || codes.includes(4001))
102
+ return true;
103
+ const msg = errorText(error).toLowerCase();
104
+ return (msg.includes('user rejected') ||
105
+ msg.includes('user denied') ||
106
+ msg.includes('rejected the request') ||
107
+ msg.includes('request rejected'));
108
+ }
109
+ /**
110
+ * Is this error a routine on-chain read revert rather than a real failure?
111
+ *
112
+ * Reading a function a contract doesn't implement, or an address that holds no
113
+ * (or incompatible) bytecode, reverts — a normal outcome when the SDK probes
114
+ * heterogeneous vaults. Matches ethers' `CALL_EXCEPTION` code and the
115
+ * message variants emitted by ethers and viem (`missing revert data`,
116
+ * `execution reverted`, `call revert exception`, and the bare `reverted`
117
+ * phrasing such as `the contract function "totalAssets" reverted`).
118
+ *
119
+ * Scope note: callers apply this on **read** paths only. A reverted *write*
120
+ * (a tx that failed on-chain) is a genuine error and is intentionally not
121
+ * demoted by this predicate's use in `write.actions`.
122
+ *
123
+ * @param error - The caught value, of unknown type.
124
+ * @returns `true` when the failure is an expected/benign contract revert.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * try { return await vaultContract.maxDepositAmount(); }
129
+ * catch (e) {
130
+ * logChainError('maxDeposit', e, isExpectedRevertError(e));
131
+ * throw e;
132
+ * }
133
+ * ```
134
+ */
135
+ function isExpectedRevertError(error) {
136
+ const codes = errorCodes(error);
137
+ if (codes.includes('CALL_EXCEPTION'))
138
+ return true;
139
+ const msg = errorText(error).toLowerCase();
140
+ return (msg.includes('call_exception') ||
141
+ msg.includes('missing revert data') ||
142
+ msg.includes('execution reverted') ||
143
+ msg.includes('call revert exception') ||
144
+ msg.includes('reverted'));
145
+ }
146
+ /**
147
+ * Log a caught chain error at the severity its category warrants, without
148
+ * swallowing it. When `isBenign` is `true` the failure is recorded as a `warn`
149
+ * (a Sentry breadcrumb that rides along with the next real issue, not a billed
150
+ * standalone issue); otherwise it is logged at `error` (a Sentry issue). The
151
+ * caller is still responsible for re-throwing — this only routes telemetry.
152
+ *
153
+ * Pass the benign decision explicitly (via {@link isUserRejectionError} or
154
+ * {@link isExpectedRevertError}) so the call site documents *why* the demotion
155
+ * is safe and each path opts into only the category that applies to it.
156
+ *
157
+ * @param tag - Low-cardinality call-site label (e.g. `'deposit'`), used as the
158
+ * Sentry breadcrumb/issue grouping key.
159
+ * @param error - The caught value, of unknown type.
160
+ * @param isBenign - `true` to demote to `warn`; `false` to keep at `error`.
161
+ * @param context - Optional structured context attached to the log entry. It is
162
+ * sanitized by the logger before transport.
163
+ */
164
+ function logChainError(tag, error, isBenign, context) {
165
+ if (isBenign) {
166
+ // Demote to a breadcrumb: the SDK's Sentry sink forwards `warn` as a
167
+ // breadcrumb, so this no longer creates its own billed issue while still
168
+ // preserving the trail if a genuine error follows.
169
+ logger_1.Logger.log.warn(tag, { message: errorText(error), ...(context ?? {}) });
170
+ return;
171
+ }
172
+ logger_1.Logger.log.error(tag, error, context);
173
+ }
174
+ //# sourceMappingURL=chain-error.js.map
@@ -18,12 +18,13 @@ export declare const filterOutBySize: (usdAmount: number) => boolean;
18
18
  export declare function toTitleCase(str: string, type?: 'camel'): string;
19
19
  export declare function truncate(s: string, amount?: number): string;
20
20
  /**
21
- * @function round formats any type number value to a standard
21
+ * Formats any numeric value (number, string, or bigint) to a standardized string.
22
22
  *
23
- * @param value amount to be formatted
24
- * @param options.showing amount of decimals to cut off at
25
- * @param options.usd if wanting to display USD value
26
- * @param options.decimals if passing type bigint, how many decimals to parse to
23
+ * @param value - amount to be formatted
24
+ * @param options - formatting options:
25
+ * `showing` is the number of decimals to cut off at (or `'all'`);
26
+ * `usd` toggles USD-value display;
27
+ * `decimals` is how many decimals to parse to when `value` is a bigint.
27
28
  *
28
29
  * @returns standardized string type value
29
30
  */
@@ -44,22 +45,24 @@ export declare function prepareDateForDb(date: string | Date): string;
44
45
  /**
45
46
  * Arrays
46
47
  */
47
- export declare function orderObjArrByDate(objectArray: any[], options?: {
48
+ export declare function orderObjArrByDate<T extends Record<string, unknown>>(objectArray: T[], options?: {
48
49
  key?: string;
49
50
  order?: 'asc' | 'desc';
50
- }): any[];
51
+ }): T[];
51
52
  /**
52
- * Calculate weights based on a specific property in array of objects
53
- * @param {Array<Object>} data - Array of objects to calculate weights for
54
- * @param {string} weightProperty - Property name to base weights on
55
- * @returns {Array<Object>} Original data with weights added
53
+ * Calculate weights based on a specific property in array of objects.
54
+ * @param data - Array of objects to calculate weights for
55
+ * @param weightProperty - Property name to base weights on
56
+ * @returns Original data with each item's `weight` added
56
57
  */
57
- export declare function calculateWeights(data?: Array<any>, weightProperty?: string): any[];
58
+ export declare function calculateWeights<T extends Record<string, unknown>>(data?: T[], weightProperty?: string): Array<T & {
59
+ weight: number;
60
+ }>;
58
61
  /**
59
- * Calculate weighted average for array of objects
60
- * @param {Array<Object>} data - Array of objects with values
61
- * @param {string} valueProperty - Property name containing the value to average
62
- * @param {string} [weightProperty] - Optional property to base weights on
63
- * @returns {number} Weighted average
62
+ * Calculate weighted average for array of objects.
63
+ * @param data - Array of objects with values
64
+ * @param valueProperty - Property name containing the value to average
65
+ * @param weightProperty - Optional property to base weights on
66
+ * @returns Weighted average
64
67
  */
65
- export declare function calculateWeightedAverage(data?: Array<any>, valueProperty?: string, weightProperty?: string): any;
68
+ export declare function calculateWeightedAverage<T extends Record<string, unknown>>(data?: T[], valueProperty?: string, weightProperty?: string): number;
@@ -67,7 +67,7 @@ function toNormalizedBn(value, decimals = 18) {
67
67
  function getFallbackRpcUrls(chainId) {
68
68
  return web3_1.FALLBACK_RPC_URLS[chainId] || [];
69
69
  }
70
- const filterOutBySize = (usdAmount) => usdAmount > 3000;
70
+ const filterOutBySize = (usdAmount) => usdAmount > 3_000;
71
71
  exports.filterOutBySize = filterOutBySize;
72
72
  /**
73
73
  * Formatters
@@ -120,12 +120,13 @@ function truncate(s, amount) {
120
120
  return `${s.slice(0, amount ? amount : 4)}...${s.slice(amount ? amount * -1 : -4)}`;
121
121
  }
122
122
  /**
123
- * @function round formats any type number value to a standard
123
+ * Formats any numeric value (number, string, or bigint) to a standardized string.
124
124
  *
125
- * @param value amount to be formatted
126
- * @param options.showing amount of decimals to cut off at
127
- * @param options.usd if wanting to display USD value
128
- * @param options.decimals if passing type bigint, how many decimals to parse to
125
+ * @param value - amount to be formatted
126
+ * @param options - formatting options:
127
+ * `showing` is the number of decimals to cut off at (or `'all'`);
128
+ * `usd` toggles USD-value display;
129
+ * `decimals` is how many decimals to parse to when `value` is a bigint.
129
130
  *
130
131
  * @returns standardized string type value
131
132
  */
@@ -133,7 +134,7 @@ function round(value, options) {
133
134
  // standardize to string
134
135
  let _value;
135
136
  if (typeof value === 'bigint') {
136
- _value = toNormalizedBn(value, options.decimals ?? web3_1.FALLBACK_DECIMALS).normalized;
137
+ _value = toNormalizedBn(value, options?.decimals ?? web3_1.FALLBACK_DECIMALS).normalized;
137
138
  }
138
139
  else {
139
140
  _value = String(value);
@@ -202,7 +203,7 @@ function loanStateToReadable(loanState) {
202
203
  */
203
204
  function dateToUnix(date) {
204
205
  if (!date)
205
- return Math.floor(new Date().getTime());
206
+ return Math.floor(Date.now());
206
207
  return Math.floor(new Date(date).getTime());
207
208
  }
208
209
  function unixToDate(epoch) {
@@ -230,19 +231,20 @@ function prepareDateForDb(date) {
230
231
  function orderObjArrByDate(objectArray, options) {
231
232
  const selectedOrder = options?.order ?? 'desc';
232
233
  const selectedKey = options?.key ?? 'date';
234
+ const toTime = (item) => new Date(item[selectedKey]).valueOf();
233
235
  return objectArray.sort((a, b) => {
234
236
  // Turn your strings into dates, and then subtract them
235
237
  // to get a value that is either negative, positive, or zero.
236
238
  if (selectedOrder === 'asc')
237
- return (new Date(a[selectedKey]).valueOf() - new Date(b[selectedKey]).valueOf());
238
- return (new Date(b[selectedKey]).valueOf() - new Date(a[selectedKey]).valueOf());
239
+ return toTime(a) - toTime(b);
240
+ return toTime(b) - toTime(a);
239
241
  });
240
242
  }
241
243
  /**
242
- * Calculate weights based on a specific property in array of objects
243
- * @param {Array<Object>} data - Array of objects to calculate weights for
244
- * @param {string} weightProperty - Property name to base weights on
245
- * @returns {Array<Object>} Original data with weights added
244
+ * Calculate weights based on a specific property in array of objects.
245
+ * @param data - Array of objects to calculate weights for
246
+ * @param weightProperty - Property name to base weights on
247
+ * @returns Original data with each item's `weight` added
246
248
  */
247
249
  function calculateWeights(data, weightProperty) {
248
250
  if (!data || data.length === 0 || !weightProperty)
@@ -256,16 +258,16 @@ function calculateWeights(data, weightProperty) {
256
258
  }));
257
259
  }
258
260
  /**
259
- * Calculate weighted average for array of objects
260
- * @param {Array<Object>} data - Array of objects with values
261
- * @param {string} valueProperty - Property name containing the value to average
262
- * @param {string} [weightProperty] - Optional property to base weights on
263
- * @returns {number} Weighted average
261
+ * Calculate weighted average for array of objects.
262
+ * @param data - Array of objects with values
263
+ * @param valueProperty - Property name containing the value to average
264
+ * @param weightProperty - Optional property to base weights on
265
+ * @returns Weighted average
264
266
  */
265
267
  function calculateWeightedAverage(data, valueProperty, weightProperty) {
266
268
  if (!data || data.length === 0 || !valueProperty)
267
269
  return 0;
268
- let weightedData = data;
270
+ let weightedData;
269
271
  // If no weightProperty specified, use equal weights
270
272
  if (!weightProperty) {
271
273
  weightedData = data.map((item) => ({
@@ -1,4 +1,4 @@
1
- import { IAddress, IChainId, IExplorerType } from '../../types';
1
+ import type { IAddress, IChainId, IExplorerType } from '../../types';
2
2
  /**
3
3
  * Generate a block-explorer URL for an address or transaction hash.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { Signer, Wallet } from 'ethers';
1
+ import { type Signer, type Wallet } from 'ethers';
2
2
  /**
3
3
  * Signer Compatibility Helpers
4
4
  *
@@ -1,4 +1,4 @@
1
- import { IAddress } from '../../types';
1
+ import type { IAddress } from '../../types';
2
2
  /**
3
3
  * Resolve the `SwapRouter` address for a chain.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { ITokenizedVault, IVaultVersion, ChainType } from '../../types';
1
+ import type { ITokenizedVault, IVaultVersion, ChainType } from '../../types';
2
2
  /** Classify an address by chain family (evm / solana / stellar / sui). */
3
3
  export declare function getAddressChainType(address: string): ChainType;
4
4
  export declare function getVaultVersion(vault: string): IVaultVersion | undefined;
@@ -1,4 +1,4 @@
1
- import { IAddress, IContractRunner } from '../../types';
1
+ import type { IAddress, IContractRunner } from '../../types';
2
2
  /**
3
3
  * Bad transactions that should be ignored
4
4
  * these transactions are usually from tests and can skew data
@@ -1,7 +1,7 @@
1
- import { ethers, Interface, InterfaceAbi, JsonRpcProvider } from 'ethers';
1
+ import { ethers, Interface, type InterfaceAbi, JsonRpcProvider } from 'ethers';
2
2
  import type { Abi } from 'abitype';
3
3
  import type { TypedContract } from '../../types/typed-contract';
4
- import { IAddress, IContractRunner, IInfuraOptions } from '../../types';
4
+ import type { IAddress, IContractRunner, IInfuraOptions } from '../../types';
5
5
  /**
6
6
  * Web3 Helper Utilities
7
7
  *
@@ -41,13 +41,13 @@ const vault_version_1 = require("./vault-version");
41
41
  const determineBlockCutoff = (chain) => {
42
42
  switch (chain) {
43
43
  case 56:
44
- return 120000;
44
+ return 120_000;
45
45
  case 43114:
46
- return 120000;
46
+ return 120_000;
47
47
  case 143:
48
- return 3456000;
48
+ return 3_456_000;
49
49
  default:
50
- return 150000;
50
+ return 150_000;
51
51
  }
52
52
  };
53
53
  exports.determineBlockCutoff = determineBlockCutoff;
@@ -78,15 +78,15 @@ exports.determineSecondsPerBlock = determineSecondsPerBlock;
78
78
  const determineBlockSkipInternal = (chain) => {
79
79
  switch (chain) {
80
80
  case 43114:
81
- return 8000;
81
+ return 8_000;
82
82
  case 56:
83
- return 8000;
83
+ return 8_000;
84
84
  case 143: // Monad — Alchemy limits eth_getLogs to 1000 blocks
85
- return 1000;
85
+ return 1_000;
86
86
  case 999: // HyperEVM — rpc.hypurrscan.io limits eth_getLogs to 1000 blocks
87
- return 1000;
87
+ return 1_000;
88
88
  default:
89
- return 50000;
89
+ return 50_000;
90
90
  }
91
91
  };
92
92
  exports.determineBlockSkipInternal = determineBlockSkipInternal;
@@ -12,6 +12,7 @@ export * from './constants/vaults';
12
12
  export * from './constants/swap-router';
13
13
  export * from './helpers/web3';
14
14
  export * from './helpers/vaults';
15
+ export * from './helpers/chain-error';
15
16
  export * from './helpers/core';
16
17
  export * from './helpers/adapters';
17
18
  export * from './helpers/signer';
package/lib/core/index.js CHANGED
@@ -28,6 +28,7 @@ __exportStar(require("./constants/vaults"), exports);
28
28
  __exportStar(require("./constants/swap-router"), exports);
29
29
  __exportStar(require("./helpers/web3"), exports);
30
30
  __exportStar(require("./helpers/vaults"), exports);
31
+ __exportStar(require("./helpers/chain-error"), exports);
31
32
  __exportStar(require("./helpers/core"), exports);
32
33
  __exportStar(require("./helpers/adapters"), exports);
33
34
  __exportStar(require("./helpers/signer"), exports);
@@ -1,4 +1,4 @@
1
- import { IVaultMetadata } from '../types';
1
+ import type { IVaultMetadata } from '../types';
2
2
  /**
3
3
  * Fetch vault metadata from the upshift API.
4
4
  * Returns metadata including symbol, subgraph URL, and address for all vaults.
@@ -30,7 +30,7 @@ let hasRunCheck = false;
30
30
  const NPM_PACKAGE = '@augustdigital/sdk';
31
31
  const REGISTRY_URL = `https://registry.npmjs.org/${NPM_PACKAGE}/latest`;
32
32
  /** Timeout for the registry request. 5s is generous; faster failures stay silent. */
33
- const REQUEST_TIMEOUT_MS = 5000;
33
+ const REQUEST_TIMEOUT_MS = 5_000;
34
34
  /**
35
35
  * Read the current installed SDK version from the generated `version.ts`
36
36
  * shim. Returns `null` when running from source (the file is gitignored and
@@ -90,7 +90,7 @@ const DEFAULT_HUB_LZ_COMPOSE_GAS_LIMIT = 2000000n;
90
90
  // serialize patched calls. The timeout THROWS rather than silently racing
91
91
  // concurrent callers' patches.
92
92
  // ---------------------------------------------------------------------------
93
- const PATCH_LOCK_TIMEOUT_MS = 30000;
93
+ const PATCH_LOCK_TIMEOUT_MS = 30_000;
94
94
  let patchLock = Promise.resolve();
95
95
  // ---------------------------------------------------------------------------
96
96
  // Internal helpers
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CROSS_CHAIN_QUOTE_TTL_MS = void 0;
13
13
  exports.isQuoteStale = isQuoteStale;
14
14
  /** Default validity window for a cross-chain quote (30s). */
15
- exports.CROSS_CHAIN_QUOTE_TTL_MS = 30000;
15
+ exports.CROSS_CHAIN_QUOTE_TTL_MS = 30_000;
16
16
  /** Returns `true` when the quote should be refreshed before submitting. */
17
17
  function isQuoteStale(quote, now = Date.now()) {
18
18
  return now >= quote.expiresAt;
package/lib/main.d.ts CHANGED
@@ -69,7 +69,7 @@ export declare class AugustSDK extends AugustBase {
69
69
  * @param symbol - Token symbol or contract address
70
70
  * @returns Current price in USD
71
71
  */
72
- getPrice(symbol: string): Promise<any>;
72
+ getPrice(symbol: string): Promise<number>;
73
73
  /**
74
74
  * Vault Data and Operations
75
75
  */
package/lib/main.js CHANGED
@@ -56,6 +56,13 @@ const api_1 = require("./modules/api");
56
56
  * Provides unified access to EVM, Solana, Sui, and Stellar blockchain adapters.
57
57
  */
58
58
  class AugustSDK extends core_1.AugustBase {
59
+ vaults;
60
+ subaccounts;
61
+ api;
62
+ solana;
63
+ sui;
64
+ stellar;
65
+ evm;
59
66
  /**
60
67
  * Initialize the August SDK with provider configuration.
61
68
  * Automatically sets up EVM adapter and optionally initializes Solana if RPC URL is provided.
@@ -1,5 +1,5 @@
1
- import { IFetchAugustOptions } from '../../core';
2
- import { IAddress, IOTCPosition, IWSSubaccountCefi, IWSSubAccountHealthFactor, IWSSubaccountLoan, IWSSubaccountSummary } from '../../types';
1
+ import { type IFetchAugustOptions } from '../../core';
2
+ import type { IAddress, IOTCPosition, IWSSubaccountCefi, IWSSubAccountHealthFactor, IWSSubaccountLoan, IWSSubaccountSummary } from '../../types';
3
3
  /**
4
4
  * Fetch subaccount health factor for a given subaccount address
5
5
  */
@@ -1,5 +1,5 @@
1
- import { AugustBase, IAugustBase } from '../../core';
2
- import { IAddress } from '../../types';
1
+ import { AugustBase, type IAugustBase } from '../../core';
2
+ import type { IAddress } from '../../types';
3
3
  /**
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.
@@ -16,9 +16,9 @@ const core_1 = require("../../core");
16
16
  * Most of the operations require a August API key to perform
17
17
  */
18
18
  class AugustSubAccounts extends core_1.AugustBase {
19
+ headers = null;
19
20
  constructor(baseConfig) {
20
21
  super(baseConfig);
21
- this.headers = null;
22
22
  this.headers = {
23
23
  'x-environment': this.monitoring?.['x-environment'],
24
24
  'x-user-id': this.monitoring?.['x-user-id'],
@@ -1,4 +1,4 @@
1
- import { IWSSubaccountSummary } from '../../types';
1
+ import type { IWSSubaccountSummary } from '../../types';
2
2
  /**
3
3
  * Transform the raw API response to camelCase
4
4
  */
@@ -4,9 +4,9 @@
4
4
  * Functions to support deposits with alternative tokens through swap adapters,
5
5
  * wrapper contracts, and Paraswap integration.
6
6
  */
7
- import { BaseContract, Signer, Wallet } from 'ethers';
8
- import { IAddress } from '../../types';
9
- import { IVaultAdapterConfig } from '../../types/vaults';
7
+ import type { BaseContract, Signer, Wallet } from 'ethers';
8
+ import type { IAddress } from '../../types';
9
+ import type { IVaultAdapterConfig } from '../../types/vaults';
10
10
  /**
11
11
  * Get quote from Paraswap for token swap
12
12
  */
@@ -1,3 +1,28 @@
1
+ import type { IAddress } from '../../types';
2
+ /**
3
+ * Fetch the set of vaults whose deposit/withdraw history is served from the
4
+ * backend Mongo snapshot (`/upshift/vault_history`) rather than their (retired)
5
+ * Goldsky subgraph.
6
+ *
7
+ * This is the routing source of truth: a vault appears here only once its
8
+ * history has been backfilled, so the SDK can never reroute a vault to empty
9
+ * snapshot data ahead of its backfill. Result is cached for 10 minutes.
10
+ *
11
+ * Side effects: one HTTP GET to the public API (cached).
12
+ *
13
+ * @returns A set of lowercased vault addresses. Empty on any error — callers
14
+ * then fall back to the subgraph path, which is the safe default while
15
+ * subgraphs still exist.
16
+ */
17
+ export declare function fetchArchivedVaults(): Promise<Set<string>>;
18
+ /**
19
+ * Whether a vault's history should be served from the backend snapshot rather
20
+ * than its subgraph. Backed by {@link fetchArchivedVaults} (cached).
21
+ *
22
+ * @param vaultAddress - The vault contract address (any casing).
23
+ * @returns `true` if the vault has a backfilled history snapshot.
24
+ */
25
+ export declare function isArchivedVault(vaultAddress: IAddress): Promise<boolean>;
1
26
  /**
2
27
  * Specialized vault fetching with enhanced retry logic and fallback strategies
3
28
  * This function attempts to fetch vault data with multiple fallback approaches
@@ -1,11 +1,61 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchVaultMetadata = void 0;
4
+ exports.fetchArchivedVaults = fetchArchivedVaults;
5
+ exports.isArchivedVault = isArchivedVault;
4
6
  exports.fetchVaultWithFallback = fetchVaultWithFallback;
5
7
  exports.fetchVaultsBatch = fetchVaultsBatch;
6
8
  exports.fetchVaultsComprehensive = fetchVaultsComprehensive;
7
9
  exports.filterVaultsIntelligently = filterVaultsIntelligently;
8
10
  const core_1 = require("../../core");
11
+ const ARCHIVED_VAULTS_CACHE_KEY = 'archived_vaults';
12
+ const ARCHIVED_VAULTS_TTL_MS = 10 * 60 * 1000;
13
+ /**
14
+ * Fetch the set of vaults whose deposit/withdraw history is served from the
15
+ * backend Mongo snapshot (`/upshift/vault_history`) rather than their (retired)
16
+ * Goldsky subgraph.
17
+ *
18
+ * This is the routing source of truth: a vault appears here only once its
19
+ * history has been backfilled, so the SDK can never reroute a vault to empty
20
+ * snapshot data ahead of its backfill. Result is cached for 10 minutes.
21
+ *
22
+ * Side effects: one HTTP GET to the public API (cached).
23
+ *
24
+ * @returns A set of lowercased vault addresses. Empty on any error — callers
25
+ * then fall back to the subgraph path, which is the safe default while
26
+ * subgraphs still exist.
27
+ */
28
+ async function fetchArchivedVaults() {
29
+ const cached = core_1.CACHE.get(ARCHIVED_VAULTS_CACHE_KEY);
30
+ if (cached)
31
+ return cached;
32
+ try {
33
+ const response = await (0, core_1.fetchAugustPublic)(core_1.WEBSERVER_ENDPOINTS.public.tokenizedVault.archivedVaults);
34
+ if (response.status !== 200) {
35
+ core_1.Logger.log.error('fetchArchivedVaults', `non-200 from archived endpoint: ${response.status}`);
36
+ return new Set();
37
+ }
38
+ const addresses = (await response.json());
39
+ const set = new Set(addresses.map((a) => a.toLowerCase()));
40
+ core_1.CACHE.set(ARCHIVED_VAULTS_CACHE_KEY, set, { ttl: ARCHIVED_VAULTS_TTL_MS });
41
+ return set;
42
+ }
43
+ catch (e) {
44
+ core_1.Logger.log.error('fetchArchivedVaults', e);
45
+ return new Set();
46
+ }
47
+ }
48
+ /**
49
+ * Whether a vault's history should be served from the backend snapshot rather
50
+ * than its subgraph. Backed by {@link fetchArchivedVaults} (cached).
51
+ *
52
+ * @param vaultAddress - The vault contract address (any casing).
53
+ * @returns `true` if the vault has a backfilled history snapshot.
54
+ */
55
+ async function isArchivedVault(vaultAddress) {
56
+ const archived = await fetchArchivedVaults();
57
+ return archived.has(vaultAddress.toLowerCase());
58
+ }
9
59
  /** @internal */
10
60
  async function runWithConcurrency(tasks, limit) {
11
61
  if (!Number.isFinite(limit) || limit <= 0) {
@@ -151,7 +201,7 @@ async function fetchVaultsComprehensive(vaults, fetchFn, options = {}) {
151
201
  catch (error) {
152
202
  lastError = error;
153
203
  if (attempts < maxRetries) {
154
- const delay = baseDelay * Math.pow(2, attempts - 1);
204
+ const delay = baseDelay * 2 ** (attempts - 1);
155
205
  core_1.Logger.log.warn('fetchVaultsComprehensive', `Vault ${vault.address} attempt ${attempts} failed, retrying in ${delay}ms: ${error.message}`);
156
206
  await new Promise((resolve) => setTimeout(resolve, delay));
157
207
  }