@augustdigital/sdk 8.3.1 → 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 +7 -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 +70 -0
  170. package/lib/modules/vaults/utils.js +108 -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 +139 -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
@@ -7,11 +7,21 @@ exports.createUserIdentity = createUserIdentity;
7
7
  exports.getUserId = getUserId;
8
8
  const crypto_1 = require("crypto");
9
9
  const uuid_1 = require("uuid");
10
+ /** Session ID persists for SDK instance lifetime */
10
11
  let sessionId = null;
12
+ /** Cached masked API key */
11
13
  let cachedMaskedApiKey = null;
14
+ /**
15
+ * Mask an API key, keeping only the last 5 characters visible.
16
+ * Example: "abcdefghij12345" -> "**********12345"
17
+ *
18
+ * @param apiKey - The raw API key to mask
19
+ * @returns Masked API key with last 5 characters visible
20
+ */
12
21
  function hashApiKey(apiKey) {
13
22
  if (!apiKey)
14
23
  return '';
24
+ // Use cached masked key if available
15
25
  if (cachedMaskedApiKey)
16
26
  return cachedMaskedApiKey;
17
27
  const visibleChars = 5;
@@ -25,14 +35,27 @@ function hashApiKey(apiKey) {
25
35
  }
26
36
  return cachedMaskedApiKey;
27
37
  }
38
+ /**
39
+ * Generate a session ID that persists for the SDK instance lifetime.
40
+ * Provides user continuity even when wallet is not connected.
41
+ *
42
+ * @returns UUID v4 session identifier
43
+ */
28
44
  function getSessionId() {
29
45
  if (!sessionId) {
30
46
  sessionId = (0, uuid_1.v4)();
31
47
  }
32
48
  return sessionId;
33
49
  }
