@augustdigital/sdk 8.3.2 → 8.5.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.
Files changed (204) hide show
  1. package/lib/abis/ERC20_Bytes32.d.ts +4 -0
  2. package/lib/abis/ERC20_Bytes32.js +4 -0
  3. package/lib/abis/ERC4626.d.ts +1 -0
  4. package/lib/abis/ERC4626.js +1 -0
  5. package/lib/abis/ERC721.d.ts +1 -0
  6. package/lib/abis/ERC721.js +1 -0
  7. package/lib/abis/FeeOracle.js +1 -0
  8. package/lib/abis/LendingPool.js +1 -0
  9. package/lib/abis/LendingPoolV2.js +1 -0
  10. package/lib/abis/Multicall3.js +3 -0
  11. package/lib/abis/OFT.d.ts +20 -0
  12. package/lib/abis/OFT.js +20 -0
  13. package/lib/abis/SmartAccount.d.ts +1 -0
  14. package/lib/abis/SmartAccount.js +3 -0
  15. package/lib/abis/SwapRouter.d.ts +1 -0
  16. package/lib/abis/SwapRouter.js +1 -0
  17. package/lib/abis/UniversalSignatureValidator.js +3 -0
  18. package/lib/abis/index.d.ts +5 -0
  19. package/lib/abis/index.js +5 -0
  20. package/lib/adapters/evm/getters.d.ts +17 -2
  21. package/lib/adapters/evm/getters.js +35 -3
  22. package/lib/adapters/evm/index.d.ts +262 -0
  23. package/lib/adapters/evm/index.js +268 -1
  24. package/lib/adapters/evm/utils.d.ts +6 -0
  25. package/lib/adapters/evm/utils.js +7 -0
  26. package/lib/adapters/solana/constants.js +4 -1
  27. package/lib/adapters/solana/getters.d.ts +8 -0
  28. package/lib/adapters/solana/getters.js +21 -0
  29. package/lib/adapters/solana/idl/vault-idl.js +9 -0
  30. package/lib/adapters/solana/index.d.ts +55 -0
  31. package/lib/adapters/solana/index.js +57 -0
  32. package/lib/adapters/solana/utils.d.ts +28 -0
  33. package/lib/adapters/solana/utils.js +79 -4
  34. package/lib/adapters/solana/vault.actions.d.ts +19 -0
  35. package/lib/adapters/solana/vault.actions.js +47 -3
  36. package/lib/adapters/stellar/actions.d.ts +25 -0
  37. package/lib/adapters/stellar/actions.js +33 -0
  38. package/lib/adapters/stellar/constants.d.ts +26 -0
  39. package/lib/adapters/stellar/constants.js +29 -0
  40. package/lib/adapters/stellar/getters.d.ts +56 -0
  41. package/lib/adapters/stellar/getters.js +81 -0
  42. package/lib/adapters/stellar/index.d.ts +48 -0
  43. package/lib/adapters/stellar/index.js +48 -0
  44. package/lib/adapters/stellar/soroban.d.ts +20 -0
  45. package/lib/adapters/stellar/soroban.js +46 -0
  46. package/lib/adapters/stellar/submit.d.ts +12 -0
  47. package/lib/adapters/stellar/submit.js +19 -0
  48. package/lib/adapters/stellar/types.d.ts +27 -0
  49. package/lib/adapters/stellar/types.js +3 -0
  50. package/lib/adapters/stellar/utils.d.ts +10 -0
  51. package/lib/adapters/stellar/utils.js +10 -0
  52. package/lib/adapters/sui/getters.d.ts +6 -0
  53. package/lib/adapters/sui/getters.js +6 -0
  54. package/lib/adapters/sui/index.d.ts +15 -0
  55. package/lib/adapters/sui/index.js +15 -0
  56. package/lib/adapters/sui/transformer.d.ts +6 -0
  57. package/lib/adapters/sui/transformer.js +6 -0
  58. package/lib/adapters/sui/utils.d.ts +6 -0
  59. package/lib/adapters/sui/utils.js +6 -0
  60. package/lib/core/analytics/chain-name.d.ts +8 -0
  61. package/lib/core/analytics/chain-name.js +8 -0
  62. package/lib/core/analytics/constants.d.ts +4 -0
  63. package/lib/core/analytics/constants.js +4 -0
  64. package/lib/core/analytics/env.d.ts +25 -0
  65. package/lib/core/analytics/env.js +26 -0
  66. package/lib/core/analytics/index.d.ts +26 -0
  67. package/lib/core/analytics/index.js +35 -0
  68. package/lib/core/analytics/instrumentation.d.ts +26 -0
  69. package/lib/core/analytics/instrumentation.js +66 -2
  70. package/lib/core/analytics/method-taxonomy.d.ts +16 -0
  71. package/lib/core/analytics/method-taxonomy.js +18 -0
  72. package/lib/core/analytics/metrics.d.ts +23 -0
  73. package/lib/core/analytics/metrics.js +40 -0
  74. package/lib/core/analytics/sanitize.d.ts +38 -0
  75. package/lib/core/analytics/sanitize.js +46 -0
  76. package/lib/core/analytics/sentry-runtime.d.ts +11 -0
  77. package/lib/core/analytics/sentry-runtime.js +19 -0
  78. package/lib/core/analytics/sentry.d.ts +45 -0
  79. package/lib/core/analytics/sentry.js +115 -2
  80. package/lib/core/analytics/types.d.ts +27 -0
  81. package/lib/core/analytics/user-identity.d.ts +34 -0
  82. package/lib/core/analytics/user-identity.js +42 -0
  83. package/lib/core/analytics/version.d.ts +6 -1
  84. package/lib/core/analytics/version.js +6 -1
  85. package/lib/core/auth/verify.js +5 -0
  86. package/lib/core/base.class.d.ts +75 -0
  87. package/lib/core/base.class.js +56 -0
  88. package/lib/core/cache.d.ts +5 -0
  89. package/lib/core/cache.js +6 -0
  90. package/lib/core/constants/adapters.d.ts +15 -0
  91. package/lib/core/constants/adapters.js +28 -8
  92. package/lib/core/constants/core.d.ts +12 -1
  93. package/lib/core/constants/core.js +12 -0
  94. package/lib/core/constants/swap-router.d.ts +46 -0
  95. package/lib/core/constants/swap-router.js +50 -0
  96. package/lib/core/constants/vaults.d.ts +56 -0
  97. package/lib/core/constants/vaults.js +66 -1
  98. package/lib/core/constants/web3.d.ts +3 -0
  99. package/lib/core/constants/web3.js +18 -5
  100. package/lib/core/errors/index.d.ts +36 -0
  101. package/lib/core/errors/index.js +29 -0
  102. package/lib/core/fetcher.d.ts +134 -0
  103. package/lib/core/fetcher.js +191 -5
  104. package/lib/core/helpers/adapters.d.ts +9 -0
  105. package/lib/core/helpers/adapters.js +11 -0
  106. package/lib/core/helpers/chain-address.d.ts +10 -0
  107. package/lib/core/helpers/chain-address.js +11 -0
  108. package/lib/core/helpers/core.d.ts +42 -0
  109. package/lib/core/helpers/core.js +66 -1
  110. package/lib/core/helpers/explorer-link.d.ts +14 -0
  111. package/lib/core/helpers/explorer-link.js +14 -0
  112. package/lib/core/helpers/signer.d.ts +26 -0
  113. package/lib/core/helpers/signer.js +39 -0
  114. package/lib/core/helpers/swap-router.d.ts +32 -0
  115. package/lib/core/helpers/swap-router.js +32 -0
  116. package/lib/core/helpers/vault-version.d.ts +1 -0
  117. package/lib/core/helpers/vault-version.js +2 -0
  118. package/lib/core/helpers/vaults.d.ts +8 -0
  119. package/lib/core/helpers/vaults.js +22 -8
  120. package/lib/core/helpers/web3.d.ts +152 -0
  121. package/lib/core/helpers/web3.js +183 -6
  122. package/lib/core/logger/index.d.ts +55 -0
  123. package/lib/core/logger/index.js +19 -0
  124. package/lib/core/logger/slack.d.ts +3 -0
  125. package/lib/core/logger/slack.js +3 -0
  126. package/lib/core/vault-metadata.d.ts +6 -0
  127. package/lib/core/vault-metadata.js +6 -0
  128. package/lib/core/version-check.d.ts +52 -0
  129. package/lib/core/version-check.js +81 -0
  130. package/lib/evm/methods/crossChainVault.d.ts +90 -0
  131. package/lib/evm/methods/crossChainVault.js +186 -1
  132. package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
  133. package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
  134. package/lib/evm/methods/index.d.ts +1 -0
  135. package/lib/evm/methods/index.js +1 -0
  136. package/lib/evm/types/crossChain.d.ts +202 -0
  137. package/lib/evm/types/crossChain.js +11 -0
  138. package/lib/index.d.ts +16 -0
  139. package/lib/index.js +19 -0
  140. package/lib/main.d.ts +288 -5
  141. package/lib/main.js +305 -0
  142. package/lib/modules/api/index.d.ts +1 -0
  143. package/lib/modules/api/index.js +6 -0
  144. package/lib/modules/api/main.d.ts +52 -0
  145. package/lib/modules/api/main.js +130 -0
  146. package/lib/modules/sub-accounts/fetcher.d.ts +15 -0
  147. package/lib/modules/sub-accounts/fetcher.js +15 -0
  148. package/lib/modules/sub-accounts/main.d.ts +33 -0
  149. package/lib/modules/sub-accounts/main.js +38 -0
  150. package/lib/modules/sub-accounts/utils.d.ts +3 -0
  151. package/lib/modules/sub-accounts/utils.js +3 -0
  152. package/lib/modules/vaults/adapter.helpers.d.ts +18 -0
  153. package/lib/modules/vaults/adapter.helpers.js +34 -0
  154. package/lib/modules/vaults/fetcher.d.ts +20 -0
  155. package/lib/modules/vaults/fetcher.js +40 -3
  156. package/lib/modules/vaults/getters.d.ts +295 -0
  157. package/lib/modules/vaults/getters.js +552 -12
  158. package/lib/modules/vaults/index.d.ts +12 -0
  159. package/lib/modules/vaults/index.js +12 -0
  160. package/lib/modules/vaults/main.d.ts +292 -4
  161. package/lib/modules/vaults/main.js +379 -7
  162. package/lib/modules/vaults/read.actions.d.ts +168 -0
  163. package/lib/modules/vaults/read.actions.js +143 -0
  164. package/lib/modules/vaults/types.d.ts +34 -0
  165. package/lib/modules/vaults/utils/call-data-decoder.d.ts +47 -0
  166. package/lib/modules/vaults/utils/call-data-decoder.js +56 -0
  167. package/lib/modules/vaults/utils/date-utils.d.ts +39 -0
  168. package/lib/modules/vaults/utils/date-utils.js +47 -1
  169. package/lib/modules/vaults/utils.d.ts +69 -0
  170. package/lib/modules/vaults/utils.js +104 -5
  171. package/lib/modules/vaults/write.actions.d.ts +363 -3
  172. package/lib/modules/vaults/write.actions.js +364 -2
  173. package/lib/polyfills.js +2 -0
  174. package/lib/sdk.d.ts +23705 -0
  175. package/lib/services/coingecko/fetcher.d.ts +13 -0
  176. package/lib/services/coingecko/fetcher.js +17 -0
  177. package/lib/services/debank/fetcher.d.ts +14 -0
  178. package/lib/services/debank/fetcher.js +12 -0
  179. package/lib/services/debank/utils.js +17 -0
  180. package/lib/services/layerzero/deposits.d.ts +11 -0
  181. package/lib/services/layerzero/deposits.js +34 -11
  182. package/lib/services/layerzero/redeems.d.ts +10 -0
  183. package/lib/services/layerzero/redeems.js +13 -0
  184. package/lib/services/layerzero/utils.d.ts +8 -0
  185. package/lib/services/layerzero/utils.js +11 -0
  186. package/lib/services/octavfi/fetcher.d.ts +7 -0
  187. package/lib/services/octavfi/fetcher.js +25 -0
  188. package/lib/services/octavfi/utils.d.ts +12 -0
  189. package/lib/services/octavfi/utils.js +44 -10
  190. package/lib/services/subgraph/fetcher.js +4 -2
  191. package/lib/services/subgraph/vaults.d.ts +12 -0
  192. package/lib/services/subgraph/vaults.js +43 -2
  193. package/lib/services/swap-quotes/index.d.ts +71 -0
  194. package/lib/services/swap-quotes/index.js +25 -0
  195. package/lib/services/swap-quotes/paraswap.d.ts +17 -0
  196. package/lib/services/swap-quotes/paraswap.js +14 -0
  197. package/lib/types/pools.d.ts +3 -0
  198. package/lib/types/typed-contract.d.ts +64 -0
  199. package/lib/types/vaults.d.ts +137 -2
  200. package/lib/types/vaults.js +10 -0
  201. package/lib/types/web3.d.ts +8 -0
  202. package/lib/types/web3.js +1 -0
  203. package/lib/types/webserver.d.ts +45 -0
  204. package/package.json +6 -5
