@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
@@ -1,3 +1,6 @@
1
+ /**
2
+ * The default Slack webhook URL for logging errors.
3
+ */
1
4
  export declare const DEFAULT_SLACK_WEBHOOK_URL = "T04CM84GAV6/B0A2DS3ST8C/FLtOA3Jna3FN7UO4DoGxHfhG";
2
5
  declare function error(options: {
3
6
  title: string;
@@ -4,6 +4,9 @@ exports.SLACK = exports.DEFAULT_SLACK_WEBHOOK_URL = void 0;
4
4
  const core_1 = require("../helpers/core");
5
5
  const explorer_link_1 = require("../helpers/explorer-link");
6
6
  const sanitize_1 = require("../analytics/sanitize");
7
+ /**
8
+ * The default Slack webhook URL for logging errors.
9
+ */
7
10
  exports.DEFAULT_SLACK_WEBHOOK_URL = 'T04CM84GAV6/B0A2DS3ST8C/FLtOA3Jna3FN7UO4DoGxHfhG';
8
11
  function error(options) {
9
12
  const { title, error, poolAddress, chainId, slackWebookUrl, address } = options;
@@ -1,4 +1,10 @@
1
1
  import { IVaultMetadata } from '../types';
2
+ /**
3
+ * Fetch vault metadata from the upshift API.
4
+ * Returns metadata including symbol, subgraph URL, and address for all vaults.
5
+ * @param options Request options including headers
6
+ * @returns Vault metadata object keyed by lowercase symbol
7
+ */
2
8
  export declare function fetchVaultMetadata(opts?: {
3
9
  options?: {
4
10
  headers?: Record<string, string>;
@@ -4,6 +4,12 @@ exports.fetchVaultMetadata = fetchVaultMetadata;
4
4
  const cache_1 = require("./cache");
5
5
  const core_1 = require("./constants/core");
6
6
  const logger_1 = require("./logger");
7
+ /**
8
+ * Fetch vault metadata from the upshift API.
9
+ * Returns metadata including symbol, subgraph URL, and address for all vaults.
10
+ * @param options Request options including headers
11
+ * @returns Vault metadata object keyed by lowercase symbol
12
+ */
7
13
  async function fetchVaultMetadata(opts) {
8
14
  const { options } = opts || {};
9
15
  try {
@@ -1,6 +1,58 @@
1
+ /**
2
+ * Best-effort version check that nudges integrators when a newer
3
+ * `@augustdigital/sdk` is available on npm.
4
+ *
5
+ * Design constraints (all kept narrow on purpose):
6
+ * - **No network call in production builds.** Most integrators ship the
7
+ * SDK to end users in the browser; surprise registry pings on user page
8
+ * loads are unacceptable. The check only fires when
9
+ * `NODE_ENV !== 'production'` (i.e. local dev / CI environments).
10
+ * - **Opt-out is supported in two places.** `AUGUST_SDK_DISABLE_VERSION_CHECK`
11
+ * env var (set in CI to silence noise) or `versionCheck: { enabled: false }`
12
+ * on the SDK constructor (programmatic opt-out, e.g. in your own libs
13
+ * that wrap the SDK).
14
+ * - **Fire-and-forget; never blocks construction.** The SDK constructor
15
+ * must return synchronously. We schedule the check on the microtask
16
+ * queue, abort after 5s, and swallow every error.
17
+ * - **Once per session.** A module-level guard prevents repeated registry
18
+ * hits when callers spin up multiple `AugustSDK` instances.
19
+ * - **No new dependency.** Semver comparison is a tiny hand-rolled helper
20
+ * rather than pulling in the `semver` package.
21
+ */
22
+ /**
23
+ * Compare two numeric-dotted version strings. Returns:
24
+ * - positive integer if `a > b`
25
+ * - negative integer if `a < b`
26
+ * - 0 if equal
27
+ *
28
+ * Pre-release suffixes (`-beta`, `-rc.1`) are stripped before comparison —
29
+ * we always treat any pre-release as equal to its base version. That keeps
30
+ * the comparison logic small and avoids false positives where an integrator
31
+ * on `4.27.4-beta.0` would otherwise be told to upgrade to the stable
32
+ * `4.27.3` they pre-released past.
33
+ */
1
34
  export declare function compareSemver(a: string, b: string): number;
35
+ /**
36
+ * Configuration knob exposed on `IAugustBase.versionCheck`. Defaulting to
37
+ * enabled keeps the nudge in front of integrators who haven't read the docs;
38
+ * setting `enabled: false` is the explicit opt-out for libraries that wrap
39
+ * the SDK and want their own update strategy.
40
+ */
2
41
  export interface IVersionCheckConfig {
42
+ /** Set to `false` to disable the registry check entirely. Default: `true`. */
3
43
  enabled?: boolean;
4
44
  }
45
+ /**
46
+ * Kick off a best-effort version check. Always returns synchronously.
47
+ *
48
+ * @param config - Optional config from `IAugustBase.versionCheck`
49
+ */
5
50
  export declare function runVersionCheck(config?: IVersionCheckConfig): void;
51
+ /**
52
+ * Testing hook — resets the module-level guard so the check can run again
53
+ * in a fresh test case. Not part of the public API surface; kept here so
54
+ * unit tests don't have to monkey-patch internals.
55
+ *
56
+ * @internal
57
+ */
6
58
  export declare function _resetVersionCheckForTests(): void;
@@ -1,14 +1,46 @@
1
1
  "use strict";
2
+ /**
3
+ * Best-effort version check that nudges integrators when a newer
4
+ * `@augustdigital/sdk` is available on npm.
5
+ *
6
+ * Design constraints (all kept narrow on purpose):
7
+ * - **No network call in production builds.** Most integrators ship the
8
+ * SDK to end users in the browser; surprise registry pings on user page
9
+ * loads are unacceptable. The check only fires when
10
+ * `NODE_ENV !== 'production'` (i.e. local dev / CI environments).
11
+ * - **Opt-out is supported in two places.** `AUGUST_SDK_DISABLE_VERSION_CHECK`
12
+ * env var (set in CI to silence noise) or `versionCheck: { enabled: false }`
13
+ * on the SDK constructor (programmatic opt-out, e.g. in your own libs
14
+ * that wrap the SDK).
15
+ * - **Fire-and-forget; never blocks construction.** The SDK constructor
16
+ * must return synchronously. We schedule the check on the microtask
17
+ * queue, abort after 5s, and swallow every error.
18
+ * - **Once per session.** A module-level guard prevents repeated registry
19
+ * hits when callers spin up multiple `AugustSDK` instances.
20
+ * - **No new dependency.** Semver comparison is a tiny hand-rolled helper
21
+ * rather than pulling in the `semver` package.
22
+ */
2
23
  Object.defineProperty(exports, "__esModule", { value: true });
3
24
  exports.compareSemver = compareSemver;
4
25
  exports.runVersionCheck = runVersionCheck;
5
26
  exports._resetVersionCheckForTests = _resetVersionCheckForTests;
27
+ /** Module-level guard — flips to true after the first attempt. */
6
28
  let hasRunCheck = false;
29
+ /** Public package name on npm — also the registry-API path component. */
7
30
  const NPM_PACKAGE = '@augustdigital/sdk';
8
31
  const REGISTRY_URL = `https://registry.npmjs.org/${NPM_PACKAGE}/latest`;
32
+ /** Timeout for the registry request. 5s is generous; faster failures stay silent. */
9
33
  const REQUEST_TIMEOUT_MS = 5000;
34
+ /**
35
+ * Read the current installed SDK version from the generated `version.ts`
36
+ * shim. Returns `null` when running from source (the file is gitignored and
37
+ * only emitted at publish time) — that's the signal to skip the check, since
38
+ * we have nothing meaningful to compare against.
39
+ */
10
40
  function getInstalledVersion() {
11
41
  try {
42
+ // The require path is resolved relative to the compiled .js location,
43
+ // so it picks up `core/analytics/version.js` when it exists.
12
44
  const mod = require('./analytics/version');
13
45
  const v = mod.SDK_VERSION;
14
46
  if (!v || v === 'development')
@@ -19,6 +51,12 @@ function getInstalledVersion() {
19
51
  return null;
20
52
  }
21
53
  }
54
+ /**
55
+ * Read an environment variable in a way that's safe in both Node and the
56
+ * browser. `process` is typically undefined in browser bundles; even when
57
+ * it's stubbed by a bundler, `process.env` may be a frozen object that
58
+ * throws on missing-key access in some setups — try/catch covers that too.
59
+ */
22
60
  function readEnv(name) {
23
61
  try {
24
62
  if (typeof process !== 'undefined' && process.env) {
@@ -26,9 +64,22 @@ function readEnv(name) {
26
64
  }
27
65
  }
28
66
  catch {
67
+ // Bundlers occasionally throw on `process.env` access. Treat as unset.
29
68
  }
30
69
  return undefined;
31
70
  }
71
+ /**
72
+ * Compare two numeric-dotted version strings. Returns:
73
+ * - positive integer if `a > b`
74
+ * - negative integer if `a < b`
75
+ * - 0 if equal
76
+ *
77
+ * Pre-release suffixes (`-beta`, `-rc.1`) are stripped before comparison —
78
+ * we always treat any pre-release as equal to its base version. That keeps
79
+ * the comparison logic small and avoids false positives where an integrator
80
+ * on `4.27.4-beta.0` would otherwise be told to upgrade to the stable
81
+ * `4.27.3` they pre-released past.
82
+ */
32
83
  function compareSemver(a, b) {
33
84
  const stripPre = (v) => v.split('-')[0];
34
85
  const parse = (v) => stripPre(v)
@@ -48,25 +99,40 @@ function compareSemver(a, b) {
48
99
  }
49
100
  return 0;
50
101
  }
102
+ /**
103
+ * Kick off a best-effort version check. Always returns synchronously.
104
+ *
105
+ * @param config - Optional config from `IAugustBase.versionCheck`
106
+ */
51
107
  function runVersionCheck(config) {
52
108
  if (hasRunCheck)
53
109
  return;
54
110
  hasRunCheck = true;
55
111
  if (config?.enabled === false)
56
112
  return;
113
+ // Skip in production builds. We treat *anything* other than "production"
114
+ // as eligible (development, test, staging) — those are the envs where a
115
+ // console warning is helpful, not annoying.
57
116
  if (readEnv('NODE_ENV') === 'production')
58
117
  return;
118
+ // Explicit env opt-out (useful in CI where the console output is noise).
59
119
  if (readEnv('AUGUST_SDK_DISABLE_VERSION_CHECK'))
60
120
  return;
61
121
  const installed = getInstalledVersion();
122
+ // No version file = local development from source. Nothing to compare.
62
123
  if (!installed)
63
124
  return;
125
+ // `fetch` is guaranteed in Node 18+ and all modern browsers, but the SDK
126
+ // supports older Node deployments via the React/Telegram bot integration.
127
+ // Gracefully no-op when missing.
64
128
  if (typeof fetch !== 'function')
65
129
  return;
66
130
  const controller = typeof AbortController !== 'undefined' ? new AbortController() : null;
67
131
  const timeoutId = controller
68
132
  ? setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS)
69
133
  : null;
134
+ // Run on the microtask queue so construction stays synchronous. The void
135
+ // expression discards the promise — we explicitly don't await it.
70
136
  void (async () => {
71
137
  try {
72
138
  const res = await fetch(REGISTRY_URL, {
@@ -80,6 +146,11 @@ function runVersionCheck(config) {
80
146
  if (!latest)
81
147
  return;
82
148
  if (compareSemver(latest, installed) > 0) {
149
+ // Use console.warn so the message is visible at the default log
150
+ // level in most setups, but distinguishable from real errors. This is
151
+ // an integrator-facing nudge — Logger.log.warn would make it a
152
+ // prod-silent breadcrumb, defeating the purpose.
153
+ // biome-ignore lint/suspicious/noConsole: integrator-facing version nudge must surface in every environment; Logger.log.warn would make it a prod-silent breadcrumb.
83
154
  console.warn([
84
155
  `[${NPM_PACKAGE}] A newer version is available: ${installed} → ${latest}.`,
85
156
  `Run \`pnpm up ${NPM_PACKAGE}\` (or your package manager's equivalent) to update.`,
@@ -88,6 +159,9 @@ function runVersionCheck(config) {
88
159
  }
89
160
  }
90
161
  catch {
162
+ // Network failure, aborted request, malformed JSON, frozen
163
+ // `console.warn`, etc. — every failure path stays silent. The check
164
+ // is purely an integrator-experience hint; it must never surface.
91
165
  }
92
166
  finally {
93
167
  if (timeoutId)
@@ -95,6 +169,13 @@ function runVersionCheck(config) {
95
169
  }
96
170
  })();
97
171
  }
172
+ /**
173
+ * Testing hook — resets the module-level guard so the check can run again
174
+ * in a fresh test case. Not part of the public API surface; kept here so
175
+ * unit tests don't have to monkey-patch internals.
176
+ *
177
+ * @internal
178
+ */
98
179
  function _resetVersionCheckForTests() {
99
180
  hasRunCheck = false;
100
181
  }
@@ -1,11 +1,50 @@
1
+ /**
2
+ * Cross-Chain Vault Methods
3
+ *
4
+ * Implements LayerZero OVault cross-chain deposit and redemption operations.
5
+ * These functions are generic — callers provide their own ICrossChainVaultConfig
6
+ * rather than relying on hardcoded vault addresses.
7
+ *
8
+ * @module evm/methods/crossChainVault
9
+ */
1
10
  import type { IAddress } from '../../types';
2
11
  import type { ICrossChainVaultConfig, ICrossChainBuildRequest, ICrossChainBuildResult, ICrossChainDepositRequest, ICrossChainDepositResult, ICrossChainRedeemRequest, ICrossChainRedeemResult, IQuoteCrossChainDepositRequest, IQuoteCrossChainRedeemRequest, IQuoteCrossChainResult, CrossChainErrorType } from '../types/crossChain';
12
+ /**
13
+ * Build LayerZero OVault transaction inputs for cross-chain deposits and
14
+ * redemptions. Does NOT execute the transaction.
15
+ *
16
+ * Overridable defaults on `props`: `slippageBps` = 100 (range 1–10000),
17
+ * `feeBufferPercent` = 50% (added to LZ `nativeFee`),
18
+ * `hubLzComposeGasLimit` = 2_000_000n (multi-asset composed messages).
19
+ *
20
+ * @returns Transaction inputs or `{ success: false, error }`.
21
+ */
3
22
  export declare function buildCrossChainVaultTx(props: ICrossChainBuildRequest): Promise<ICrossChainBuildResult>;
23
+ /**
24
+ * Estimate fees and expected shares for a cross-chain deposit. The returned
25
+ * quote carries `quotedAt`/`expiresAt`; re-quote via {@link isQuoteStale}
26
+ * before submitting.
27
+ */
4
28
  export declare function quoteCrossChainDeposit(props: IQuoteCrossChainDepositRequest): Promise<IQuoteCrossChainResult | null>;
29
+ /**
30
+ * Estimate fees and expected assets for a cross-chain redeem. The returned
31
+ * quote carries `quotedAt`/`expiresAt`; re-quote via {@link isQuoteStale}
32
+ * before submitting.
33
+ */
5
34
  export declare function quoteCrossChainRedeem(props: IQuoteCrossChainRedeemRequest): Promise<IQuoteCrossChainResult | null>;
35
+ /**
36
+ * Returns `true` when the wallet's ERC-20 allowance is insufficient for the
37
+ * cross-chain operation. On RPC failure also returns `true` (defensive
38
+ * default — better a redundant approval than a downstream revert).
39
+ */
6
40
  export declare function needsCrossChainApproval(tokenAddress: IAddress, spenderAddress: IAddress, walletAddress: IAddress, amount: bigint, publicClient: {
7
41
  readContract: (args: unknown) => Promise<unknown>;
8
42
  }): Promise<boolean>;
43
+ /**
44
+ * Execute a token approval for a cross-chain operation.
45
+ *
46
+ * @returns Transaction hash of the approval
47
+ */
9
48
  export declare function approveCrossChain(tokenAddress: IAddress, spenderAddress: IAddress, amount: bigint, walletClient: {
10
49
  account: {
11
50
  address: string;
@@ -18,16 +57,67 @@ export declare function approveCrossChain(tokenAddress: IAddress, spenderAddress
18
57
  status: string;
19
58
  }>;
20
59
  }): Promise<string>;
60
+ /**
61
+ * Execute a cross-chain deposit via LayerZero OVault. Validates the source
62
+ * chain, ensures approval, estimates gas with a buffer, and waits for the
63
+ * on-chain receipt. Defaults: `slippageBps` 100, `feeBufferPercent` 50,
64
+ * `gasBufferPercent` 150 — all overridable on the request.
65
+ *
66
+ * @throws Error on unsupported chain, approval revert, gas-estimation
67
+ * failure, or on-chain revert.
68
+ */
21
69
  export declare function crossChainVaultDeposit(props: ICrossChainDepositRequest): Promise<ICrossChainDepositResult>;
70
+ /**
71
+ * Execute a cross-chain redemption via LayerZero OVault. User must be on the
72
+ * hub chain. Defaults: `slippageBps` 100, `feeBufferPercent` 50,
73
+ * `gasBufferPercent` 200 (compose calls under-estimate on mainnet),
74
+ * `minGasLimit` 5_000_000n — all overridable on the request.
75
+ */
22
76
  export declare function crossChainVaultRedeem(props: ICrossChainRedeemRequest): Promise<ICrossChainRedeemResult>;
77
+ /**
78
+ * Check if an error indicates a missing LayerZero peer configuration.
79
+ */
23
80
  export declare function isNoPeerError(errStr: string): boolean;
81
+ /**
82
+ * Classify a cross-chain contract error into a known error type.
83
+ */
24
84
  export declare function classifyCrossChainError(error: unknown): CrossChainErrorType;
85
+ /**
86
+ * Check if a user can deposit from their current chain.
87
+ */
25
88
  export declare function canDepositFromChain(config: ICrossChainVaultConfig, userChainId: number): boolean;
89
+ /**
90
+ * Check if a user can redeem from their current chain (must be hub).
91
+ */
26
92
  export declare function canRedeemFromChain(config: ICrossChainVaultConfig, userChainId: number): boolean;
93
+ /**
94
+ * Check if an operation is cross-chain (needs LayerZero).
95
+ *
96
+ * An operation is cross-chain when:
97
+ * - The user's chain differs from the hub chain, OR
98
+ * - The destination chain differs from the hub chain
99
+ * (e.g. deposit from hub but receive shares on a spoke)
100
+ */
27
101
  export declare function isCrossChainOperation(config: ICrossChainVaultConfig, userChainId: number, destinationChainId?: number): boolean;
102
+ /**
103
+ * Get all chain IDs that a vault supports (hub + all spokes).
104
+ */
28
105
  export declare function getAvailableChains(config: ICrossChainVaultConfig): number[];
106
+ /**
107
+ * Format a cross-chain error into a user-friendly message.
108
+ *
109
+ * Mirrors the `classifyCrossChainDepositError` from upshift-app but is
110
+ * generic enough for any SDK consumer.
111
+ */
29
112
  export declare function formatCrossChainError(errMsg: string): string;
113
+ /**
114
+ * Get the LayerZero Scan URL for tracking a cross-chain message.
115
+ */
30
116
  export declare function getLayerZeroScanUrl(txHash: string, testnet?: boolean): string;
117
+ /**
118
+ * Well-known LayerZero Endpoint IDs for common chains.
119
+ * SDK consumers can use these when building their ICrossChainVaultConfig.
120
+ */
31
121
  export declare const LAYERZERO_ENDPOINT_IDS: {
32
122
  readonly ETHEREUM: 30101;
33
123
  readonly ARBITRUM: 30110;