@augustdigital/sdk 8.3.2 → 8.6.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 (213) hide show
  1. package/README.md +207 -117
  2. package/lib/abis/ERC20_Bytes32.d.ts +4 -0
  3. package/lib/abis/ERC20_Bytes32.js +4 -0
  4. package/lib/abis/ERC4626.d.ts +1 -0
  5. package/lib/abis/ERC4626.js +1 -0
  6. package/lib/abis/ERC721.d.ts +1 -0
  7. package/lib/abis/ERC721.js +1 -0
  8. package/lib/abis/FeeOracle.js +1 -0
  9. package/lib/abis/LendingPool.js +1 -0
  10. package/lib/abis/LendingPoolV2.js +1 -0
  11. package/lib/abis/Multicall3.js +3 -0
  12. package/lib/abis/OFT.d.ts +20 -0
  13. package/lib/abis/OFT.js +20 -0
  14. package/lib/abis/SmartAccount.d.ts +1 -0
  15. package/lib/abis/SmartAccount.js +3 -0
  16. package/lib/abis/SwapRouter.d.ts +1 -0
  17. package/lib/abis/SwapRouter.js +1 -0
  18. package/lib/abis/UniversalSignatureValidator.js +3 -0
  19. package/lib/abis/index.d.ts +5 -0
  20. package/lib/abis/index.js +5 -0
  21. package/lib/adapters/evm/getters.d.ts +17 -2
  22. package/lib/adapters/evm/getters.js +35 -3
  23. package/lib/adapters/evm/index.d.ts +266 -4
  24. package/lib/adapters/evm/index.js +270 -1
  25. package/lib/adapters/evm/utils.d.ts +6 -0
  26. package/lib/adapters/evm/utils.js +7 -0
  27. package/lib/adapters/solana/constants.d.ts +1 -1
  28. package/lib/adapters/solana/constants.js +4 -1
  29. package/lib/adapters/solana/getters.d.ts +9 -1
  30. package/lib/adapters/solana/getters.js +21 -0
  31. package/lib/adapters/solana/idl/vault-idl.js +9 -0
  32. package/lib/adapters/solana/index.d.ts +59 -4
  33. package/lib/adapters/solana/index.js +61 -0
  34. package/lib/adapters/solana/types.d.ts +1 -1
  35. package/lib/adapters/solana/utils.d.ts +31 -3
  36. package/lib/adapters/solana/utils.js +79 -4
  37. package/lib/adapters/solana/vault.actions.d.ts +23 -4
  38. package/lib/adapters/solana/vault.actions.js +47 -3
  39. package/lib/adapters/stellar/actions.d.ts +26 -1
  40. package/lib/adapters/stellar/actions.js +33 -0
  41. package/lib/adapters/stellar/constants.d.ts +26 -0
  42. package/lib/adapters/stellar/constants.js +29 -0
  43. package/lib/adapters/stellar/getters.d.ts +56 -0
  44. package/lib/adapters/stellar/getters.js +81 -0
  45. package/lib/adapters/stellar/index.d.ts +70 -0
  46. package/lib/adapters/stellar/index.js +71 -0
  47. package/lib/adapters/stellar/soroban.d.ts +21 -1
  48. package/lib/adapters/stellar/soroban.js +47 -1
  49. package/lib/adapters/stellar/submit.d.ts +29 -0
  50. package/lib/adapters/stellar/submit.js +90 -5
  51. package/lib/adapters/stellar/types.d.ts +27 -0
  52. package/lib/adapters/stellar/types.js +3 -0
  53. package/lib/adapters/stellar/utils.d.ts +10 -0
  54. package/lib/adapters/stellar/utils.js +10 -0
  55. package/lib/adapters/sui/getters.d.ts +7 -1
  56. package/lib/adapters/sui/getters.js +6 -0
  57. package/lib/adapters/sui/index.d.ts +16 -1
  58. package/lib/adapters/sui/index.js +17 -0
  59. package/lib/adapters/sui/transformer.d.ts +8 -2
  60. package/lib/adapters/sui/transformer.js +7 -0
  61. package/lib/adapters/sui/types.d.ts +1 -1
  62. package/lib/adapters/sui/utils.d.ts +6 -0
  63. package/lib/adapters/sui/utils.js +6 -0
  64. package/lib/core/analytics/chain-name.d.ts +8 -0
  65. package/lib/core/analytics/chain-name.js +8 -0
  66. package/lib/core/analytics/constants.d.ts +4 -0
  67. package/lib/core/analytics/constants.js +4 -0
  68. package/lib/core/analytics/env.d.ts +25 -0
  69. package/lib/core/analytics/env.js +26 -0
  70. package/lib/core/analytics/index.d.ts +26 -0
  71. package/lib/core/analytics/index.js +35 -0
  72. package/lib/core/analytics/instrumentation.d.ts +26 -0
  73. package/lib/core/analytics/instrumentation.js +66 -2
  74. package/lib/core/analytics/method-taxonomy.d.ts +16 -0
  75. package/lib/core/analytics/method-taxonomy.js +18 -0
  76. package/lib/core/analytics/metrics.d.ts +23 -0
  77. package/lib/core/analytics/metrics.js +40 -0
  78. package/lib/core/analytics/sanitize.d.ts +38 -0
  79. package/lib/core/analytics/sanitize.js +46 -0
  80. package/lib/core/analytics/sentry-runtime.d.ts +11 -0
  81. package/lib/core/analytics/sentry-runtime.js +20 -1
  82. package/lib/core/analytics/sentry.d.ts +47 -2
  83. package/lib/core/analytics/sentry.js +115 -2
  84. package/lib/core/analytics/types.d.ts +28 -1
  85. package/lib/core/analytics/user-identity.d.ts +36 -2
  86. package/lib/core/analytics/user-identity.js +43 -1
  87. package/lib/core/analytics/version.d.ts +6 -1
  88. package/lib/core/analytics/version.js +6 -1
  89. package/lib/core/auth/verify.js +5 -0
  90. package/lib/core/base.class.d.ts +78 -3
  91. package/lib/core/base.class.js +66 -4
  92. package/lib/core/cache.d.ts +5 -0
  93. package/lib/core/cache.js +6 -0
  94. package/lib/core/constants/adapters.d.ts +16 -1
  95. package/lib/core/constants/adapters.js +28 -8
  96. package/lib/core/constants/core.d.ts +14 -1
  97. package/lib/core/constants/core.js +18 -0
  98. package/lib/core/constants/swap-router.d.ts +83 -1
  99. package/lib/core/constants/swap-router.js +91 -1
  100. package/lib/core/constants/vaults.d.ts +57 -1
  101. package/lib/core/constants/vaults.js +66 -1
  102. package/lib/core/constants/web3.d.ts +4 -1
  103. package/lib/core/constants/web3.js +15 -5
  104. package/lib/core/errors/index.d.ts +38 -2
  105. package/lib/core/errors/index.js +38 -0
  106. package/lib/core/fetcher.d.ts +136 -2
  107. package/lib/core/fetcher.js +229 -25
  108. package/lib/core/helpers/adapters.d.ts +10 -1
  109. package/lib/core/helpers/adapters.js +11 -0
  110. package/lib/core/helpers/chain-address.d.ts +10 -0
  111. package/lib/core/helpers/chain-address.js +11 -0
  112. package/lib/core/helpers/core.d.ts +49 -4
  113. package/lib/core/helpers/core.js +74 -7
  114. package/lib/core/helpers/explorer-link.d.ts +15 -1
  115. package/lib/core/helpers/explorer-link.js +14 -0
  116. package/lib/core/helpers/signer.d.ts +27 -1
  117. package/lib/core/helpers/signer.js +39 -0
  118. package/lib/core/helpers/swap-router.d.ts +33 -1
  119. package/lib/core/helpers/swap-router.js +32 -0
  120. package/lib/core/helpers/vault-version.d.ts +2 -1
  121. package/lib/core/helpers/vault-version.js +2 -0
  122. package/lib/core/helpers/vaults.d.ts +9 -1
  123. package/lib/core/helpers/vaults.js +22 -8
  124. package/lib/core/helpers/web3.d.ts +154 -2
  125. package/lib/core/helpers/web3.js +192 -15
  126. package/lib/core/logger/index.d.ts +55 -0
  127. package/lib/core/logger/index.js +19 -0
  128. package/lib/core/logger/slack.d.ts +3 -0
  129. package/lib/core/logger/slack.js +3 -0
  130. package/lib/core/vault-metadata.d.ts +7 -1
  131. package/lib/core/vault-metadata.js +6 -0
  132. package/lib/core/version-check.d.ts +52 -0
  133. package/lib/core/version-check.js +82 -1
  134. package/lib/evm/methods/crossChainVault.d.ts +90 -0
  135. package/lib/evm/methods/crossChainVault.js +187 -2
  136. package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
  137. package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
  138. package/lib/evm/methods/index.d.ts +1 -0
  139. package/lib/evm/methods/index.js +1 -0
  140. package/lib/evm/types/crossChain.d.ts +202 -0
  141. package/lib/evm/types/crossChain.js +12 -1
  142. package/lib/index.d.ts +16 -0
  143. package/lib/index.js +19 -0
  144. package/lib/main.d.ts +289 -6
  145. package/lib/main.js +312 -0
  146. package/lib/modules/api/index.d.ts +1 -0
  147. package/lib/modules/api/index.js +6 -0
  148. package/lib/modules/api/main.d.ts +52 -0
  149. package/lib/modules/api/main.js +130 -0
  150. package/lib/modules/sub-accounts/fetcher.d.ts +17 -2
  151. package/lib/modules/sub-accounts/fetcher.js +15 -0
  152. package/lib/modules/sub-accounts/main.d.ts +35 -2
  153. package/lib/modules/sub-accounts/main.js +39 -1
  154. package/lib/modules/sub-accounts/utils.d.ts +4 -1
  155. package/lib/modules/sub-accounts/utils.js +3 -0
  156. package/lib/modules/vaults/adapter.helpers.d.ts +21 -3
  157. package/lib/modules/vaults/adapter.helpers.js +34 -0
  158. package/lib/modules/vaults/fetcher.d.ts +45 -0
  159. package/lib/modules/vaults/fetcher.js +91 -4
  160. package/lib/modules/vaults/getters.d.ts +295 -0
  161. package/lib/modules/vaults/getters.js +567 -26
  162. package/lib/modules/vaults/index.d.ts +12 -0
  163. package/lib/modules/vaults/index.js +12 -0
  164. package/lib/modules/vaults/main.d.ts +292 -4
  165. package/lib/modules/vaults/main.js +382 -8
  166. package/lib/modules/vaults/read.actions.d.ts +170 -2
  167. package/lib/modules/vaults/read.actions.js +143 -0
  168. package/lib/modules/vaults/types.d.ts +34 -0
  169. package/lib/modules/vaults/utils/call-data-decoder.d.ts +48 -1
  170. package/lib/modules/vaults/utils/call-data-decoder.js +56 -0
  171. package/lib/modules/vaults/utils/date-utils.d.ts +39 -0
  172. package/lib/modules/vaults/utils/date-utils.js +47 -1
  173. package/lib/modules/vaults/utils.d.ts +85 -0
  174. package/lib/modules/vaults/utils.js +139 -7
  175. package/lib/modules/vaults/write.actions.d.ts +363 -3
  176. package/lib/modules/vaults/write.actions.js +399 -3
  177. package/lib/polyfills.js +4 -2
  178. package/lib/sdk.d.ts +23847 -0
  179. package/lib/services/coingecko/fetcher.d.ts +15 -1
  180. package/lib/services/coingecko/fetcher.js +30 -9
  181. package/lib/services/debank/fetcher.d.ts +15 -1
  182. package/lib/services/debank/fetcher.js +12 -0
  183. package/lib/services/debank/utils.d.ts +1 -1
  184. package/lib/services/debank/utils.js +18 -1
  185. package/lib/services/layerzero/deposits.d.ts +12 -1
  186. package/lib/services/layerzero/deposits.js +34 -11
  187. package/lib/services/layerzero/redeems.d.ts +11 -1
  188. package/lib/services/layerzero/redeems.js +13 -0
  189. package/lib/services/layerzero/utils.d.ts +8 -0
  190. package/lib/services/layerzero/utils.js +11 -0
  191. package/lib/services/octavfi/fetcher.d.ts +8 -1
  192. package/lib/services/octavfi/fetcher.js +25 -0
  193. package/lib/services/octavfi/types.d.ts +1 -1
  194. package/lib/services/octavfi/utils.d.ts +14 -2
  195. package/lib/services/octavfi/utils.js +44 -10
  196. package/lib/services/subgraph/fetcher.js +4 -2
  197. package/lib/services/subgraph/vaults.d.ts +12 -0
  198. package/lib/services/subgraph/vaults.js +119 -2
  199. package/lib/services/swap-quotes/index.d.ts +80 -0
  200. package/lib/services/swap-quotes/index.js +27 -1
  201. package/lib/services/swap-quotes/paraswap.d.ts +25 -0
  202. package/lib/services/swap-quotes/paraswap.js +22 -0
  203. package/lib/types/pools.d.ts +5 -2
  204. package/lib/types/staking.d.ts +1 -1
  205. package/lib/types/sub-accounts.d.ts +1 -1
  206. package/lib/types/subgraph.d.ts +10 -1
  207. package/lib/types/typed-contract.d.ts +64 -0
  208. package/lib/types/vaults.d.ts +163 -2
  209. package/lib/types/vaults.js +10 -0
  210. package/lib/types/web3.d.ts +9 -1
  211. package/lib/types/web3.js +1 -0
  212. package/lib/types/webserver.d.ts +47 -2
  213. 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
- data?: any;
17
+ data?: unknown;
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[]>;
24
- export declare function fetchTokenPrice(symbol: string, provider?: IContractRunner, coinGeckoKey?: string, headers?: IWSMonitorHeaders): Promise<any>;
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
+ */
118
+ export declare function fetchTokenPrice(symbol: string, provider?: IContractRunner, coinGeckoKey?: string, headers?: IWSMonitorHeaders): Promise<number>;
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[]>;