@@ -1,29 +1,163 @@
1
1
  import type { IAddress, IContractRunner, IHistoricalTimeseriesResponse, ITokenizedVault, IWSMonitorHeaders, IWSVaultLoan, VaultAddress } from '../types';
2
2
  import { WEBSERVER_URL } from './constants/core';
3
+ /**
4
+ * API Fetching and Data Utilities
5
+ *
6
+ * Core fetching functions for August backend services:
7
+ * - Authentication: fetchAugustWithKey, fetchAugustWithBearer, fetchAugustPublic
8
+ * - Retry Logic: withRetry, isRetryableError, promiseSettle
9
+ * - Vault Data: fetchTokenizedVaults, fetchTokenizedVaultLoans
10
+ * - Pricing: fetchTokenPrice (with CoinGecko fallback)
11
+ * - Caching: LRU cache for API responses
12
+ */
3
13
  export type IFetchAugustMethods = 'get' | 'post' | 'put';
4
14
  export type IFetchAugustOptions = {
5
15
  method?: IFetchAugustMethods;
6
16
  headers?: Record<string, string>;
7
17
  data?: any;
8
18
  server?: keyof typeof WEBSERVER_URL;
19
+ /** Caller-supplied AbortSignal; combined with the default timeout. */
9
20
  signal?: AbortSignal;
21
+ /** Per-request timeout in ms. Defaults to `REQUEST_TIMEOUT_MS`. */
10
22
  timeoutMs?: number;
23
+ /**
24
+ * @deprecated Bypasses the API-key check for legacy unauthenticated endpoints.
25
+ * Will be removed in a future major version; pass a valid `apiKey` instead.
26
+ */
11
27
  override?: boolean;
12
28
  };