50
+ /**
51
+ * Generate a browser/environment fingerprint for cross-session tracking.
52
+ * Falls back gracefully in different environments.
53
+ *
54
+ * @returns Base64 encoded fingerprint string or undefined if unavailable
55
+ */
34
56
  function generateFingerprint() {
35
57
  try {
58
+ // Browser environment
36
59
  if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
37
60
  const components = [
38
61
  navigator.userAgent,
@@ -42,11 +65,13 @@ function generateFingerprint() {
42
65
  typeof screen !== 'undefined' ? screen.height?.toString() : '',
43
66
  typeof screen !== 'undefined' ? screen.colorDepth?.toString() : '',
44
67
  ].filter(Boolean);
68
+ // Create a simple hash from components
45
69
  const hash = (0, crypto_1.createHash)('sha256')
46
70
  .update(components.join('|'))
47
71
  .digest('hex');
48
72
  return hash.substring(0, 32);
49
73
  }
74
+ // Node.js environment
50
75
  if (typeof process !== 'undefined' && process.platform) {
51
76
  const components = [process.platform, process.arch, process.version];
52
77
  const hash = (0, crypto_1.createHash)('sha256')
@@ -56,10 +81,19 @@ function generateFingerprint() {
56
81
  }
57
82
  }
58
83
  catch {
84
+ // Silently fail if fingerprinting is not possible
59
85
  return undefined;
60
86
  }
61
87
  return undefined;
62
88
  }
89
+ /**
90
+ * Create a composite user identity for analytics.
91
+ *
92
+ * @param apiKey - Optional API key (will be hashed, never stored raw)
93
+ * @param walletAddress - Optional wallet address
94
+ * @param environment - Current environment (DEV or PROD)
95
+ * @returns User identity object
96
+ */
63
97
  function createUserIdentity(apiKey, walletAddress, environment = 'PROD') {
64
98
  let domain = undefined;
65
99
  try {
@@ -71,6 +105,7 @@ function createUserIdentity(apiKey, walletAddress, environment = 'PROD') {
71
105
  }
72
106
  }
73
107
  catch {
108
+ // Silently fail - domain is optional
74
109
  }
75
110
  return {
76
111
  apiKeyHash: apiKey ? hashApiKey(apiKey) : undefined,
@@ -81,6 +116,13 @@ function createUserIdentity(apiKey, walletAddress, environment = 'PROD') {
81
116
  domain,
82
117
  };
83
118
  }
119
+ /**
120
+ * Generate a unique user ID for Sentry from identity components.
121
+ * Priority: apiKeyHash > wallet > fingerprint > session
122
+ *
123
+ * @param identity - User identity object
124
+ * @returns Prefixed user ID string
125
+ */
84
126
  function getUserId(identity) {
85
127
  if (identity.domain) {
86
128
  return `domain:${identity.domain}`;
@@ -1 +1,6 @@
1
- export declare const SDK_VERSION = "8.3.1";
1
+ /**
2
+ * AUTO-GENERATED FILE - DO NOT EDIT
3
+ * Generated during publish from package.json version
4
+ * This file is gitignored and created at publish time
5
+ */
6
+ export declare const SDK_VERSION = "8.5.0";
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = '8.3.1';
4
+ /**
5
+ * AUTO-GENERATED FILE - DO NOT EDIT
6
+ * Generated during publish from package.json version
7
+ * This file is gitignored and created at publish time
8
+ */
9
+ exports.SDK_VERSION = '8.5.0';
5
10
  //# sourceMappingURL=version.js.map
@@ -13,6 +13,9 @@ async function verifyInfuraKey(key) {
13
13
  return true;
14
14
  }
15
15
  async function verifyAugustKey(key) {
16
+ // Fast path: no key means no verification possible. Returning false here
17
+ // preserves the historical contract (`init()` throws a generic "API key is invalid")
18
+ // and avoids letting an AUTH_MISSING_KEY error bubble up from the fetcher.
16
19
  if (!key)
17
20
  return false;
18
21
  try {
@@ -20,6 +23,8 @@ async function verifyAugustKey(key) {
20
23
  return verify.status === 200;
21
24
  }
22
25
  catch {
26
+ // Network errors, timeouts, and any future thrown auth errors all
27
+ // resolve to "key not verified" here. Callers handle this as a boolean.
23
28
  return false;
24
29
  }
25
30
  }
@@ -11,31 +11,106 @@ interface IMonitoring extends IWSMonitorHeaders {
11
11
  env?: IEnv;
12
12
  }
13
13
  export interface IAugustBase {
14
+ /**
15
+ * Identifier-shaped name for the integrating application. Required.
16
+ *
17
+ * Pick a stable, kebab-case slug that identifies your product (e.g.
18
+ * `"acme-trader"`, `"my-defi-app"`). The SDK includes it on outbound
19
+ * analytics events so August Digital can see who's hitting which methods
20
+ * and reach out about breaking changes or critical bugs.
21
+ *
22
+ * Despite the friendly `appName` label, the value is used as a Sentry
23
+ * tag and HTTP header, so it must be identifier-shaped:
24
+ * 3–64 characters, `[a-zA-Z0-9._-]` only. Use a slug ("acme-trader"),
25
+ * not a display name ("Acme Trader").
26
+ *
27
+ * @throws Throws synchronously from the constructor if missing or empty.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const sdk = new AugustSDK({
32
+ * appName: 'acme-trader',
33
+ * providers: { 1: 'https://...' },
34
+ * keys: { august: '...' },
35
+ * });
36
+ * ```
37
+ */
14
38
  appName: string;
15
39
  providers?: IProvidersConfig;
16
40
  solana?: ISolanaConfig;
17
41
  keys: IKeys;
18
42
  monitoring?: IMonitoring;
43
+ /** Analytics configuration. Enabled by default (opt-out model). */
19
44
  analytics?: IAnalyticsConfig;
45
+ /**
46
+ * Best-effort npm-registry version check. Enabled by default in
47
+ * non-production environments; never runs in `NODE_ENV=production`.
48
+ * Set `enabled: false` to disable entirely (or set the
49
+ * `AUGUST_SDK_DISABLE_VERSION_CHECK` env var).
50
+ */
20
51
  versionCheck?: IVersionCheckConfig;
52
+ /**
53
+ * Default request timeout (in milliseconds) for backend API calls made by
54
+ * this SDK instance. Falls back to the SDK's compiled-in
55
+ * `REQUEST_TIMEOUT_MS` (90 s) when omitted.
56
+ *
57
+ * Per-call `timeoutMs` (when threaded through to the fetcher) still wins
58
+ * over this value. Setting this only changes the default that's used when
59
+ * no per-call value is supplied.
60
+ *
61
+ * Note: this is a process-global override on the underlying fetcher
62
+ * helpers, so the last `AugustSDK` instantiated wins if you create several
63
+ * with different timeouts in the same process.
64
+ */
21
65
  timeoutMs?: number;
22
66
  }
23
67
  interface IActiveNetwork {
24
68
  chainId: IChainId;
25
69
  rpcUrl: string;
26
70
  }
71
+ /**
72
+ * Base class providing core SDK functionality including provider management,
73
+ * network switching, and authentication state.
74
+ */
27
75
  export declare class AugustBase {
28
76
  keys: IKeys;
29
77
  monitoring: IMonitoring;
30
78
  authorized: boolean;
31
79
  activeNetwork?: IActiveNetwork;
32
80
  providers: IProvidersConfig;
81
+ /** Validated app-name slug from the constructor. */
33
82
  appName: string;
83
+ /**
84
+ * Initialize base SDK with provider configuration and API keys.
85
+ * Sets up the first provider as the active network by default.
86
+ *
87
+ * @throws If `appName` is missing, malformed, or out of the allowed
88
+ * length range — see {@link IAugustBase.appName}.
89
+ */
34
90
  constructor({ appName, providers, keys, monitoring, analytics, versionCheck, timeoutMs, }: IAugustBase);
91
+ /**
92
+ * Verify API keys and authorize SDK usage.
93
+ * TODO: initialize class with appropriate keys and verify august key
94
+ */
35
95
  init(): Promise<void>;
96
+ /**
97
+ * Return the active network or throw a clear error.
98
+ * Use this in methods that require an EVM provider.
99
+ */
36
100
  protected requireActiveNetwork(): IActiveNetwork;
101
+ /**
102
+ * Switch the active blockchain network.
103
+ * Updates both chain ID and RPC URL for subsequent operations.
104
+ */
37
105
  switchNetwork(chainId: IChainId): void;
106
+ /**
107
+ * Set active wallet address and update monitoring headers.
108
+ * Preserves existing environment setting.
109
+ */
38
110
  updateWallet(address: IAddress): void;
111
+ /**
112
+ * Remove wallet address from SDK state and monitoring headers.
113
+ */
39
114
  clearWallet(): void;
40
115
  }
41
116
  export {};
@@ -6,6 +6,19 @@ const logger_1 = require("./logger");
6
6
  const analytics_1 = require("./analytics");
7
7
  const version_check_1 = require("./version-check");
8
8
  const fetcher_1 = require("./fetcher");
9
+ /**
10
+ * Validate an appName at SDK construction time.
11
+ *
12
+ * Rules (kept intentionally narrow so the value is safe to use as a Sentry
13
+ * tag, an HTTP header value, and a filesystem-safe identifier — this is
14
+ * why we accept slugs only, not display names):
15
+ * - non-empty after trim
16
+ * - 3..64 characters
17
+ * - only `[a-zA-Z0-9._-]`
18
+ *
19
+ * Throws a descriptive Error that names the failed rule and includes a
20
+ * remediation hint pointing at the docs link.
21
+ */
9
22
  function validateAppName(value) {
10
23
  const docsHint = 'See https://docs.augustdigital.io/developers/typescript-sdk#app-name';
11
24
  if (typeof value !== 'string' || value.trim().length === 0) {
@@ -20,15 +33,31 @@ function validateAppName(value) {
20
33
  }
21
34
  return trimmed;
22
35
  }
36
+ /**
37
+ * Base class providing core SDK functionality including provider management,
38
+ * network switching, and authentication state.
39
+ */
23
40
  class AugustBase {
41
+ /**
42
+ * Initialize base SDK with provider configuration and API keys.
43
+ * Sets up the first provider as the active network by default.
44
+ *
45
+ * @throws If `appName` is missing, malformed, or out of the allowed
46
+ * length range — see {@link IAugustBase.appName}.
47
+ */
24
48
  constructor({ appName, providers = {}, keys, monitoring, analytics, versionCheck, timeoutMs, }) {
25
49
  this.monitoring = {
26
50
  'x-user-id': undefined,
27
51
  'x-environment': undefined,
28
52
  };
53
+ // Validate first so the failure mode is a clear, actionable error before
54
+ // any provider / analytics side effects run.
29
55
  this.appName = validateAppName(appName);
56
+ // TODO: change this to false later when august key is required
30
57
  this.authorized = true;
31
58
  this.providers = providers;
59
+ // Set active network from the first provider (if any).
60
+ // An empty providers map is valid for backend-only chains (e.g. Stellar).
32
61
  if (Object.keys(providers).length > 0) {
33
62
  this.activeNetwork = {
34
63
  chainId: Number(Object.keys(providers)[0]),
@@ -36,18 +65,28 @@ class AugustBase {
36
65
  };
37
66
  }
38
67
  this.keys = keys;
68
+ // Set environment (defaults to PROD for safety)
39
69
  const environment = monitoring?.env || monitoring?.['x-environment'] || 'PROD';
40
70
  this.monitoring = {
41
71
  ...monitoring,
42
72
  'x-environment': environment,
43
73
  };
74
+ // Set dev mode for logging (only true if explicitly set to DEV)
44
75
  logger_1.Logger.setDevMode(environment === 'DEV');
76
+ // Initialize analytics (pass API key for hashed identification + the
77
+ // appName so events can be filtered by consuming application).
45
78
  (0, analytics_1.initializeSentry)(analytics ?? { enabled: true }, environment, monitoring?.['x-user-id'], keys?.august, this.appName);
79
+ // Best-effort version nudge — fire-and-forget, never blocks init, no
80
+ // network call in production. See `core/version-check.ts` for details.
46
81
  (0, version_check_1.runVersionCheck)(versionCheck);
47
82
  if (typeof timeoutMs === 'number') {
48
83
  (0, fetcher_1.setSdkRequestTimeout)(timeoutMs);
49
84
  }
50
85
  }
86
+ /**
87
+ * Verify API keys and authorize SDK usage.
88
+ * TODO: initialize class with appropriate keys and verify august key
89
+ */
51
90
  async init() {
52
91
  const [augustCheck] = await Promise.all([
53
92
  (0, auth_1.verifyAugustKey)(this.keys?.august),
@@ -58,6 +97,10 @@ class AugustBase {
58
97
  logger_1.Logger.log.info('init', 'August Digital SDK successfully initialized');
59
98
  return;
60
99
  }
100
+ /**
101
+ * Return the active network or throw a clear error.
102
+ * Use this in methods that require an EVM provider.
103
+ */
61
104
  requireActiveNetwork() {
62
105
  if (!this.activeNetwork) {
63
106
  throw new Error('No active network configured. This operation requires an EVM provider. ' +
@@ -65,6 +108,10 @@ class AugustBase {
65
108
  }
66
109
  return this.activeNetwork;
67
110
  }
111
+ /**
112
+ * Switch the active blockchain network.
113
+ * Updates both chain ID and RPC URL for subsequent operations.
114
+ */
68
115
  switchNetwork(chainId) {
69
116
  if (!this.providers[chainId]) {
70
117
  throw new Error(`No provider configured for chainId ${chainId}. Available chains: ${Object.keys(this.providers).join(', ')}`);
@@ -74,6 +121,10 @@ class AugustBase {
74
121
  rpcUrl: this.providers[chainId],
75
122
  };
76
123
  }
124
+ /**
125
+ * Set active wallet address and update monitoring headers.
126
+ * Preserves existing environment setting.
127
+ */
77
128
  updateWallet(address) {
78
129
  if (!address)
79
130
  return;
@@ -82,8 +133,12 @@ class AugustBase {
82
133
  ...this.monitoring,
83
134
  'x-user-id': lowercasedAddress,
84
135
  };
136
+ // Update analytics user identity
85
137
  (0, analytics_1.updateUser)(lowercasedAddress, this.monitoring['x-environment']);
86
138
  }
139
+ /**
140
+ * Remove wallet address from SDK state and monitoring headers.
141
+ */
87
142
  clearWallet() {
88
143
  if (this.monitoring) {
89
144
  this.monitoring = {
@@ -91,6 +146,7 @@ class AugustBase {
91
146
  'x-user-id': undefined,
92
147
  };
93
148
  }
149
+ // Clear wallet from analytics user identity
94
150
  (0, analytics_1.clearUser)();
95
151
  }
96
152
  }
@@ -1,4 +1,9 @@
1
1
  import { LRUCache } from 'lru-cache';
2
+ /**
3
+ * Process-wide LRU used by core helpers for memoizing RPC / fetch results.
4
+ * Kept in a leaf module so importers don't pull in the broader `core/fetcher.ts`
5
+ * graph (which would cycle through `core/helpers/web3.ts`).
6
+ */
2
7
  export declare const CACHE: LRUCache<string, any, unknown>;
3
8
  export declare const getSafeCache: <T>(key: string) => Promise<T | null>;
4
9
  export declare const setSafeCache: <T>(key: string, value: T) => Promise<void>;
package/lib/core/cache.js CHANGED
@@ -2,6 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setSafeCache = exports.getSafeCache = exports.CACHE = void 0;
4
4
  const lru_cache_1 = require("lru-cache");
5
+ /**
6
+ * Process-wide LRU used by core helpers for memoizing RPC / fetch results.
7
+ * Kept in a leaf module so importers don't pull in the broader `core/fetcher.ts`
8
+ * graph (which would cycle through `core/helpers/web3.ts`).
9
+ */
10
+ // biome-ignore lint/suspicious/noExplicitAny: shared heterogeneous cache keyed by string; a concrete value type would force casts at every call site and risk a dependency cycle through core/helpers/web3.ts.
5
11
  exports.CACHE = new lru_cache_1.LRUCache({
6
12
  max: 1000,
7
13
  ttl: 1000 * 60 * 60 * 24,
@@ -1,9 +1,21 @@
1
+ /**
2
+ * Adapter Configurations for Vaults
3
+ *
4
+ * This file contains configurations for vaults that support deposits with alternative tokens
5
+ * through wrapper contracts, swap adapters, or native token deposits.
6
+ */
1
7
  import { IVaultAdapterConfig, IAddress } from '../../types';
8
+ /**
9
+ * Pool/Vault names for adapter routing
10
+ */
2
11
  export declare const POOL_NAMES: {
3
12
  readonly ETH_TREEHOUSE_GROWTH: "Treehouse Growth";
4
13
  readonly AVAX_AVAX: "AVAX Strategy";
5
14
  readonly ETH_KELP_TAC_RSETH: "Kelp TAC rsETH";
6
15
  };
16
+ /**
17
+ * Adapter ABIs for wrapper contracts
18
+ */
7
19
  export declare const ADAPTER_ABIS: {
8
20
  readonly NATIVE_DEPOSIT_AVAX: readonly [{
9
21
  readonly inputs: readonly [];
@@ -85,4 +97,7 @@ export declare const ADAPTER_ABIS: {
85
97
  readonly type: "function";
86
98
  }];
87
99
  };
100
+ /**
101
+ * Vault adapter configurations mapping vault addresses to their adapter settings
102
+ */
88
103
  export declare const VAULT_ADAPTER_CONFIGS: Record<IAddress, IVaultAdapterConfig>;
@@ -1,12 +1,24 @@
1
1
  "use strict";
2
+ /**
3
+ * Adapter Configurations for Vaults
4
+ *
5
+ * This file contains configurations for vaults that support deposits with alternative tokens
6
+ * through wrapper contracts, swap adapters, or native token deposits.
7
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.VAULT_ADAPTER_CONFIGS = exports.ADAPTER_ABIS = exports.POOL_NAMES = void 0;
4
10
  const ethers_1 = require("ethers");
11
+ /**
12
+ * Pool/Vault names for adapter routing
13
+ */
5
14
  exports.POOL_NAMES = {
6
15
  ETH_TREEHOUSE_GROWTH: 'Treehouse Growth',
7
16
  AVAX_AVAX: 'AVAX Strategy',
8
17
  ETH_KELP_TAC_RSETH: 'Kelp TAC rsETH',
9
18
  };
19
+ /**
20
+ * Adapter ABIs for wrapper contracts
21
+ */
10
22
  exports.ADAPTER_ABIS = {
11
23
  NATIVE_DEPOSIT_AVAX: [
12
24
  {
@@ -97,13 +109,18 @@ exports.ADAPTER_ABIS = {
97
109
  },
98
110
  ],
99
111
  };
112
+ /**
113
+ * Vault adapter configurations mapping vault addresses to their adapter settings
114
+ */
100
115
  exports.VAULT_ADAPTER_CONFIGS = {
116
+ // Multi-asset vault with view adapter
101
117
  '0x18EE038C114a07f4B08b420fb1E4149a4F357249': {
102
118
  viewAdapter: '0x72f3cf0d87e9688fad77711d02d86c68334fb275',
103
119
  lpTokenAddress: '0xeF866BfbD0eEc6D6b42C37d8acC0D5fd26828376',
104
120
  isNativeTokenDeposit: false,
105
121
  isWrappedTokenDeposit: false,
106
122
  },
123
+ // BTC multi-token vault with Paraswap bridge
107
124
  '0x8AcA0841993ef4C87244d519166e767f49362C21': {
108
125
  isNativeTokenDeposit: false,
109
126
  isWrappedTokenDeposit: false,
@@ -112,11 +129,12 @@ exports.VAULT_ADAPTER_CONFIGS = {
112
129
  bridgeId: 2,
113
130
  abi: [],
114
131
  tokens: [
115
- '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
116
- '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf',
132
+ '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', // WBTC
133
+ '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf', // cbBTC
117
134
  '0x18084fbA666a33d37592fA2633fD49a74DD93a88',
118
135
  ],
119
136
  },
137
+ // AVAX native deposit vault
120
138
  '0xB2bFb52cfc40584AC4e9e2B36a5B8d6554A56e0b': {
121
139
  isNativeTokenDeposit: true,
122
140
  isWrappedTokenDeposit: false,
@@ -124,10 +142,11 @@ exports.VAULT_ADAPTER_CONFIGS = {
124
142
  wrapperAddress: '0xb2C57614B93c41A7Ec3B91980C0Bb7453904c6e8',
125
143
  abi: exports.ADAPTER_ABIS.NATIVE_DEPOSIT_AVAX,
126
144
  tokens: [
127
- '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7',
145
+ '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7', // WAVAX
128
146
  ethers_1.ZeroAddress,
129
147
  ],
130
148
  },
149
+ // ETH Treehouse Growth - native deposit with referral
131
150
  '0x5Fde59415625401278c4d41C6beFCe3790eb357f': {
132
151
  isNativeTokenDeposit: true,
133
152
  isWrappedTokenDeposit: true,
@@ -136,11 +155,12 @@ exports.VAULT_ADAPTER_CONFIGS = {
136
155
  wrapperAddress: '0x6B6b27F08B84c186626D5A64614B5192a8ef71a9',
137
156
  abi: exports.ADAPTER_ABIS.NATIVE_DEPOSIT_ETH_WITH_REFERRAL,
138
157
  tokens: [
139
- '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
140
- '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
158
+ '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0', // wstETH
159
+ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
141
160
  ethers_1.ZeroAddress,
142
161
  ],
143
162
  },
163
+ // Kelp TAC rsETH - native deposit with custom adapter
144
164
  '0x419386E3Ef42368e602720CC458e00c0B28c47A7': {
145
165
  isNativeTokenDeposit: true,
146
166
  isWrappedTokenDeposit: true,
@@ -150,9 +170,9 @@ exports.VAULT_ADAPTER_CONFIGS = {
150
170
  viewAdapter: '0x036676389e48133B63a802f8635AD39E752D375D',
151
171
  abi: exports.ADAPTER_ABIS.KELP_RSETH_ADAPTER,
152
172
  tokens: [
153
- '0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84',
154
- '0xA35b1B31Ce002FBF2058D22F30f95D405200A15b',
155
- '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
173
+ '0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84', // stETH
174
+ '0xA35b1B31Ce002FBF2058D22F30f95D405200A15b', // ETHx
175
+ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
156
176
  ethers_1.ZeroAddress,
157
177
  ],
158
178
  },
@@ -1,4 +1,11 @@
1
- import { IAddress, VaultAddress } from '../../types';
1
+ /**
2
+ * August Digital
3
+ */
4
+ import type { IAddress, VaultAddress } from '../../types';
5
+ /**
6
+ * Request timeout in milliseconds.
7
+ * Set to 90 seconds to accommodate slow API responses.
8
+ */
2
9
  export declare const REQUEST_TIMEOUT_MS = 90000;
3
10
  export declare const PRICE_SERVER_URL = "https://prices.augustdigital.io";
4
11
  export declare const WEBSERVER_URL: {
@@ -72,6 +79,10 @@ export declare const WEBSERVER_ENDPOINTS: {
72
79
  vaults: {
73
80
  pendingRedemptions: (vaultAddress: IAddress) => string;
74
81
  };
82
+ pnl: {
83
+ unrealizedHistory: (vaultAddress: VaultAddress, limit?: number) => string;
84
+ unrealizedLatest: string;
85
+ };
75
86
  };
76
87
  upshift: {
77
88
  vaults: {
@@ -1,7 +1,14 @@
1
1
  "use strict";
2
+ /**
3
+ * August Digital
4
+ */
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.DEFAULT_FETCH_OPTIONS = exports.WEBSERVER_ENDPOINTS = exports.WEBSERVER_URL = exports.PRICE_SERVER_URL = exports.REQUEST_TIMEOUT_MS = void 0;
4
7
  const ethers_1 = require("ethers");
8
+ /**
9
+ * Request timeout in milliseconds.
10
+ * Set to 90 seconds to accommodate slow API responses.
11
+ */
5
12
  exports.REQUEST_TIMEOUT_MS = 90000;
6
13
  exports.PRICE_SERVER_URL = 'https://prices.augustdigital.io';
7
14
  exports.WEBSERVER_URL = {
@@ -75,12 +82,17 @@ exports.WEBSERVER_ENDPOINTS = {
75
82
  vaults: {
76
83
  pendingRedemptions: (vaultAddress) => `/vaults/${vaultAddress}/pending-redemptions`,
77
84
  },
85
+ pnl: {
86
+ unrealizedHistory: (vaultAddress, limit) => `/upshift/unrealized_pnl?vault_address=${vaultAddress}${limit !== undefined ? `&limit=${limit}` : ''}`,
87
+ unrealizedLatest: '/upshift/unrealized_pnl/latest',
88
+ },
78
89
  },
79
90
  upshift: {
80
91
  vaults: {
81
92
  metadata: `/api/sdk/vaults-metadata`,
82
93
  },
83
94
  },
95
+ // TODO: add remaining endpoints
84
96
  };
85
97
  exports.DEFAULT_FETCH_OPTIONS = {
86
98
  method: 'GET',
@@ -1,8 +1,54 @@
1
1
  import { IAddress } from '../../types';
2
+ /**
3
+ * Address of the `SwapRouter` periphery contract on each supported chain.
4
+ *
5
+ * Missing keys mean no SwapRouter is deployed on that chain — callers
6
+ * should fall back to legacy adapter paths.
7
+ *
8
+ * @see {@link getSwapRouterAddress} for the typed lookup helper.
9
+ */
2
10
  export declare const SWAP_ROUTER_ADDRESSES: Readonly<Record<number, IAddress>>;
11
+ /**
12
+ * Vault addresses registered on a `SwapRouter` via `enableVault`. The
13
+ * presence of a vault here is the signal to route its deposits through the
14
+ * SwapRouter rather than the legacy adapter path.
15
+ *
16
+ * Entries mirror the on-chain `vaultInfo[addr].referenceAsset != 0` state of
17
+ * the `SwapRouter` deployment. Verify against the deployed contract before
18
+ * adding a new entry — a vault that is not registered on-chain will revert
19
+ * with `InvalidVault` at deposit time.
20
+ *
21
+ * Lowercase comparison is required when checking — use
22
+ * {@link vaultUsesSwapRouter} rather than reading this set directly.
23
+ */
3
24
  export declare const VAULTS_USING_SWAP_ROUTER: ReadonlySet<string>;
25
+ /**
26
+ * 32-byte origin codes registered on the `SwapRouter` via `addOrigin`.
27
+ * Drives origin/referral-fee accrual. The on-chain admin must register a
28
+ * code before it can be used — calls with an unknown code revert with
29
+ * `InvalidOrigin`.
30
+ *
31
+ * `default` is the all-zero sentinel — the SwapRouter treats it as "no
32
+ * origin fee" and skips the origin-fee transfer.
33
+ */
4
34
  export declare const ORIGIN_CODES: {
35
+ /** All-zero sentinel — no origin fee. */
5
36
  readonly default: `0x${string}`;
6
37
  };
38
+ /**
39
+ * Maximum number of swap legs the contract accepts in a single
40
+ * `swapAndDeposit` call. Mirrors the on-chain `MAX_SWAPS` constant; reading
41
+ * the on-chain value at call time would add an RPC for no gain.
42
+ *
43
+ * Kept here so the SDK can reject oversize inputs at the boundary rather
44
+ * than wait for the on-chain `TooManySwaps` revert.
45
+ */
7
46
  export declare const SWAP_ROUTER_MAX_SWAPS = 9;
47
+ /**
48
+ * Wrapped-native ERC-20 per chain that has a SwapRouter deployment. Mirrors
49
+ * the on-chain `wrappedNativeTokenAddress()` view to avoid an extra RPC on
50
+ * every dispatch. Used to validate that native-token deposits target a
51
+ * vault whose reference asset is the wrapped native — the only configuration
52
+ * the contract's `depositNativeToken` / `swapAndDepositNativeToken` accept.
53
+ */
8
54
  export declare const SWAP_ROUTER_WRAPPED_NATIVE: Readonly<Record<number, IAddress>>;