upshift-finance 1.0.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 (316) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -0
  3. package/lib/abis/AddressResolver.d.ts +28 -0
  4. package/lib/abis/AddressResolver.js +23 -0
  5. package/lib/abis/ChainlinkV3.d.ts +87 -0
  6. package/lib/abis/ChainlinkV3.js +117 -0
  7. package/lib/abis/ERC20.d.ts +168 -0
  8. package/lib/abis/ERC20.js +226 -0
  9. package/lib/abis/ERC20_Bytes32.d.ts +139 -0
  10. package/lib/abis/ERC20_Bytes32.js +196 -0
  11. package/lib/abis/ERC4626.d.ts +364 -0
  12. package/lib/abis/ERC4626.js +507 -0
  13. package/lib/abis/ERC721.d.ts +231 -0
  14. package/lib/abis/ERC721.js +321 -0
  15. package/lib/abis/FeeOracle.d.ts +120 -0
  16. package/lib/abis/FeeOracle.js +162 -0
  17. package/lib/abis/LendingPool.d.ts +1393 -0
  18. package/lib/abis/LendingPool.js +1807 -0
  19. package/lib/abis/LendingPoolV2.d.ts +1413 -0
  20. package/lib/abis/LendingPoolV2.js +1833 -0
  21. package/lib/abis/LendingPoolV3.d.ts +1677 -0
  22. package/lib/abis/LendingPoolV3.js +1160 -0
  23. package/lib/abis/Loan.d.ts +837 -0
  24. package/lib/abis/Loan.js +1080 -0
  25. package/lib/abis/MultiAssetNativeDepositWrapper.d.ts +137 -0
  26. package/lib/abis/MultiAssetNativeDepositWrapper.js +125 -0
  27. package/lib/abis/Multicall3.d.ts +30 -0
  28. package/lib/abis/Multicall3.js +97 -0
  29. package/lib/abis/OFT.d.ts +116 -0
  30. package/lib/abis/OFT.js +85 -0
  31. package/lib/abis/PoolAdapter.d.ts +36 -0
  32. package/lib/abis/PoolAdapter.js +51 -0
  33. package/lib/abis/RewardDistributor.d.ts +267 -0
  34. package/lib/abis/RewardDistributor.js +352 -0
  35. package/lib/abis/RwaRedeemSubaccount.d.ts +747 -0
  36. package/lib/abis/RwaRedeemSubaccount.js +548 -0
  37. package/lib/abis/SmartAccount.d.ts +17 -0
  38. package/lib/abis/SmartAccount.js +19 -0
  39. package/lib/abis/SwapRouter.d.ts +1043 -0
  40. package/lib/abis/SwapRouter.js +740 -0
  41. package/lib/abis/TextResolver.d.ts +16 -0
  42. package/lib/abis/TextResolver.js +16 -0
  43. package/lib/abis/TokenizedVaultV2.d.ts +1364 -0
  44. package/lib/abis/TokenizedVaultV2.js +1041 -0
  45. package/lib/abis/TokenizedVaultV2DepositWithPermit.d.ts +1456 -0
  46. package/lib/abis/TokenizedVaultV2DepositWithPermit.js +1878 -0
  47. package/lib/abis/TokenizedVaultV2Receipt.d.ts +1568 -0
  48. package/lib/abis/TokenizedVaultV2Receipt.js +1061 -0
  49. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.d.ts +454 -0
  50. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js +327 -0
  51. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.d.ts +1466 -0
  52. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js +1092 -0
  53. package/lib/abis/TokenizedVaultV2WhitelistedAssets.d.ts +274 -0
  54. package/lib/abis/TokenizedVaultV2WhitelistedAssets.js +167 -0
  55. package/lib/abis/UniversalResolverResolve.d.ts +69 -0
  56. package/lib/abis/UniversalResolverResolve.js +35 -0
  57. package/lib/abis/UniversalSignatureValidator.d.ts +17 -0
  58. package/lib/abis/UniversalSignatureValidator.js +30 -0
  59. package/lib/abis/WrapperAdapter.d.ts +71 -0
  60. package/lib/abis/WrapperAdapter.js +77 -0
  61. package/lib/abis/index.d.ts +34 -0
  62. package/lib/abis/index.js +51 -0
  63. package/lib/adapters/evm/getters.d.ts +19 -0
  64. package/lib/adapters/evm/getters.js +209 -0
  65. package/lib/adapters/evm/index.d.ts +353 -0
  66. package/lib/adapters/evm/index.js +434 -0
  67. package/lib/adapters/evm/utils.d.ts +8 -0
  68. package/lib/adapters/evm/utils.js +51 -0
  69. package/lib/adapters/solana/constants.d.ts +33 -0
  70. package/lib/adapters/solana/constants.js +52 -0
  71. package/lib/adapters/solana/getters.d.ts +11 -0
  72. package/lib/adapters/solana/getters.js +165 -0
  73. package/lib/adapters/solana/idl/vault-idl.d.ts +272 -0
  74. package/lib/adapters/solana/idl/vault-idl.js +1084 -0
  75. package/lib/adapters/solana/index.d.ts +233 -0
  76. package/lib/adapters/solana/index.js +291 -0
  77. package/lib/adapters/solana/types.d.ts +67 -0
  78. package/lib/adapters/solana/types.js +3 -0
  79. package/lib/adapters/solana/utils.d.ts +141 -0
  80. package/lib/adapters/solana/utils.js +595 -0
  81. package/lib/adapters/solana/vault.actions.d.ts +57 -0
  82. package/lib/adapters/solana/vault.actions.js +379 -0
  83. package/lib/adapters/stellar/actions.d.ts +28 -0
  84. package/lib/adapters/stellar/actions.js +77 -0
  85. package/lib/adapters/stellar/constants.d.ts +43 -0
  86. package/lib/adapters/stellar/constants.js +53 -0
  87. package/lib/adapters/stellar/getters.d.ts +68 -0
  88. package/lib/adapters/stellar/getters.js +290 -0
  89. package/lib/adapters/stellar/index.d.ts +114 -0
  90. package/lib/adapters/stellar/index.js +175 -0
  91. package/lib/adapters/stellar/soroban.d.ts +123 -0
  92. package/lib/adapters/stellar/soroban.js +613 -0
  93. package/lib/adapters/stellar/submit.d.ts +34 -0
  94. package/lib/adapters/stellar/submit.js +149 -0
  95. package/lib/adapters/stellar/types.d.ts +58 -0
  96. package/lib/adapters/stellar/types.js +6 -0
  97. package/lib/adapters/stellar/utils.d.ts +24 -0
  98. package/lib/adapters/stellar/utils.js +34 -0
  99. package/lib/adapters/sui/constants.d.ts +14 -0
  100. package/lib/adapters/sui/constants.js +29 -0
  101. package/lib/adapters/sui/getters.d.ts +9 -0
  102. package/lib/adapters/sui/getters.js +60 -0
  103. package/lib/adapters/sui/index.d.ts +45 -0
  104. package/lib/adapters/sui/index.js +101 -0
  105. package/lib/adapters/sui/transformer.d.ts +10 -0
  106. package/lib/adapters/sui/transformer.js +107 -0
  107. package/lib/adapters/sui/types.d.ts +66 -0
  108. package/lib/adapters/sui/types.js +3 -0
  109. package/lib/adapters/sui/utils.d.ts +10 -0
  110. package/lib/adapters/sui/utils.js +29 -0
  111. package/lib/core/analytics/chain-name.d.ts +9 -0
  112. package/lib/core/analytics/chain-name.js +34 -0
  113. package/lib/core/analytics/constants.d.ts +5 -0
  114. package/lib/core/analytics/constants.js +9 -0
  115. package/lib/core/analytics/env.d.ts +29 -0
  116. package/lib/core/analytics/env.js +59 -0
  117. package/lib/core/analytics/index.d.ts +36 -0
  118. package/lib/core/analytics/index.js +79 -0
  119. package/lib/core/analytics/instrumentation.d.ts +29 -0
  120. package/lib/core/analytics/instrumentation.js +277 -0
  121. package/lib/core/analytics/method-taxonomy.d.ts +19 -0
  122. package/lib/core/analytics/method-taxonomy.js +128 -0
  123. package/lib/core/analytics/metrics.d.ts +33 -0
  124. package/lib/core/analytics/metrics.js +116 -0
  125. package/lib/core/analytics/sanitize.d.ts +44 -0
  126. package/lib/core/analytics/sanitize.js +260 -0
  127. package/lib/core/analytics/sentry-runtime.d.ts +15 -0
  128. package/lib/core/analytics/sentry-runtime.js +97 -0
  129. package/lib/core/analytics/sentry.d.ts +67 -0
  130. package/lib/core/analytics/sentry.js +613 -0
  131. package/lib/core/analytics/types.d.ts +48 -0
  132. package/lib/core/analytics/types.js +3 -0
  133. package/lib/core/analytics/user-identity.d.ts +41 -0
  134. package/lib/core/analytics/user-identity.js +141 -0
  135. package/lib/core/analytics/version.d.ts +6 -0
  136. package/lib/core/analytics/version.js +10 -0
  137. package/lib/core/attribution.d.ts +111 -0
  138. package/lib/core/attribution.js +142 -0
  139. package/lib/core/auth/index.d.ts +1 -0
  140. package/lib/core/auth/index.js +18 -0
  141. package/lib/core/auth/verify.d.ts +2 -0
  142. package/lib/core/auth/verify.js +31 -0
  143. package/lib/core/base.class.d.ts +152 -0
  144. package/lib/core/base.class.js +172 -0
  145. package/lib/core/cache.d.ts +9 -0
  146. package/lib/core/cache.js +31 -0
  147. package/lib/core/constants/adapters.d.ts +103 -0
  148. package/lib/core/constants/adapters.js +180 -0
  149. package/lib/core/constants/core.d.ts +133 -0
  150. package/lib/core/constants/core.js +209 -0
  151. package/lib/core/constants/swap-router.d.ts +150 -0
  152. package/lib/core/constants/swap-router.js +169 -0
  153. package/lib/core/constants/vaults.d.ts +93 -0
  154. package/lib/core/constants/vaults.js +273 -0
  155. package/lib/core/constants/web3.d.ts +91 -0
  156. package/lib/core/constants/web3.js +229 -0
  157. package/lib/core/errors/index.d.ts +114 -0
  158. package/lib/core/errors/index.js +183 -0
  159. package/lib/core/fetcher.d.ts +198 -0
  160. package/lib/core/fetcher.js +903 -0
  161. package/lib/core/helpers/adapters.d.ts +13 -0
  162. package/lib/core/helpers/adapters.js +39 -0
  163. package/lib/core/helpers/chain-address.d.ts +13 -0
  164. package/lib/core/helpers/chain-address.js +47 -0
  165. package/lib/core/helpers/chain-error.d.ts +207 -0
  166. package/lib/core/helpers/chain-error.js +682 -0
  167. package/lib/core/helpers/chain-support.d.ts +80 -0
  168. package/lib/core/helpers/chain-support.js +115 -0
  169. package/lib/core/helpers/core.d.ts +68 -0
  170. package/lib/core/helpers/core.js +285 -0
  171. package/lib/core/helpers/explorer-link.d.ts +16 -0
  172. package/lib/core/helpers/explorer-link.js +26 -0
  173. package/lib/core/helpers/multicall.d.ts +68 -0
  174. package/lib/core/helpers/multicall.js +103 -0
  175. package/lib/core/helpers/revert-decode.d.ts +248 -0
  176. package/lib/core/helpers/revert-decode.js +515 -0
  177. package/lib/core/helpers/signer.d.ts +52 -0
  178. package/lib/core/helpers/signer.js +145 -0
  179. package/lib/core/helpers/swap-router.d.ts +211 -0
  180. package/lib/core/helpers/swap-router.js +480 -0
  181. package/lib/core/helpers/vault-version.d.ts +23 -0
  182. package/lib/core/helpers/vault-version.js +75 -0
  183. package/lib/core/helpers/vaults.d.ts +89 -0
  184. package/lib/core/helpers/vaults.js +235 -0
  185. package/lib/core/helpers/web3.d.ts +353 -0
  186. package/lib/core/helpers/web3.js +992 -0
  187. package/lib/core/index.d.ts +23 -0
  188. package/lib/core/index.js +40 -0
  189. package/lib/core/logger/index.d.ts +98 -0
  190. package/lib/core/logger/index.js +144 -0
  191. package/lib/core/logger/slack.d.ts +16 -0
  192. package/lib/core/logger/slack.js +57 -0
  193. package/lib/core/vault-metadata.d.ts +12 -0
  194. package/lib/core/vault-metadata.js +42 -0
  195. package/lib/core/version-check.d.ts +58 -0
  196. package/lib/core/version-check.js +182 -0
  197. package/lib/evm/index.d.ts +2 -0
  198. package/lib/evm/index.js +19 -0
  199. package/lib/evm/methods/crossChainVault.d.ts +128 -0
  200. package/lib/evm/methods/crossChainVault.js +853 -0
  201. package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
  202. package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
  203. package/lib/evm/methods/index.d.ts +2 -0
  204. package/lib/evm/methods/index.js +19 -0
  205. package/lib/evm/types/crossChain.d.ts +363 -0
  206. package/lib/evm/types/crossChain.js +20 -0
  207. package/lib/evm/types/index.d.ts +1 -0
  208. package/lib/evm/types/index.js +18 -0
  209. package/lib/index.d.ts +30 -0
  210. package/lib/index.js +52 -0
  211. package/lib/main.d.ts +527 -0
  212. package/lib/main.js +601 -0
  213. package/lib/modules/api/fetcher.d.ts +82 -0
  214. package/lib/modules/api/fetcher.js +150 -0
  215. package/lib/modules/api/index.d.ts +1 -0
  216. package/lib/modules/api/index.js +6 -0
  217. package/lib/modules/api/main.d.ts +313 -0
  218. package/lib/modules/api/main.js +479 -0
  219. package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
  220. package/lib/modules/sub-accounts/fetcher.js +120 -0
  221. package/lib/modules/sub-accounts/index.d.ts +2 -0
  222. package/lib/modules/sub-accounts/index.js +19 -0
  223. package/lib/modules/sub-accounts/main.d.ts +243 -0
  224. package/lib/modules/sub-accounts/main.js +205 -0
  225. package/lib/modules/sub-accounts/utils.d.ts +106 -0
  226. package/lib/modules/sub-accounts/utils.js +112 -0
  227. package/lib/modules/vaults/adapter.helpers.d.ts +64 -0
  228. package/lib/modules/vaults/adapter.helpers.js +184 -0
  229. package/lib/modules/vaults/fetcher.d.ts +147 -0
  230. package/lib/modules/vaults/fetcher.js +368 -0
  231. package/lib/modules/vaults/getters.d.ts +570 -0
  232. package/lib/modules/vaults/getters.js +3051 -0
  233. package/lib/modules/vaults/index.d.ts +20 -0
  234. package/lib/modules/vaults/index.js +44 -0
  235. package/lib/modules/vaults/main.d.ts +601 -0
  236. package/lib/modules/vaults/main.js +1623 -0
  237. package/lib/modules/vaults/prefetch.d.ts +65 -0
  238. package/lib/modules/vaults/prefetch.js +120 -0
  239. package/lib/modules/vaults/read.actions.d.ts +225 -0
  240. package/lib/modules/vaults/read.actions.js +596 -0
  241. package/lib/modules/vaults/types.d.ts +71 -0
  242. package/lib/modules/vaults/types.js +3 -0
  243. package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
  244. package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
  245. package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
  246. package/lib/modules/vaults/utils/date-utils.js +84 -0
  247. package/lib/modules/vaults/utils.d.ts +140 -0
  248. package/lib/modules/vaults/utils.js +799 -0
  249. package/lib/modules/vaults/write.actions.d.ts +529 -0
  250. package/lib/modules/vaults/write.actions.js +1749 -0
  251. package/lib/polyfills.d.ts +1 -0
  252. package/lib/polyfills.js +12 -0
  253. package/lib/sdk.d.ts +26721 -0
  254. package/lib/services/coingecko/fetcher.d.ts +15 -0
  255. package/lib/services/coingecko/fetcher.js +67 -0
  256. package/lib/services/coingecko/index.d.ts +2 -0
  257. package/lib/services/coingecko/index.js +19 -0
  258. package/lib/services/coingecko/utils.d.ts +1 -0
  259. package/lib/services/coingecko/utils.js +24 -0
  260. package/lib/services/debank/fetcher.d.ts +126 -0
  261. package/lib/services/debank/fetcher.js +47 -0
  262. package/lib/services/debank/index.d.ts +2 -0
  263. package/lib/services/debank/index.js +19 -0
  264. package/lib/services/debank/utils.d.ts +38 -0
  265. package/lib/services/debank/utils.js +297 -0
  266. package/lib/services/layerzero/deposits.d.ts +49 -0
  267. package/lib/services/layerzero/deposits.js +166 -0
  268. package/lib/services/layerzero/redeems.d.ts +20 -0
  269. package/lib/services/layerzero/redeems.js +92 -0
  270. package/lib/services/layerzero/utils.d.ts +9 -0
  271. package/lib/services/layerzero/utils.js +22 -0
  272. package/lib/services/octavfi/fetcher.d.ts +9 -0
  273. package/lib/services/octavfi/fetcher.js +103 -0
  274. package/lib/services/octavfi/index.d.ts +3 -0
  275. package/lib/services/octavfi/index.js +20 -0
  276. package/lib/services/octavfi/types.d.ts +34 -0
  277. package/lib/services/octavfi/types.js +3 -0
  278. package/lib/services/octavfi/utils.d.ts +16 -0
  279. package/lib/services/octavfi/utils.js +212 -0
  280. package/lib/services/subgraph/fetcher.d.ts +2 -0
  281. package/lib/services/subgraph/fetcher.js +61 -0
  282. package/lib/services/subgraph/index.d.ts +2 -0
  283. package/lib/services/subgraph/index.js +19 -0
  284. package/lib/services/subgraph/schema.d.ts +45 -0
  285. package/lib/services/subgraph/schema.js +75 -0
  286. package/lib/services/subgraph/vaults.d.ts +25 -0
  287. package/lib/services/subgraph/vaults.js +1106 -0
  288. package/lib/services/swap-quotes/index.d.ts +105 -0
  289. package/lib/services/swap-quotes/index.js +77 -0
  290. package/lib/services/swap-quotes/paraswap.d.ts +51 -0
  291. package/lib/services/swap-quotes/paraswap.js +138 -0
  292. package/lib/types/api.d.ts +280 -0
  293. package/lib/types/api.js +3 -0
  294. package/lib/types/index.d.ts +12 -0
  295. package/lib/types/index.js +28 -0
  296. package/lib/types/points.d.ts +28 -0
  297. package/lib/types/points.js +3 -0
  298. package/lib/types/pools.d.ts +144 -0
  299. package/lib/types/pools.js +3 -0
  300. package/lib/types/staking.d.ts +28 -0
  301. package/lib/types/staking.js +3 -0
  302. package/lib/types/sub-accounts.d.ts +140 -0
  303. package/lib/types/sub-accounts.js +3 -0
  304. package/lib/types/subgraph.d.ts +74 -0
  305. package/lib/types/subgraph.js +3 -0
  306. package/lib/types/typed-contract.d.ts +102 -0
  307. package/lib/types/typed-contract.js +3 -0
  308. package/lib/types/user.d.ts +1 -0
  309. package/lib/types/user.js +3 -0
  310. package/lib/types/vaults.d.ts +714 -0
  311. package/lib/types/vaults.js +24 -0
  312. package/lib/types/web3.d.ts +51 -0
  313. package/lib/types/web3.js +14 -0
  314. package/lib/types/webserver.d.ts +698 -0
  315. package/lib/types/webserver.js +3 -0
  316. package/package.json +78 -0
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AugustBase = void 0;
4
+ const auth_1 = require("./auth");
5
+ const logger_1 = require("./logger");
6
+ const analytics_1 = require("./analytics");
7
+ const version_check_1 = require("./version-check");
8
+ const fetcher_1 = require("./fetcher");
9
+ const attribution_1 = require("./attribution");
10
+ /**
11
+ * Validate an appName at SDK construction time.
12
+ *
13
+ * Rules (kept intentionally narrow so the value is safe to use as a Sentry
14
+ * tag, an HTTP header value, and a filesystem-safe identifier — this is
15
+ * why we accept slugs only, not display names):
16
+ * - non-empty after trim
17
+ * - 3..64 characters
18
+ * - only `[a-zA-Z0-9._-]`
19
+ *
20
+ * Throws a descriptive Error that names the failed rule and includes a
21
+ * remediation hint pointing at the docs link.
22
+ */
23
+ function validateAppName(value) {
24
+ const docsHint = 'See https://docs.augustdigital.io/developers/typescript-sdk#app-name';
25
+ if (typeof value !== 'string' || value.trim().length === 0) {
26
+ throw new Error(`August SDK: \`appName\` is required. Pass a stable kebab-case slug identifying your application (e.g. "acme-trader"). ${docsHint}`);
27
+ }
28
+ const trimmed = value.trim();
29
+ if (trimmed.length < 3 || trimmed.length > 64) {
30
+ throw new Error(`August SDK: \`appName\` must be 3-64 characters (got ${trimmed.length}). ${docsHint}`);
31
+ }
32
+ if (!/^[a-zA-Z0-9._-]+$/.test(trimmed)) {
33
+ throw new Error(`August SDK: \`appName\` may only contain letters, digits, '.', '_' and '-' (got "${trimmed}"). Use a slug like "acme-trader", not a display name. ${docsHint}`);
34
+ }
35
+ return trimmed;
36
+ }
37
+ /**
38
+ * Base class providing core SDK functionality including provider management,
39
+ * network switching, and authentication state.
40
+ */
41
+ class AugustBase {
42
+ keys;
43
+ monitoring = {
44
+ 'x-user-id': undefined,
45
+ 'x-environment': undefined,
46
+ };
47
+ authorized;
48
+ activeNetwork;
49
+ providers;
50
+ /** Validated app-name slug from the constructor. */
51
+ appName;
52
+ /**
53
+ * Initialize base SDK with provider configuration and API keys.
54
+ * Sets up the first provider as the active network by default.
55
+ *
56
+ * @throws If `appName` is missing, malformed, or out of the allowed
57
+ * length range — see {@link IAugustBase.appName}.
58
+ */
59
+ constructor({ appName, providers = {}, keys, monitoring, analytics, versionCheck, timeoutMs, publicApiBaseUrl, attribution, }) {
60
+ // Validate first so the failure mode is a clear, actionable error before
61
+ // any provider / analytics side effects run.
62
+ this.appName = validateAppName(appName);
63
+ // TODO: change this to false later when august key is required
64
+ this.authorized = true;
65
+ this.providers = providers;
66
+ // Set active network from the first provider (if any).
67
+ // An empty providers map is valid for backend-only chains (e.g. Stellar).
68
+ if (Object.keys(providers).length > 0) {
69
+ this.activeNetwork = {
70
+ chainId: Number(Object.keys(providers)[0]),
71
+ rpcUrl: Object.values(providers)[0],
72
+ };
73
+ }
74
+ this.keys = keys;
75
+ // Set environment (defaults to PROD for safety)
76
+ const environment = monitoring?.env || monitoring?.['x-environment'] || 'PROD';
77
+ this.monitoring = {
78
+ ...monitoring,
79
+ 'x-environment': environment,
80
+ };
81
+ // Set dev mode for logging (only true if explicitly set to DEV)
82
+ logger_1.Logger.setDevMode(environment === 'DEV');
83
+ // Initialize analytics (pass API key for hashed identification + the
84
+ // appName so events can be filtered by consuming application).
85
+ (0, analytics_1.initializeSentry)(analytics ?? { enabled: true }, environment, monitoring?.['x-user-id'], keys?.august, this.appName);
86
+ // Best-effort version nudge — fire-and-forget, never blocks init, no
87
+ // network call in production. See `core/version-check.ts` for details.
88
+ (0, version_check_1.runVersionCheck)(versionCheck);
89
+ if (typeof timeoutMs === 'number') {
90
+ (0, fetcher_1.setSdkRequestTimeout)(timeoutMs);
91
+ }
92
+ // Repoint the unauthenticated `public` vault-catalog API when a non-prod
93
+ // deployment supplies an isolated backend. Called UNCONDITIONALLY so each
94
+ // instance is authoritative: an instance that omits `publicApiBaseUrl`
95
+ // passes `null` and RESETS to the compiled-in prod default. Without this a
96
+ // prior staging instance would leak into a later prod instance in the same
97
+ // process — the inverse of the isolation this option exists to provide.
98
+ (0, fetcher_1.setPublicApiBaseUrl)(publicApiBaseUrl ?? null);
99
+ // ERC-8021 attribution follows the same reset-on-omit contract as
100
+ // `publicApiBaseUrl`: called unconditionally so a prior instance's
101
+ // builder codes never leak into a later instance in the same process.
102
+ (0, attribution_1.setAttribution)(attribution ?? null);
103
+ }
104
+ /**
105
+ * Verify API keys and authorize SDK usage.
106
+ * TODO: initialize class with appropriate keys and verify august key
107
+ */
108
+ async init() {
109
+ const [augustCheck] = await Promise.all([
110
+ (0, auth_1.verifyAugustKey)(this.keys?.august),
111
+ ]);
112
+ if (!augustCheck)
113
+ throw new Error('August Digital API key is invalid.');
114
+ this.authorized = true;
115
+ logger_1.Logger.log.info('init', 'August Digital SDK successfully initialized');
116
+ return;
117
+ }
118
+ /**
119
+ * Return the active network or throw a clear error.
120
+ * Use this in methods that require an EVM provider.
121
+ */
122
+ requireActiveNetwork() {
123
+ if (!this.activeNetwork) {
124
+ throw new Error('No active network configured. This operation requires an EVM provider. ' +
125
+ 'Pass at least one provider in the SDK constructor, or call switchNetwork() first.');
126
+ }
127
+ return this.activeNetwork;
128
+ }
129
+ /**
130
+ * Switch the active blockchain network.
131
+ * Updates both chain ID and RPC URL for subsequent operations.
132
+ */
133
+ switchNetwork(chainId) {
134
+ if (!this.providers[chainId]) {
135
+ throw new Error(`No provider configured for chainId ${chainId}. Available chains: ${Object.keys(this.providers).join(', ')}`);
136
+ }
137
+ this.activeNetwork = {
138
+ chainId,
139
+ rpcUrl: this.providers[chainId],
140
+ };
141
+ }
142
+ /**
143
+ * Set active wallet address and update monitoring headers.
144
+ * Preserves existing environment setting.
145
+ */
146
+ updateWallet(address) {
147
+ if (!address)
148
+ return;
149
+ const lowercasedAddress = address.toLowerCase();
150
+ this.monitoring = {
151
+ ...this.monitoring,
152
+ 'x-user-id': lowercasedAddress,
153
+ };
154
+ // Update analytics user identity
155
+ (0, analytics_1.updateUser)(lowercasedAddress, this.monitoring['x-environment']);
156
+ }
157
+ /**
158
+ * Remove wallet address from SDK state and monitoring headers.
159
+ */
160
+ clearWallet() {
161
+ if (this.monitoring) {
162
+ this.monitoring = {
163
+ ...this.monitoring,
164
+ 'x-user-id': undefined,
165
+ };
166
+ }
167
+ // Clear wallet from analytics user identity
168
+ (0, analytics_1.clearUser)();
169
+ }
170
+ }
171
+ exports.AugustBase = AugustBase;
172
+ //# sourceMappingURL=base.class.js.map
@@ -0,0 +1,9 @@
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
+ */
7
+ export declare const CACHE: LRUCache<string, any, unknown>;
8
+ export declare const getSafeCache: <T>(key: string) => Promise<T | null>;
9
+ export declare const setSafeCache: <T>(key: string, value: T) => Promise<void>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setSafeCache = exports.getSafeCache = exports.CACHE = void 0;
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.
11
+ exports.CACHE = new lru_cache_1.LRUCache({
12
+ max: 1000,
13
+ ttl: 1000 * 60 * 60 * 24,
14
+ allowStale: true,
15
+ });
16
+ const getSafeCache = async (key) => {
17
+ if (!key)
18
+ return null;
19
+ if (exports.CACHE.has(key)) {
20
+ return exports.CACHE.get(key);
21
+ }
22
+ return null;
23
+ };
24
+ exports.getSafeCache = getSafeCache;
25
+ const setSafeCache = async (key, value) => {
26
+ if (key && value) {
27
+ exports.CACHE.set(key, value);
28
+ }
29
+ };
30
+ exports.setSafeCache = setSafeCache;
31
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1,103 @@
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
+ */
7
+ import type { IVaultAdapterConfig, IAddress } from '../../types';
8
+ /**
9
+ * Pool/Vault names for adapter routing
10
+ */
11
+ export declare const POOL_NAMES: {
12
+ readonly ETH_TREEHOUSE_GROWTH: "Treehouse Growth";
13
+ readonly AVAX_AVAX: "AVAX Strategy";
14
+ readonly ETH_KELP_TAC_RSETH: "Kelp TAC rsETH";
15
+ };
16
+ /**
17
+ * Adapter ABIs for wrapper contracts
18
+ */
19
+ export declare const ADAPTER_ABIS: {
20
+ readonly NATIVE_DEPOSIT_AVAX: readonly [{
21
+ readonly inputs: readonly [];
22
+ readonly name: "depositETH";
23
+ readonly outputs: readonly [];
24
+ readonly stateMutability: "payable";
25
+ readonly type: "function";
26
+ }];
27
+ readonly NATIVE_DEPOSIT_ETH_WITH_REFERRAL: readonly [{
28
+ readonly inputs: readonly [{
29
+ readonly internalType: "address";
30
+ readonly name: "referralId";
31
+ readonly type: "address";
32
+ }];
33
+ readonly name: "depositETH";
34
+ readonly outputs: readonly [];
35
+ readonly stateMutability: "payable";
36
+ readonly type: "function";
37
+ }, {
38
+ readonly inputs: readonly [{
39
+ readonly internalType: "uint256";
40
+ readonly name: "amount";
41
+ readonly type: "uint256";
42
+ }, {
43
+ readonly internalType: "address";
44
+ readonly name: "referralId";
45
+ readonly type: "address";
46
+ }];
47
+ readonly name: "depositWETH";
48
+ readonly outputs: readonly [];
49
+ readonly stateMutability: "nonpayable";
50
+ readonly type: "function";
51
+ }];
52
+ readonly KELP_RSETH_ADAPTER: readonly [{
53
+ readonly inputs: readonly [{
54
+ readonly internalType: "address";
55
+ readonly name: "referralId";
56
+ readonly type: "address";
57
+ }];
58
+ readonly name: "getRSETHWithETH";
59
+ readonly outputs: readonly [];
60
+ readonly stateMutability: "payable";
61
+ readonly type: "function";
62
+ }, {
63
+ readonly inputs: readonly [{
64
+ readonly internalType: "address";
65
+ readonly name: "asset";
66
+ readonly type: "address";
67
+ }, {
68
+ readonly internalType: "uint256";
69
+ readonly name: "depositAmount";
70
+ readonly type: "uint256";
71
+ }, {
72
+ readonly internalType: "string";
73
+ readonly name: "referralId";
74
+ readonly type: "string";
75
+ }];
76
+ readonly name: "getRSETHWithERC20";
77
+ readonly outputs: readonly [];
78
+ readonly stateMutability: "nonpayable";
79
+ readonly type: "function";
80
+ }, {
81
+ readonly inputs: readonly [{
82
+ readonly internalType: "address";
83
+ readonly name: "asset";
84
+ readonly type: "address";
85
+ }, {
86
+ readonly internalType: "uint256";
87
+ readonly name: "depositAmount";
88
+ readonly type: "uint256";
89
+ }];
90
+ readonly name: "getRsETHAmountToMint";
91
+ readonly outputs: readonly [{
92
+ readonly internalType: "uint256";
93
+ readonly name: "rsETHAmount";
94
+ readonly type: "uint256";
95
+ }];
96
+ readonly stateMutability: "view";
97
+ readonly type: "function";
98
+ }];
99
+ };
100
+ /**
101
+ * Vault adapter configurations mapping vault addresses to their adapter settings
102
+ */
103
+ export declare const VAULT_ADAPTER_CONFIGS: Record<IAddress, IVaultAdapterConfig>;
@@ -0,0 +1,180 @@
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
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.VAULT_ADAPTER_CONFIGS = exports.ADAPTER_ABIS = exports.POOL_NAMES = void 0;
10
+ const ethers_1 = require("ethers");
11
+ /**
12
+ * Pool/Vault names for adapter routing
13
+ */
14
+ exports.POOL_NAMES = {
15
+ ETH_TREEHOUSE_GROWTH: 'Treehouse Growth',
16
+ AVAX_AVAX: 'AVAX Strategy',
17
+ ETH_KELP_TAC_RSETH: 'Kelp TAC rsETH',
18
+ };
19
+ /**
20
+ * Adapter ABIs for wrapper contracts
21
+ */
22
+ exports.ADAPTER_ABIS = {
23
+ NATIVE_DEPOSIT_AVAX: [
24
+ {
25
+ inputs: [],
26
+ name: 'depositETH',
27
+ outputs: [],
28
+ stateMutability: 'payable',
29
+ type: 'function',
30
+ },
31
+ ],
32
+ NATIVE_DEPOSIT_ETH_WITH_REFERRAL: [
33
+ {
34
+ inputs: [
35
+ { internalType: 'address', name: 'referralId', type: 'address' },
36
+ ],
37
+ name: 'depositETH',
38
+ outputs: [],
39
+ stateMutability: 'payable',
40
+ type: 'function',
41
+ },
42
+ {
43
+ inputs: [
44
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
45
+ { internalType: 'address', name: 'referralId', type: 'address' },
46
+ ],
47
+ name: 'depositWETH',
48
+ outputs: [],
49
+ stateMutability: 'nonpayable',
50
+ type: 'function',
51
+ },
52
+ ],
53
+ KELP_RSETH_ADAPTER: [
54
+ {
55
+ inputs: [
56
+ { internalType: 'address', name: 'referralId', type: 'address' },
57
+ ],
58
+ name: 'getRSETHWithETH',
59
+ outputs: [],
60
+ stateMutability: 'payable',
61
+ type: 'function',
62
+ },
63
+ {
64
+ inputs: [
65
+ {
66
+ internalType: 'address',
67
+ name: 'asset',
68
+ type: 'address',
69
+ },
70
+ {
71
+ internalType: 'uint256',
72
+ name: 'depositAmount',
73
+ type: 'uint256',
74
+ },
75
+ {
76
+ internalType: 'string',
77
+ name: 'referralId',
78
+ type: 'string',
79
+ },
80
+ ],
81
+ name: 'getRSETHWithERC20',
82
+ outputs: [],
83
+ stateMutability: 'nonpayable',
84
+ type: 'function',
85
+ },
86
+ {
87
+ inputs: [
88
+ {
89
+ internalType: 'address',
90
+ name: 'asset',
91
+ type: 'address',
92
+ },
93
+ {
94
+ internalType: 'uint256',
95
+ name: 'depositAmount',
96
+ type: 'uint256',
97
+ },
98
+ ],
99
+ name: 'getRsETHAmountToMint',
100
+ outputs: [
101
+ {
102
+ internalType: 'uint256',
103
+ name: 'rsETHAmount',
104
+ type: 'uint256',
105
+ },
106
+ ],
107
+ stateMutability: 'view',
108
+ type: 'function',
109
+ },
110
+ ],
111
+ };
112
+ /**
113
+ * Vault adapter configurations mapping vault addresses to their adapter settings
114
+ */
115
+ exports.VAULT_ADAPTER_CONFIGS = {
116
+ // Multi-asset vault with view adapter
117
+ '0x18EE038C114a07f4B08b420fb1E4149a4F357249': {
118
+ viewAdapter: '0x72f3cf0d87e9688fad77711d02d86c68334fb275',
119
+ lpTokenAddress: '0xeF866BfbD0eEc6D6b42C37d8acC0D5fd26828376',
120
+ isNativeTokenDeposit: false,
121
+ isWrappedTokenDeposit: false,
122
+ },
123
+ // BTC multi-token vault with Paraswap bridge
124
+ '0x8AcA0841993ef4C87244d519166e767f49362C21': {
125
+ isNativeTokenDeposit: false,
126
+ isWrappedTokenDeposit: false,
127
+ wrappedTokenAddress: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
128
+ wrapperAddress: '0xfa3f6f36e3D178A538B2B1Fa5f1a5291C901A884',
129
+ bridgeId: 2,
130
+ abi: [],
131
+ tokens: [
132
+ '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', // WBTC
133
+ '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf', // cbBTC
134
+ '0x18084fbA666a33d37592fA2633fD49a74DD93a88',
135
+ ],
136
+ },
137
+ // AVAX native deposit vault
138
+ '0xB2bFb52cfc40584AC4e9e2B36a5B8d6554A56e0b': {
139
+ isNativeTokenDeposit: true,
140
+ isWrappedTokenDeposit: false,
141
+ wrappedTokenAddress: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7',
142
+ wrapperAddress: '0xb2C57614B93c41A7Ec3B91980C0Bb7453904c6e8',
143
+ abi: exports.ADAPTER_ABIS.NATIVE_DEPOSIT_AVAX,
144
+ tokens: [
145
+ '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7', // WAVAX
146
+ ethers_1.ZeroAddress,
147
+ ],
148
+ },
149
+ // ETH Treehouse Growth - native deposit with referral
150
+ '0x5Fde59415625401278c4d41C6beFCe3790eb357f': {
151
+ isNativeTokenDeposit: true,
152
+ isWrappedTokenDeposit: true,
153
+ wrappedTokenAddress: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
154
+ referralId: '0x849ECeE35EdD45aFA3Bd731531427B5661f57d87',
155
+ wrapperAddress: '0x6B6b27F08B84c186626D5A64614B5192a8ef71a9',
156
+ abi: exports.ADAPTER_ABIS.NATIVE_DEPOSIT_ETH_WITH_REFERRAL,
157
+ tokens: [
158
+ '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0', // wstETH
159
+ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
160
+ ethers_1.ZeroAddress,
161
+ ],
162
+ },
163
+ // Kelp TAC rsETH - native deposit with custom adapter
164
+ '0x419386E3Ef42368e602720CC458e00c0B28c47A7': {
165
+ isNativeTokenDeposit: true,
166
+ isWrappedTokenDeposit: true,
167
+ wrappedTokenAddress: '0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84',
168
+ referralId: '',
169
+ wrapperAddress: '0xa7f3a4d8395d62DF12bf35Afb4ab8db42F12926F',
170
+ viewAdapter: '0x036676389e48133B63a802f8635AD39E752D375D',
171
+ abi: exports.ADAPTER_ABIS.KELP_RSETH_ADAPTER,
172
+ tokens: [
173
+ '0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84', // stETH
174
+ '0xA35b1B31Ce002FBF2058D22F30f95D405200A15b', // ETHx
175
+ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
176
+ ethers_1.ZeroAddress,
177
+ ],
178
+ },
179
+ };
180
+ //# sourceMappingURL=adapters.js.map
@@ -0,0 +1,133 @@
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
+ */
9
+ export declare const REQUEST_TIMEOUT_MS = 90000;
10
+ export declare const PRICE_SERVER_URL = "https://prices.augustdigital.io";
11
+ export declare const WEBSERVER_URL: {
12
+ production: string;
13
+ staging: string;
14
+ development: string;
15
+ localhost: string;
16
+ qa: string;
17
+ public: string;
18
+ upshift: string;
19
+ };
20
+ export declare const WEBSERVER_ENDPOINTS: {
21
+ default: {
22
+ hello: string;
23
+ protected: string;
24
+ };
25
+ auth: {
26
+ verify: string;
27
+ sign: string;
28
+ login: string;
29
+ nonce: string;
30
+ refresh: string;
31
+ };
32
+ subaccount: {
33
+ list: (offset?: number, limit?: number) => string;
34
+ rewards: (subaccount: IAddress) => string;
35
+ tokens: (subaccount: IAddress) => string;
36
+ twap: {
37
+ create: (subaccount: IAddress) => string;
38
+ stop: (subaccount: IAddress, id: string) => string;
39
+ fills: (subaccount: IAddress, id: string) => string;
40
+ };
41
+ debank: (subaccount: IAddress) => string;
42
+ health_factor: (subaccount: IAddress) => string;
43
+ summary: (subaccount: IAddress) => string;
44
+ batch: (subaccount: IAddress) => string;
45
+ loans: (subaccount: IAddress, side?: "BORROWER" | "LENDER" | "BOTH", active?: boolean) => string;
46
+ cefi: (subaccount: IAddress) => string;
47
+ otc_positions: (subaccount: IAddress) => string;
48
+ loanByAddress: (loanAddress: string, chainId: number) => string;
49
+ _: (subaccount: IAddress) => string;
50
+ };
51
+ transactions: {
52
+ v2: (subaccount: string, startTime?: string, endTime?: string) => string;
53
+ };
54
+ otc: {
55
+ positions: string;
56
+ marginRequirements: (otcCounterpartyId?: string, payer?: string) => string;
57
+ };
58
+ curator: {
59
+ vaultSubaccounts: (vaultAddress: string) => string;
60
+ vaultWhitelist: (vaultAddress: string) => string;
61
+ };
62
+ timelockRequests: (vaultAddress: string, chainId: number, status?: string) => string;
63
+ users: {
64
+ get: string;
65
+ };
66
+ dashboard: {
67
+ loans: string;
68
+ };
69
+ risk: {
70
+ discountFactors: string;
71
+ collateralExcessOrDeficit: (subaccount: string, tokenAddress: string, tokenChain: number, targetHealthFactor?: number) => string;
72
+ collateralSimulation: string;
73
+ };
74
+ prices: (symbol: string) => string;
75
+ metrics: {
76
+ pnl: (subaccount: IAddress, startTime?: string, endTime?: string) => string;
77
+ vaultPerformanceFees: (params: {
78
+ vaultAddress: string;
79
+ annualizedFeesPct: number;
80
+ nativeDenominated: boolean;
81
+ calculationPeriod: string;
82
+ startDate?: string;
83
+ endDate?: string;
84
+ }) => string;
85
+ };
86
+ public: {
87
+ integrations: {
88
+ morpho: {
89
+ apy: (subaccount: IAddress, vaultAddress: IAddress) => string;
90
+ };
91
+ };
92
+ tokenizedVault: {
93
+ loans: (vaultAddress: VaultAddress, chainId: number, active: boolean) => string;
94
+ subaccountLoans: (vaultAddress: VaultAddress, chainId: number, active: boolean) => string;
95
+ list: string;
96
+ byVaultAddress: (vaultAddress: VaultAddress) => string;
97
+ historicalApy: (vaultAddress: IAddress) => string;
98
+ historicalTimeseries: (vaultAddress: IAddress, nDays?: number) => string;
99
+ annualizedApy: (vaultAddress: IAddress) => string;
100
+ summary: (vaultAddress: IAddress) => string;
101
+ withdrawals: (chain: string, vaultAddress: IAddress) => string;
102
+ debank: (vaultAddress: IAddress) => string;
103
+ userHistory: (vaultAddress: IAddress, wallet: IAddress) => string;
104
+ archivedVaults: string;
105
+ };
106
+ points: {
107
+ byUserAddress: (userAddress: IAddress) => string;
108
+ register: string;
109
+ leaderboard: string;
110
+ };
111
+ vaults: {
112
+ pendingRedemptions: (vaultAddress: IAddress) => string;
113
+ };
114
+ pnl: {
115
+ unrealizedHistory: (vaultAddress: VaultAddress, limit?: number) => string;
116
+ unrealizedLatest: string;
117
+ };
118
+ revertReason: (txHash: string, chain: number) => string;
119
+ oracleClassification: (vaultAddress: string, chainId: number) => string;
120
+ };
121
+ upshift: {
122
+ vaults: {
123
+ metadata: string;
124
+ };
125
+ };
126
+ };
127
+ export declare const DEFAULT_FETCH_OPTIONS: {
128
+ readonly method: "GET";
129
+ readonly headers: {
130
+ readonly Accept: "application/json";
131
+ readonly 'Content-Type': "application/json";
132
+ };
133
+ };