29
+ /**
30
+ * Override the default request timeout used by every August fetcher helper
31
+ * when the caller doesn't supply a per-call `timeoutMs`. Pass `null` (or
32
+ * call with no arguments) to clear the override and fall back to the
33
+ * compiled-in `REQUEST_TIMEOUT_MS`.
34
+ *
35
+ * @param ms Positive number of milliseconds to wait before aborting, or
36
+ * `null` to clear.
37
+ */
13
38
  export declare function setSdkRequestTimeout(ms?: number | null): void;
39
+ /**
40
+ * Read the active default request timeout — the SDK-level override if set,
41
+ * otherwise the compiled-in `REQUEST_TIMEOUT_MS`.
42
+ */
14
43
  export declare function getSdkRequestTimeout(): number;
15
44
  import { CACHE, getSafeCache, setSafeCache } from './cache';
16
45
  export { CACHE, getSafeCache, setSafeCache };
46
+ /**
47
+ * Make authenticated requests to August backend services using API key.
48
+ * Automatically logs errors with correlation IDs for debugging.
49
+ * @param apiKey August API key for authentication
50
+ * @param relativeUrl Endpoint path relative to base URL
51
+ * @param options Request configuration including method and headers
52
+ * @returns Response object if successful
53
+ * @throws Error with correlation ID if request fails
54
+ */
17
55
  export declare function fetchAugustWithKey(apiKey: string, relativeUrl: string, options?: IFetchAugustOptions): Promise<Response>;
56
+ /**
57
+ * Make unauthenticated requests to August public API endpoints.
58
+ * Used for fetching vault metadata and public market data.
59
+ * @param relativeUrl Endpoint path relative to public API base URL
60
+ * @param options Request configuration including method and headers
61
+ * @returns Response object if successful
62
+ * @throws Error with correlation ID if request fails
63
+ */
18
64
  export declare function fetchAugustPublic(relativeUrl: string, options?: IFetchAugustOptions): Promise<Response>;
65
+ /**
66
+ * Make authenticated requests using Bearer token authentication.
67
+ * Typically used for user-specific operations requiring OAuth tokens.
68
+ * @param bearerToken OAuth bearer token
69
+ * @param relativeUrl Endpoint path relative to base URL
70
+ * @param options Request configuration including method and headers
71
+ * @returns Response object if successful
72
+ * @throws Error with correlation ID if request fails
73
+ */
19
74
  export declare function fetchAugustWithBearer(bearerToken: string, relativeUrl: string, options?: IFetchAugustOptions): Promise<Response>;
75
+ /**
76
+ * Check if an error is network-related and suitable for retry.
77
+ * Identifies timeouts, connection resets, and fetch failures.
78
+ */
20
79
  export declare function isRetryableError(error: Error): boolean;
80
+ /**
81
+ * Wrap async operations with exponential backoff retry logic.
82
+ * Retries on network errors with increasing delays between attempts.
83
+ * @param fn Async function to execute with retry logic
84
+ * @param maxRetries Maximum number of retry attempts
85
+ * @param baseDelay Initial delay in milliseconds (doubles each retry)
86
+ * @param shouldRetry Custom function to determine if error is retryable
87
+ * @returns Result of successful function execution
88
+ * @throws Last error if all retries exhausted
89
+ */
21
90
  export declare function withRetry<T>(fn: () => Promise<T>, maxRetries?: number, baseDelay?: number, shouldRetry?: (error: Error) => boolean): Promise<T>;
91
+ /**
92
+ * Fetch tokenized vault configurations from backend API.
93
+ * Results are cached to reduce API calls. Optionally filter by specific vault address.
94
+ * @param pool Optional vault address to filter results
95
+ * @param headers Monitoring headers for request tracking
96
+ * @returns Array of tokenized vault configurations
97
+ */
22
98
  export declare function fetchTokenizedVault(pool: VaultAddress, headers?: IWSMonitorHeaders, loadSubaccounts?: boolean, loadSnapshots?: boolean): Promise<ITokenizedVault[]>;
99
+ /**
100
+ * Fetch tokenized vault configurations from backend API.
101
+ * Results are cached to reduce API calls. Optionally filter by specific vault address.
102
+ * @param pool Optional vault address to filter results
103
+ * @param headers Monitoring headers for request tracking
104
+ * @param loadSubaccounts Optional flag to load subaccounts and EOA operators (defaults to true on API)
105
+ * @returns Array of tokenized vault configurations
106
+ */
23
107
  export declare function fetchTokenizedVaults(pool?: IAddress, headers?: IWSMonitorHeaders, loadSubaccounts?: boolean, loadSnapshots?: boolean): Promise<ITokenizedVault[]>;
108
+ /**
109
+ * Fetch current USD price for a token symbol or vault LP token.
110
+ * For vault LP tokens, calculates share price using totalAssets/totalSupply ratio.
111
+ * Falls back to CoinGecko if primary source fails.
112
+ * @param symbol Token symbol or contract address
113
+ * @param provider Optional web3 provider for on-chain price calculations
114
+ * @param coinGeckoKey Optional CoinGecko API key for fallback pricing
115
+ * @param headers Monitoring headers for request tracking
116
+ * @returns Token price in USD
117
+ */
24
118
  export declare function fetchTokenPrice(symbol: string, provider?: IContractRunner, coinGeckoKey?: string, headers?: IWSMonitorHeaders): Promise<any>;
119
+ /**
120
+ * Fetch token price by contract address and chain ID from August price server.
121
+ * @param address Token contract address
122
+ * @param chainId Network chain ID
123
+ * @param headers Optional monitoring headers for request tracking
124
+ * @returns Token price in USD, or 0 if not found
125
+ */
25
126
  export declare function fetchTokenPriceByAddress(address: VaultAddress, chainId: number, headers?: IWSMonitorHeaders): Promise<number>;
127
+ /**
128
+ * Fetch active loans for a specific vault from backend API.
129
+ * Results are cached per vault and chain to reduce API calls.
130
+ * @param pool Vault address
131
+ * @param chainId Network chain ID
132
+ * @param headers Monitoring headers for request tracking
133
+ * @returns Array of active loan objects
134
+ */
26
135
  export declare function fetchTokenizedVaultLoans(pool: VaultAddress, chainId: number, headers?: IWSMonitorHeaders): Promise<IWSVaultLoan[]>;
136
+ /**
137
+ * Fetch subaccount loans for a specific tokenized vault (lending pool).
138
+ * Retrieves all active subaccount loan data from the backend.
139
+ * @param pool Vault address
140
+ * @param chainId Network chain ID
141
+ * @param headers Monitoring headers for request tracking
142
+ * @returns Array of active subaccount loan objects
143
+ */
27
144
  export declare function fetchTokenizedVaultSubaccountLoans(pool: VaultAddress, chainId: number, headers?: IWSMonitorHeaders): Promise<IWSVaultLoan[]>;
145
+ /**
146
+ * Fetch historical timeseries data for a specific vault.
147
+ * Returns TVL, APY, PnL, and share price data over time.
148
+ * @param vaultAddress Vault contract address
149
+ * @param nDays Number of days of historical data to fetch (default 30, min 1)
150
+ * @param headers Monitoring headers for request tracking
151
+ * @returns Historical timeseries data with date keys
152
+ */
28
153
  export declare function fetchVaultHistoricalTimeseries(vaultAddress: IAddress, nDays?: number, headers?: IWSMonitorHeaders): Promise<IHistoricalTimeseriesResponse>;
154
+ /**
155
+ * Execute multiple promises with retry logic and allow partial failures.
156
+ * Unlike Promise.all, continues execution if some promises fail.
157
+ * Failed promises return null to maintain array index alignment.
158
+ * @param promises Array of promises to execute
159
+ * @param maxRetries Maximum retry attempts per promise
160
+ * @param baseDelay Initial delay for exponential backoff
161
+ * @returns Array of results with null for failed promises
162
+ */
29
163
  export declare function promiseSettle<T>(promises: Promise<T>[], maxRetries?: number, baseDelay?: number): Promise<T[]>;
@@ -30,6 +30,7 @@ const vault_version_1 = require("./helpers/vault-version");
30
30
  const analytics_1 = require("./analytics");
31
31
  const sanitize_1 = require("./analytics/sanitize");
32
32
  const errors_1 = require("./errors");
33
+ /** Map an HTTP status to the appropriate typed SDK error subclass. */
33
34
  function errorFromResponseStatus(status, message, options) {
34
35
  if (status === 401) {
35
36
  return new errors_1.AugustAuthError('AUTH_UNAUTHORIZED', message, options);
@@ -43,6 +44,15 @@ function errorFromResponseStatus(status, message, options) {
43
44
  return new errors_1.AugustServerError(status, message, options);
44
45
  }
45
46
  let SDK_REQUEST_TIMEOUT_OVERRIDE = null;
47
+ /**
48
+ * Override the default request timeout used by every August fetcher helper
49
+ * when the caller doesn't supply a per-call `timeoutMs`. Pass `null` (or
50
+ * call with no arguments) to clear the override and fall back to the
51
+ * compiled-in `REQUEST_TIMEOUT_MS`.
52
+ *
53
+ * @param ms Positive number of milliseconds to wait before aborting, or
54
+ * `null` to clear.
55
+ */
46
56
  function setSdkRequestTimeout(ms = null) {
47
57
  if (ms === null) {
48
58
  SDK_REQUEST_TIMEOUT_OVERRIDE = null;
@@ -56,9 +66,21 @@ function setSdkRequestTimeout(ms = null) {
56
66
  }
57
67
  SDK_REQUEST_TIMEOUT_OVERRIDE = ms;
58
68
  }
69
+ /**
70
+ * Read the active default request timeout — the SDK-level override if set,
71
+ * otherwise the compiled-in `REQUEST_TIMEOUT_MS`.
72
+ */
59
73
  function getSdkRequestTimeout() {
60
74
  return SDK_REQUEST_TIMEOUT_OVERRIDE ?? core_2.REQUEST_TIMEOUT_MS;
61
75
  }
76
+ /**
77
+ * Combine the per-request timeout signal with any caller-supplied signal.
78
+ * Uses `AbortSignal.any` (Node 22+) with a manual relay fallback.
79
+ *
80
+ * Returns `timedOut()` (a closure over an internal flag set when the timeout
81
+ * fires) so the caller can distinguish "we timed out" from "caller cancelled",
82
+ * and `cleanup()` to release the fallback-relay listener.
83
+ */
62
84
  function buildRequestAbortSignal(options) {
63
85
  const timeoutMs = options?.timeoutMs ?? SDK_REQUEST_TIMEOUT_OVERRIDE ?? core_2.REQUEST_TIMEOUT_MS;
64
86
  const timeoutController = new AbortController();
@@ -98,8 +120,20 @@ function warnOverrideDeprecation(callerTag) {
98
120
  if (_overrideDeprecationWarned)
99
121
  return;
100
122
  _overrideDeprecationWarned = true;
123
+ // Deliberately a direct console.warn, not Logger.log.warn: a deprecation
124
+ // notice must surface in the integrator's console in every environment.
125
+ // Logger.log.warn would downgrade it to a prod-silent Sentry breadcrumb.
126
+ // 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.
101
127
  console.warn(`[@augustdigital/sdk] ${callerTag}: option "override" is deprecated and will be removed in a future major version. Pass a valid apiKey instead.`);
102
128
  }
129
+ /**
130
+ * LRU cache for API responses and frequently accessed data.
131
+ * 24-hour TTL with 1000 item capacity.
132
+ */
133
+ /**
134
+ * Read a response header tolerantly. Real `fetch` returns a `Headers` instance,
135
+ * but some test mocks supply a plain object; both shapes are supported here.
136
+ */
103
137
  function readResponseHeader(headers, name) {
104
138
  if (!headers)
105
139
  return undefined;
@@ -114,17 +148,33 @@ const cache_1 = require("./cache");
114
148
  Object.defineProperty(exports, "CACHE", { enumerable: true, get: function () { return cache_1.CACHE; } });
115
149
  Object.defineProperty(exports, "getSafeCache", { enumerable: true, get: function () { return cache_1.getSafeCache; } });
116
150
  Object.defineProperty(exports, "setSafeCache", { enumerable: true, get: function () { return cache_1.setSafeCache; } });
151
+ /**
152
+ * Dedicated cache for token prices with short TTL to prevent rate limiting.
153
+ * 30-second TTL with 500 item capacity.
154
+ */
117
155
  const PRICE_CACHE = new lru_cache_1.LRUCache({
118
156
  max: 500,
119
- ttl: 1000 * 30,
157
+ ttl: 1000 * 30, // 30 seconds
120
158
  allowStale: false,
121
159
  });
160
+ /**
161
+ * Cache for failed price requests to prevent retry storms.
162
+ * 5-second TTL to allow quick retry after temporary failures.
163
+ */
122
164
  const PRICE_ERROR_CACHE = new lru_cache_1.LRUCache({
123
165
  max: 100,
124
- ttl: 1000 * 5,
166
+ ttl: 1000 * 5, // 5 seconds
125
167
  allowStale: false,
126
168
  });
169
+ /**
170
+ * In-flight price requests to prevent duplicate simultaneous API calls.
171
+ */
127
172
  const PRICE_REQUESTS = new Map();
173
+ /**
174
+ * Build an August backend URL, rejecting unknown server keys and any
175
+ * `relativeUrl` that would escape the configured origin.
176
+ * Throws `AugustValidationError` with `code: 'INVALID_URL'`.
177
+ */
128
178
  function buildAugustUrl(server, relativeUrl) {
129
179
  const serverKey = server;
130
180
  const base = core_2.WEBSERVER_URL[serverKey];
@@ -134,9 +184,12 @@ function buildAugustUrl(server, relativeUrl) {
134
184
  if (typeof relativeUrl !== 'string' || relativeUrl.length === 0) {
135
185
  throw new errors_1.AugustValidationError('INVALID_URL', 'relativeUrl must be a non-empty string');
136
186
  }
187
+ // Reject anything that looks like a scheme or protocol-relative authority.
137
188
  if (/^\s*[a-z][a-z0-9+.-]*:|^\s*\/\//i.test(relativeUrl)) {
138
189
  throw new errors_1.AugustValidationError('INVALID_URL', `relativeUrl must be a path, not an absolute or protocol-relative URL`);
139
190
  }
191
+ // Concat (rather than `new URL(rel, base)`) preserves base paths like /api/v1
192
+ // when relativeUrl starts with `/`. Origin check below is a second line.
140
193
  const candidate = `${base}${relativeUrl}`;
141
194
  let url;
142
195
  try {
@@ -151,6 +204,15 @@ function buildAugustUrl(server, relativeUrl) {
151
204
  }
152
205
  return url.toString();
153
206
  }
207
+ /**
208
+ * Make authenticated requests to August backend services using API key.
209
+ * Automatically logs errors with correlation IDs for debugging.
210
+ * @param apiKey August API key for authentication
211
+ * @param relativeUrl Endpoint path relative to base URL
212
+ * @param options Request configuration including method and headers
213
+ * @returns Response object if successful
214
+ * @throws Error with correlation ID if request fails
215
+ */
154
216
  async function fetchAugustWithKey(apiKey, relativeUrl, options) {
155
217
  if (options?.override) {
156
218
  warnOverrideDeprecation('fetchAugustWithKey');
@@ -178,6 +240,7 @@ async function fetchAugustWithKey(apiKey, relativeUrl, options) {
178
240
  signal: requestSignal,
179
241
  });
180
242
  cleanup();
243
+ // Track API call
181
244
  (0, analytics_1.trackApiCall)(relativeUrl, options?.method ?? 'GET', startTime, res.status, server);
182
245
  const correlationId = readResponseHeader(res.headers, 'x-correlation-id');
183
246
  const logger = logger_1.Logger.getLogger();
@@ -206,6 +269,14 @@ async function fetchAugustWithKey(apiKey, relativeUrl, options) {
206
269
  throw err;
207
270
  }
208
271
  }
272
+ /**
273
+ * Make unauthenticated requests to August public API endpoints.
274
+ * Used for fetching vault metadata and public market data.
275
+ * @param relativeUrl Endpoint path relative to public API base URL
276
+ * @param options Request configuration including method and headers
277
+ * @returns Response object if successful
278
+ * @throws Error with correlation ID if request fails
279
+ */
209
280
  async function fetchAugustPublic(relativeUrl, options) {
210
281
  const defaultHeaders = {
211
282
  'content-type': 'application/json',
@@ -253,6 +324,15 @@ async function fetchAugustPublic(relativeUrl, options) {
253
324
  throw err;
254
325
  }
255
326
  }
327
+ /**
328
+ * Make authenticated requests using Bearer token authentication.
329
+ * Typically used for user-specific operations requiring OAuth tokens.
330
+ * @param bearerToken OAuth bearer token
331
+ * @param relativeUrl Endpoint path relative to base URL
332
+ * @param options Request configuration including method and headers
333
+ * @returns Response object if successful
334
+ * @throws Error with correlation ID if request fails
335
+ */
256
336
  async function fetchAugustWithBearer(bearerToken, relativeUrl, options) {
257
337
  const defaultHeaders = {
258
338
  authorization: `Bearer ${bearerToken}`,
@@ -302,6 +382,10 @@ async function fetchAugustWithBearer(bearerToken, relativeUrl, options) {
302
382
  throw err;
303
383
  }
304
384
  }
385
+ /**
386
+ * Check if an error is network-related and suitable for retry.
387
+ * Identifies timeouts, connection resets, and fetch failures.
388
+ */
305
389
  function isRetryableError(error) {
306
390
  return ((error instanceof TypeError && error.message.includes('fetch failed')) ||
307
391
  error.name === 'AbortError' ||
@@ -311,6 +395,16 @@ function isRetryableError(error) {
311
395
  error.message.includes('ENOTFOUND') ||
312
396
  error.message.includes('ECONNREFUSED'));
313
397
  }
398
+ /**
399
+ * Wrap async operations with exponential backoff retry logic.
400
+ * Retries on network errors with increasing delays between attempts.
401
+ * @param fn Async function to execute with retry logic
402
+ * @param maxRetries Maximum number of retry attempts
403
+ * @param baseDelay Initial delay in milliseconds (doubles each retry)
404
+ * @param shouldRetry Custom function to determine if error is retryable
405
+ * @returns Result of successful function execution
406
+ * @throws Last error if all retries exhausted
407
+ */
314
408
  async function withRetry(fn, maxRetries = 3, baseDelay = 1000, shouldRetry = isRetryableError) {
315
409
  let lastError;
316
410
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
@@ -330,10 +424,18 @@ async function withRetry(fn, maxRetries = 3, baseDelay = 1000, shouldRetry = isR
330
424
  }
331
425
  throw lastError;
332
426
  }
427
+ /**
428
+ * Fetch tokenized vault configurations from backend API.
429
+ * Results are cached to reduce API calls. Optionally filter by specific vault address.
430
+ * @param pool Optional vault address to filter results
431
+ * @param headers Monitoring headers for request tracking
432
+ * @returns Array of tokenized vault configurations
433
+ */
333
434
  async function fetchTokenizedVault(pool, headers, loadSubaccounts, loadSnapshots) {
334
435
  if (!pool) {
335
436
  return [];
336
437
  }
438
+ // Build cache key based on loading options
337
439
  const keyParts = [`tokenized-vault-${pool}`];
338
440
  if (loadSubaccounts === false)
339
441
  keyParts.push('no-subaccounts');
@@ -346,6 +448,7 @@ async function fetchTokenizedVault(pool, headers, loadSubaccounts, loadSnapshots
346
448
  tokenizedVault = cachedResponse;
347
449
  }
348
450
  if (!tokenizedVault) {
451
+ // Build endpoint URL with optional query parameters
349
452
  let endpoint = core_2.WEBSERVER_ENDPOINTS.public.tokenizedVault.byVaultAddress(pool);
350
453
  const params = new URLSearchParams();
351
454
  if (loadSubaccounts === false) {
@@ -362,15 +465,25 @@ async function fetchTokenizedVault(pool, headers, loadSubaccounts, loadSnapshots
362
465
  headers: headers,
363
466
  });
364
467
  tokenizedVault = (await tokenizedVaultsResponse.json());
365
- cache_1.CACHE.set(key, tokenizedVault, { ttl: 1000 * 60 * 10 });
468
+ cache_1.CACHE.set(key, tokenizedVault, { ttl: 1000 * 60 * 10 }); // Cache for 10 minutes
366
469
  }
470
+ // Filter by specific vault if address provided
367
471
  if (pool &&
368
472
  ((0, ethers_1.isAddress)(pool) || (0, chain_address_1.isSolanaAddress)(pool) || (0, chain_address_1.isStellarAddress)(pool))) {
369
473
  return tokenizedVault ? [tokenizedVault] : [];
370
474
  }
371
475
  return [tokenizedVault];
372
476
  }
477
+ /**
478
+ * Fetch tokenized vault configurations from backend API.
479
+ * Results are cached to reduce API calls. Optionally filter by specific vault address.
480
+ * @param pool Optional vault address to filter results
481
+ * @param headers Monitoring headers for request tracking
482
+ * @param loadSubaccounts Optional flag to load subaccounts and EOA operators (defaults to true on API)
483
+ * @returns Array of tokenized vault configurations
484
+ */
373
485
  async function fetchTokenizedVaults(pool, headers, loadSubaccounts, loadSnapshots) {
486
+ // Build cache key based on loading options
374
487
  const keyParts = ['tokenized-vaults'];
375
488
  if (pool)
376
489
  keyParts.push(pool);
@@ -385,6 +498,7 @@ async function fetchTokenizedVaults(pool, headers, loadSubaccounts, loadSnapshot
385
498
  tokenizedVaults = cachedResponse;
386
499
  }
387
500
  if (!tokenizedVaults) {
501
+ // Build endpoint URL with optional query parameters
388
502
  let endpoint = core_2.WEBSERVER_ENDPOINTS.public.tokenizedVault.list;
389
503
  const params = new URLSearchParams();
390
504
  if (loadSubaccounts === false) {
@@ -402,9 +516,10 @@ async function fetchTokenizedVaults(pool, headers, loadSubaccounts, loadSnapshot
402
516
  });
403
517
  tokenizedVaults =
404
518
  (await tokenizedVaultsResponse.json());
405
- const ttl = 1000 * 60 * 15;
519
+ const ttl = 1000 * 60 * 15; // 15 minute cache
406
520
  cache_1.CACHE.set(key, tokenizedVaults, { ttl });
407
521
  }
522
+ // Filter by specific vault if address provided
408
523
  if (pool &&
409
524
  ((0, ethers_1.isAddress)(pool) || (0, chain_address_1.isSolanaAddress)(pool) || (0, chain_address_1.isStellarAddress)(pool))) {
410
525
  const foundObj = tokenizedVaults.find((t) => t.address.toLowerCase() === pool.toLowerCase());
@@ -412,57 +527,84 @@ async function fetchTokenizedVaults(pool, headers, loadSubaccounts, loadSnapshot
412
527
  }
413
528
  return tokenizedVaults;
414
529
  }
530
+ /**
531
+ * Fetch current USD price for a token symbol or vault LP token.
532
+ * For vault LP tokens, calculates share price using totalAssets/totalSupply ratio.
533
+ * Falls back to CoinGecko if primary source fails.
534
+ * @param symbol Token symbol or contract address
535
+ * @param provider Optional web3 provider for on-chain price calculations
536
+ * @param coinGeckoKey Optional CoinGecko API key for fallback pricing
537
+ * @param headers Monitoring headers for request tracking
538
+ * @returns Token price in USD
539
+ */
415
540
  async function fetchTokenPrice(symbol, provider, coinGeckoKey, headers) {
416
541
  if (!symbol) {
417
542
  logger_1.Logger.log.error('fetchTokenPrice', 'symbol parameter is undefined');
418
543
  return 0;
419
544
  }
545
+ // Normalize symbol and apply aliases BEFORE generating cache key
420
546
  let normalizedSymbol = symbol.toLowerCase();
421
547
  normalizedSymbol = normalizedSymbol === 'xbtc' ? 'btc' : normalizedSymbol;
422
548
  normalizedSymbol = normalizedSymbol === 'strbtc' ? 'btc' : normalizedSymbol;
549
+ // Generate cache key based on normalized symbol and provider presence
423
550
  const cacheKey = `price:${normalizedSymbol}:${provider ? 'with-provider' : 'no-provider'}`;
551
+ // Check error cache to prevent retry storms after failures
424
552
  const cachedError = PRICE_ERROR_CACHE.get(cacheKey);
425
553
  if (cachedError) {
426
554
  logger_1.Logger.log.info('fetchTokenPrice', `Error cache HIT for ${normalizedSymbol} - throwing cached error`);
427
555
  throw cachedError;
428
556
  }
557
+ // Check price cache first to avoid rate limiting
429
558
  const cachedPrice = PRICE_CACHE.get(cacheKey);
430
559
  if (cachedPrice !== undefined) {
431
560
  logger_1.Logger.log.info('fetchTokenPrice', `Cache HIT for ${normalizedSymbol}: $${cachedPrice}`);
432
561
  return cachedPrice;
433
562
  }
563
+ // Check for in-flight request to deduplicate simultaneous calls
434
564
  const inflightRequest = PRICE_REQUESTS.get(cacheKey);
435
565
  if (inflightRequest) {
436
566
  logger_1.Logger.log.info('fetchTokenPrice', `In-flight request deduplication for ${normalizedSymbol}`);
437
567
  return inflightRequest;
438
568
  }
569
+ // Create the price fetching promise
439
570
  const pricePromise = (async () => {
440
571
  try {
441
572
  const price = await _fetchTokenPriceInternal(symbol, provider, coinGeckoKey, headers);
573
+ // Cache the successful result
442
574
  PRICE_CACHE.set(cacheKey, price);
575
+ // Clear any previous error cache on success
443
576
  PRICE_ERROR_CACHE.delete(cacheKey);
444
577
  return price;
445
578
  }
446
579
  catch (error) {
580
+ // Cache the error temporarily to prevent retry storms
447
581
  const err = error instanceof Error ? error : new Error(String(error));
448
582
  PRICE_ERROR_CACHE.set(cacheKey, err);
449
583
  logger_1.Logger.log.info('fetchTokenPrice', `Cached error for ${normalizedSymbol}: ${err.message}`);
450
584
  throw err;
451
585
  }
452
586
  finally {
587
+ // Clean up in-flight request tracking
453
588
  PRICE_REQUESTS.delete(cacheKey);
454
589
  }
455
590
  })();
591
+ // Track this request to prevent duplicates
456
592
  PRICE_REQUESTS.set(cacheKey, pricePromise);
457
593
  return pricePromise;
458
594
  }
595
+ /**
596
+ * Internal price fetching implementation.
597
+ * This is separated to allow caching and request deduplication in the public function.
598
+ */
459
599
  async function _fetchTokenPriceInternal(symbol, provider, coinGeckoKey, headers) {
600
+ // Fetch vault metadata to check if symbol is a vault LP token
460
601
  const tokenizedVaults = await fetchTokenizedVaults(undefined, headers, false, false);
461
602
  const vaultArray = tokenizedVaults.map((vault) => ({
462
603
  vault: vault.address,
463
604
  symbol: vault.receipt_token_symbol,
464
605
  }));
465
606
  const foundVaultLpAsset = vaultArray.find((v) => v.symbol?.toLowerCase() === symbol?.toLowerCase());
607
+ // @todo: handle multi-asset vaults
466
608
  const tokenizedVault = tokenizedVaults.find((vault) => vault.address === foundVaultLpAsset?.vault);
467
609
  const version = (0, vault_version_1.getVaultVersionV2)(tokenizedVault);
468
610
  if (foundVaultLpAsset?.vault && provider && version === 'evm-2') {
@@ -478,15 +620,18 @@ async function _fetchTokenPriceInternal(symbol, provider, coinGeckoKey, headers)
478
620
  throw new Error('failed to fetch token price for evm-2 vault');
479
621
  }
480
622
  }
623
+ // Apply symbol normalization and aliases for API calls
481
624
  let _symbol = symbol?.toLowerCase();
482
625
  _symbol = _symbol === 'xbtc' ? 'btc' : _symbol;
483
626
  _symbol = _symbol === 'strbtc' ? 'btc' : _symbol;
484
627
  try {
628
+ // Fetch base token price from August backend
485
629
  const res = await fetch(`https://prices.augustdigital.io/price/${_symbol}`, { headers: headers });
486
630
  if (res.status !== 200) {
487
631
  throw new Error(`fetching ${_symbol} price: ${res?.statusText}`);
488
632
  }
489
633
  const json = (await res.json());
634
+ // For vault LP tokens, calculate share price using on-chain ratio
490
635
  if (foundVaultLpAsset && provider) {
491
636
  const vaultContract = new ethers_2.Contract((0, ethers_1.getAddress)(foundVaultLpAsset.vault), abis_1.ABI_LENDING_POOL_V2, provider);
492
637
  const [totalAssets, totalSupply, rawDecimals] = await Promise.all([
@@ -501,6 +646,7 @@ async function _fetchTokenPriceInternal(symbol, provider, coinGeckoKey, headers)
501
646
  return json.price;
502
647
  }
503
648
  catch (e) {
649
+ // Fallback to CoinGecko if primary source fails
504
650
  const fallbackPrice = await (0, fetcher_1.fetchTokenPricesFromCoinGecko)(symbol, coinGeckoKey);
505
651
  if (foundVaultLpAsset && provider) {
506
652
  const vaultContract = new ethers_2.Contract((0, ethers_1.getAddress)(foundVaultLpAsset.vault), abis_1.ABI_LENDING_POOL_V2, provider);
@@ -521,6 +667,13 @@ async function _fetchTokenPriceInternal(symbol, provider, coinGeckoKey, headers)
521
667
  }
522
668
  }
523
669
  }
670
+ /**
671
+ * Fetch token price by contract address and chain ID from August price server.
672
+ * @param address Token contract address
673
+ * @param chainId Network chain ID
674
+ * @param headers Optional monitoring headers for request tracking
675
+ * @returns Token price in USD, or 0 if not found
676
+ */
524
677
  async function fetchTokenPriceByAddress(address, chainId, headers) {
525
678
  if (!address || !chainId) {
526
679
  return 0;
@@ -547,6 +700,14 @@ async function fetchTokenPriceByAddress(address, chainId, headers) {
547
700
  return 0;
548
701
  }
549
702
  }
703
+ /**
704
+ * Fetch active loans for a specific vault from backend API.
705
+ * Results are cached per vault and chain to reduce API calls.
706
+ * @param pool Vault address
707
+ * @param chainId Network chain ID
708
+ * @param headers Monitoring headers for request tracking
709
+ * @returns Array of active loan objects
710
+ */
550
711
  async function fetchTokenizedVaultLoans(pool, chainId, headers) {
551
712
  const key = `loans-${chainId}-${pool}`;
552
713
  let loans;
@@ -560,6 +721,14 @@ async function fetchTokenizedVaultLoans(pool, chainId, headers) {
560
721
  }
561
722
  return loans?.filter((l) => l.state.toLowerCase() === 'active');
562
723
  }
724
+ /**
725
+ * Fetch subaccount loans for a specific tokenized vault (lending pool).
726
+ * Retrieves all active subaccount loan data from the backend.
727
+ * @param pool Vault address
728
+ * @param chainId Network chain ID
729
+ * @param headers Monitoring headers for request tracking
730
+ * @returns Array of active subaccount loan objects
731
+ */
563
732
  async function fetchTokenizedVaultSubaccountLoans(pool, chainId, headers) {
564
733
  const key = `subaccount-loans-${chainId}-${pool}`;
565
734
  let loans;
@@ -573,6 +742,14 @@ async function fetchTokenizedVaultSubaccountLoans(pool, chainId, headers) {
573
742
  }
574
743
  return loans?.filter((l) => l.state.toLowerCase() === 'active');
575
744
  }
745
+ /**
746
+ * Fetch historical timeseries data for a specific vault.
747
+ * Returns TVL, APY, PnL, and share price data over time.
748
+ * @param vaultAddress Vault contract address
749
+ * @param nDays Number of days of historical data to fetch (default 30, min 1)
750
+ * @param headers Monitoring headers for request tracking
751
+ * @returns Historical timeseries data with date keys
752
+ */
576
753
  async function fetchVaultHistoricalTimeseries(vaultAddress, nDays, headers) {
577
754
  const key = `vault-historical-timeseries-${vaultAddress}-${nDays}`;
578
755
  const cachedResponse = await (0, cache_1.getSafeCache)(key);
@@ -584,9 +761,18 @@ async function fetchVaultHistoricalTimeseries(vaultAddress, nDays, headers) {
584
761
  throw new Error(`Failed to fetch historical timeseries data: ${response.statusText}`);
585
762
  }
586
763
  const json = (await response.json());
587
- cache_1.CACHE.set(key, json, { ttl: 1000 * 60 * 10 });
764
+ cache_1.CACHE.set(key, json, { ttl: 1000 * 60 * 10 }); // Cache for 10 minutes
588
765
  return json;
589
766
  }
767
+ /**
768
+ * Execute multiple promises with retry logic and allow partial failures.
769
+ * Unlike Promise.all, continues execution if some promises fail.
770
+ * Failed promises return null to maintain array index alignment.
771
+ * @param promises Array of promises to execute
772
+ * @param maxRetries Maximum retry attempts per promise
773
+ * @param baseDelay Initial delay for exponential backoff
774
+ * @returns Array of results with null for failed promises
775
+ */
590
776
  async function promiseSettle(promises, maxRetries = 3, baseDelay = 1000) {
591
777
  const promisesWithRetry = promises.map((promise, index) => withRetry(async () => {
592
778
  try {
@@ -1,4 +1,13 @@
1
1
  import { IAddress, IVaultAdapterConfig } from '../../types';
2
+ /**
3
+ * Get adapter configuration for a vault
4
+ */
2
5
  export declare function getVaultAdapterConfig(vaultAddress: IAddress): IVaultAdapterConfig | undefined;
6
+ /**
7
+ * Check if vault has adapter support
8
+ */
3
9
  export declare function vaultHasAdapter(vaultAddress: IAddress): boolean;
10
+ /**
11
+ * Get deposit tokens for a vault (includes underlying + adapter tokens)
12
+ */
4
13
  export declare function getVaultDepositTokens(vaultAddress: IAddress, underlyingToken: IAddress): IAddress[];
@@ -4,19 +4,30 @@ exports.getVaultAdapterConfig = getVaultAdapterConfig;
4
4
  exports.vaultHasAdapter = vaultHasAdapter;
5
5
  exports.getVaultDepositTokens = getVaultDepositTokens;
6
6
  const adapters_1 = require("../constants/adapters");
7
+ /**
8
+ * Get adapter configuration for a vault
9
+ */
7
10
  function getVaultAdapterConfig(vaultAddress) {
8
11
  return adapters_1.VAULT_ADAPTER_CONFIGS[vaultAddress];
9
12
  }
13
+ /**
14
+ * Check if vault has adapter support
15
+ */
10
16
  function vaultHasAdapter(vaultAddress) {
11
17
  return !!adapters_1.VAULT_ADAPTER_CONFIGS[vaultAddress];
12
18
  }
19
+ /**
20
+ * Get deposit tokens for a vault (includes underlying + adapter tokens)
21
+ */
13
22
  function getVaultDepositTokens(vaultAddress, underlyingToken) {
14
23
  const adapterConfig = getVaultAdapterConfig(vaultAddress);
15
24
  if (!adapterConfig) {
16
25
  return [underlyingToken];
17
26
  }
27
+ // Return all tokens including the underlying
18
28
  const allTokens = [underlyingToken];
19
29
  if (adapterConfig.tokens && adapterConfig.tokens.length > 0) {
30
+ // Use configured tokens list
20
31
  adapterConfig.tokens.forEach((token) => {
21
32
  if (!allTokens.includes(token)) {
22
33
  allTokens.push(token);
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Check if a string is a valid Solana base58 address (including PDAs).
3
+ * Returns `false` for EVM hex addresses.
4
+ */
1
5
  export declare function isSolanaAddress(address: string): boolean;
6
+ /**
7
+ * Check if a string is a valid Stellar address.
8
+ * Muxed accounts (M prefix, per SEP-0023) are intentionally excluded — they are
9
+ * not valid vault or contract addresses.
10
+ */
2
11
  export declare function isStellarAddress(address: string): boolean;
12
+ /** Check if a string is a valid Sui address (0x + 64 hex chars). */
3
13
  export declare function isSuiAddress(address: string): boolean;