@upshiftfinance/sdk 0.0.0-stage → 0.1.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 (346) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +408 -2
  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 +953 -0
  40. package/lib/abis/SwapRouter.js +1228 -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 +249 -0
  65. package/lib/adapters/evm/index.d.ts +539 -0
  66. package/lib/adapters/evm/index.js +656 -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/confirm.d.ts +88 -0
  70. package/lib/adapters/solana/confirm.js +291 -0
  71. package/lib/adapters/solana/constants.d.ts +42 -0
  72. package/lib/adapters/solana/constants.js +59 -0
  73. package/lib/adapters/solana/getters.d.ts +42 -0
  74. package/lib/adapters/solana/getters.js +275 -0
  75. package/lib/adapters/solana/idl/vault-idl.d.ts +700 -0
  76. package/lib/adapters/solana/idl/vault-idl.js +2101 -0
  77. package/lib/adapters/solana/idl/withdrawal-queue-idl.d.ts +795 -0
  78. package/lib/adapters/solana/idl/withdrawal-queue-idl.js +1864 -0
  79. package/lib/adapters/solana/index.d.ts +372 -0
  80. package/lib/adapters/solana/index.js +459 -0
  81. package/lib/adapters/solana/pricing.d.ts +184 -0
  82. package/lib/adapters/solana/pricing.js +239 -0
  83. package/lib/adapters/solana/queue-hints.d.ts +29 -0
  84. package/lib/adapters/solana/queue-hints.js +59 -0
  85. package/lib/adapters/solana/queue.actions.d.ts +97 -0
  86. package/lib/adapters/solana/queue.actions.js +468 -0
  87. package/lib/adapters/solana/token-reads.d.ts +108 -0
  88. package/lib/adapters/solana/token-reads.js +145 -0
  89. package/lib/adapters/solana/types.d.ts +325 -0
  90. package/lib/adapters/solana/types.js +3 -0
  91. package/lib/adapters/solana/utils.d.ts +229 -0
  92. package/lib/adapters/solana/utils.js +773 -0
  93. package/lib/adapters/solana/vault.actions.d.ts +140 -0
  94. package/lib/adapters/solana/vault.actions.js +657 -0
  95. package/lib/adapters/solana/withdrawal-queue.d.ts +125 -0
  96. package/lib/adapters/solana/withdrawal-queue.js +301 -0
  97. package/lib/adapters/stellar/actions.d.ts +41 -0
  98. package/lib/adapters/stellar/actions.js +126 -0
  99. package/lib/adapters/stellar/constants.d.ts +43 -0
  100. package/lib/adapters/stellar/constants.js +53 -0
  101. package/lib/adapters/stellar/getters.d.ts +68 -0
  102. package/lib/adapters/stellar/getters.js +290 -0
  103. package/lib/adapters/stellar/index.d.ts +126 -0
  104. package/lib/adapters/stellar/index.js +187 -0
  105. package/lib/adapters/stellar/invocation.d.ts +55 -0
  106. package/lib/adapters/stellar/invocation.js +92 -0
  107. package/lib/adapters/stellar/soroban.d.ts +131 -0
  108. package/lib/adapters/stellar/soroban.js +617 -0
  109. package/lib/adapters/stellar/submit.d.ts +42 -0
  110. package/lib/adapters/stellar/submit.js +195 -0
  111. package/lib/adapters/stellar/types.d.ts +57 -0
  112. package/lib/adapters/stellar/types.js +6 -0
  113. package/lib/adapters/stellar/utils.d.ts +24 -0
  114. package/lib/adapters/stellar/utils.js +34 -0
  115. package/lib/adapters/sui/constants.d.ts +1 -0
  116. package/lib/adapters/sui/constants.js +9 -0
  117. package/lib/adapters/sui/getters.d.ts +24 -0
  118. package/lib/adapters/sui/getters.js +134 -0
  119. package/lib/adapters/sui/index.d.ts +53 -0
  120. package/lib/adapters/sui/index.js +96 -0
  121. package/lib/adapters/sui/transformer.d.ts +10 -0
  122. package/lib/adapters/sui/transformer.js +115 -0
  123. package/lib/adapters/sui/types.d.ts +70 -0
  124. package/lib/adapters/sui/types.js +3 -0
  125. package/lib/adapters/sui/utils.d.ts +8 -0
  126. package/lib/adapters/sui/utils.js +17 -0
  127. package/lib/core/analytics/app-name.d.ts +27 -0
  128. package/lib/core/analytics/app-name.js +48 -0
  129. package/lib/core/analytics/chain-name.d.ts +9 -0
  130. package/lib/core/analytics/chain-name.js +34 -0
  131. package/lib/core/analytics/constants.d.ts +15 -0
  132. package/lib/core/analytics/constants.js +28 -0
  133. package/lib/core/analytics/env.d.ts +46 -0
  134. package/lib/core/analytics/env.js +147 -0
  135. package/lib/core/analytics/index.d.ts +39 -0
  136. package/lib/core/analytics/index.js +83 -0
  137. package/lib/core/analytics/instrumentation.d.ts +29 -0
  138. package/lib/core/analytics/instrumentation.js +292 -0
  139. package/lib/core/analytics/method-taxonomy.d.ts +19 -0
  140. package/lib/core/analytics/method-taxonomy.js +156 -0
  141. package/lib/core/analytics/metrics.d.ts +48 -0
  142. package/lib/core/analytics/metrics.js +142 -0
  143. package/lib/core/analytics/sanitize.d.ts +57 -0
  144. package/lib/core/analytics/sanitize.js +272 -0
  145. package/lib/core/analytics/sentry-runtime.d.ts +15 -0
  146. package/lib/core/analytics/sentry-runtime.js +131 -0
  147. package/lib/core/analytics/sentry.d.ts +100 -0
  148. package/lib/core/analytics/sentry.js +696 -0
  149. package/lib/core/analytics/types.d.ts +55 -0
  150. package/lib/core/analytics/types.js +3 -0
  151. package/lib/core/analytics/user-identity.d.ts +55 -0
  152. package/lib/core/analytics/user-identity.js +218 -0
  153. package/lib/core/analytics/version.d.ts +6 -0
  154. package/lib/core/analytics/version.js +10 -0
  155. package/lib/core/attribution.d.ts +159 -0
  156. package/lib/core/attribution.js +194 -0
  157. package/lib/core/auth/index.d.ts +1 -0
  158. package/lib/core/auth/index.js +18 -0
  159. package/lib/core/auth/verify.d.ts +2 -0
  160. package/lib/core/auth/verify.js +35 -0
  161. package/lib/core/base.class.d.ts +193 -0
  162. package/lib/core/base.class.js +163 -0
  163. package/lib/core/cache.d.ts +9 -0
  164. package/lib/core/cache.js +31 -0
  165. package/lib/core/constants/adapters.d.ts +103 -0
  166. package/lib/core/constants/adapters.js +180 -0
  167. package/lib/core/constants/core.d.ts +162 -0
  168. package/lib/core/constants/core.js +281 -0
  169. package/lib/core/constants/swap-router.d.ts +180 -0
  170. package/lib/core/constants/swap-router.js +203 -0
  171. package/lib/core/constants/vaults.d.ts +93 -0
  172. package/lib/core/constants/vaults.js +277 -0
  173. package/lib/core/constants/web3.d.ts +106 -0
  174. package/lib/core/constants/web3.js +251 -0
  175. package/lib/core/errors/index.d.ts +177 -0
  176. package/lib/core/errors/index.js +257 -0
  177. package/lib/core/fetcher.d.ts +237 -0
  178. package/lib/core/fetcher.js +1103 -0
  179. package/lib/core/helpers/adapters.d.ts +13 -0
  180. package/lib/core/helpers/adapters.js +39 -0
  181. package/lib/core/helpers/chain-address.d.ts +13 -0
  182. package/lib/core/helpers/chain-address.js +47 -0
  183. package/lib/core/helpers/chain-error.d.ts +207 -0
  184. package/lib/core/helpers/chain-error.js +697 -0
  185. package/lib/core/helpers/chain-support.d.ts +98 -0
  186. package/lib/core/helpers/chain-support.js +139 -0
  187. package/lib/core/helpers/concurrency.d.ts +51 -0
  188. package/lib/core/helpers/concurrency.js +79 -0
  189. package/lib/core/helpers/core.d.ts +92 -0
  190. package/lib/core/helpers/core.js +368 -0
  191. package/lib/core/helpers/explorer-link.d.ts +16 -0
  192. package/lib/core/helpers/explorer-link.js +26 -0
  193. package/lib/core/helpers/multicall.d.ts +68 -0
  194. package/lib/core/helpers/multicall.js +103 -0
  195. package/lib/core/helpers/revert-decode.d.ts +248 -0
  196. package/lib/core/helpers/revert-decode.js +515 -0
  197. package/lib/core/helpers/signer.d.ts +61 -0
  198. package/lib/core/helpers/signer.js +184 -0
  199. package/lib/core/helpers/swap-router.d.ts +269 -0
  200. package/lib/core/helpers/swap-router.js +542 -0
  201. package/lib/core/helpers/vault-version.d.ts +24 -0
  202. package/lib/core/helpers/vault-version.js +83 -0
  203. package/lib/core/helpers/vaults.d.ts +89 -0
  204. package/lib/core/helpers/vaults.js +241 -0
  205. package/lib/core/helpers/web3.d.ts +366 -0
  206. package/lib/core/helpers/web3.js +1034 -0
  207. package/lib/core/index.d.ts +23 -0
  208. package/lib/core/index.js +40 -0
  209. package/lib/core/logger/curator-alert.d.ts +217 -0
  210. package/lib/core/logger/curator-alert.js +276 -0
  211. package/lib/core/logger/index.d.ts +99 -0
  212. package/lib/core/logger/index.js +163 -0
  213. package/lib/core/logger/slack.d.ts +49 -0
  214. package/lib/core/logger/slack.js +111 -0
  215. package/lib/core/vault-metadata.d.ts +12 -0
  216. package/lib/core/vault-metadata.js +42 -0
  217. package/lib/core/version-check.d.ts +58 -0
  218. package/lib/core/version-check.js +182 -0
  219. package/lib/evm/index.d.ts +2 -0
  220. package/lib/evm/index.js +19 -0
  221. package/lib/evm/methods/crossChainVault.d.ts +132 -0
  222. package/lib/evm/methods/crossChainVault.js +857 -0
  223. package/lib/evm/methods/crossChainVaultRegistry.d.ts +92 -0
  224. package/lib/evm/methods/crossChainVaultRegistry.js +239 -0
  225. package/lib/evm/methods/index.d.ts +2 -0
  226. package/lib/evm/methods/index.js +19 -0
  227. package/lib/evm/types/crossChain.d.ts +363 -0
  228. package/lib/evm/types/crossChain.js +20 -0
  229. package/lib/evm/types/index.d.ts +1 -0
  230. package/lib/evm/types/index.js +18 -0
  231. package/lib/index.d.ts +30 -0
  232. package/lib/index.js +52 -0
  233. package/lib/main.d.ts +596 -0
  234. package/lib/main.js +681 -0
  235. package/lib/modules/api/fetcher.d.ts +108 -0
  236. package/lib/modules/api/fetcher.js +187 -0
  237. package/lib/modules/api/index.d.ts +1 -0
  238. package/lib/modules/api/index.js +6 -0
  239. package/lib/modules/api/main.d.ts +587 -0
  240. package/lib/modules/api/main.js +911 -0
  241. package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
  242. package/lib/modules/sub-accounts/fetcher.js +96 -0
  243. package/lib/modules/sub-accounts/index.d.ts +2 -0
  244. package/lib/modules/sub-accounts/index.js +19 -0
  245. package/lib/modules/sub-accounts/main.d.ts +249 -0
  246. package/lib/modules/sub-accounts/main.js +211 -0
  247. package/lib/modules/sub-accounts/utils.d.ts +106 -0
  248. package/lib/modules/sub-accounts/utils.js +112 -0
  249. package/lib/modules/vaults/adapter.helpers.d.ts +84 -0
  250. package/lib/modules/vaults/adapter.helpers.js +202 -0
  251. package/lib/modules/vaults/fetcher.d.ts +147 -0
  252. package/lib/modules/vaults/fetcher.js +357 -0
  253. package/lib/modules/vaults/getters.d.ts +1060 -0
  254. package/lib/modules/vaults/getters.js +4079 -0
  255. package/lib/modules/vaults/index.d.ts +20 -0
  256. package/lib/modules/vaults/index.js +44 -0
  257. package/lib/modules/vaults/main.d.ts +607 -0
  258. package/lib/modules/vaults/main.js +1687 -0
  259. package/lib/modules/vaults/prefetch.d.ts +65 -0
  260. package/lib/modules/vaults/prefetch.js +120 -0
  261. package/lib/modules/vaults/read.actions.d.ts +406 -0
  262. package/lib/modules/vaults/read.actions.js +891 -0
  263. package/lib/modules/vaults/types.d.ts +149 -0
  264. package/lib/modules/vaults/types.js +3 -0
  265. package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
  266. package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
  267. package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
  268. package/lib/modules/vaults/utils/date-utils.js +84 -0
  269. package/lib/modules/vaults/utils.d.ts +153 -0
  270. package/lib/modules/vaults/utils.js +818 -0
  271. package/lib/modules/vaults/write.actions.d.ts +812 -0
  272. package/lib/modules/vaults/write.actions.js +2377 -0
  273. package/lib/polyfills.d.ts +1 -0
  274. package/lib/polyfills.js +12 -0
  275. package/lib/sdk.d.ts +30154 -0
  276. package/lib/services/coingecko/fetcher.d.ts +15 -0
  277. package/lib/services/coingecko/fetcher.js +67 -0
  278. package/lib/services/coingecko/index.d.ts +2 -0
  279. package/lib/services/coingecko/index.js +19 -0
  280. package/lib/services/coingecko/utils.d.ts +1 -0
  281. package/lib/services/coingecko/utils.js +24 -0
  282. package/lib/services/debank/fetcher.d.ts +126 -0
  283. package/lib/services/debank/fetcher.js +47 -0
  284. package/lib/services/debank/index.d.ts +2 -0
  285. package/lib/services/debank/index.js +19 -0
  286. package/lib/services/debank/utils.d.ts +50 -0
  287. package/lib/services/debank/utils.js +325 -0
  288. package/lib/services/layerzero/deposits.d.ts +55 -0
  289. package/lib/services/layerzero/deposits.js +174 -0
  290. package/lib/services/layerzero/redeems.d.ts +20 -0
  291. package/lib/services/layerzero/redeems.js +92 -0
  292. package/lib/services/layerzero/utils.d.ts +9 -0
  293. package/lib/services/layerzero/utils.js +22 -0
  294. package/lib/services/octavfi/fetcher.d.ts +33 -0
  295. package/lib/services/octavfi/fetcher.js +39 -0
  296. package/lib/services/octavfi/index.d.ts +3 -0
  297. package/lib/services/octavfi/index.js +20 -0
  298. package/lib/services/octavfi/types.d.ts +34 -0
  299. package/lib/services/octavfi/types.js +3 -0
  300. package/lib/services/octavfi/utils.d.ts +16 -0
  301. package/lib/services/octavfi/utils.js +244 -0
  302. package/lib/services/subgraph/fetcher.d.ts +2 -0
  303. package/lib/services/subgraph/fetcher.js +66 -0
  304. package/lib/services/subgraph/index.d.ts +2 -0
  305. package/lib/services/subgraph/index.js +19 -0
  306. package/lib/services/subgraph/schema.d.ts +48 -0
  307. package/lib/services/subgraph/schema.js +87 -0
  308. package/lib/services/subgraph/vaults.d.ts +83 -0
  309. package/lib/services/subgraph/vaults.js +1282 -0
  310. package/lib/services/swap-quotes/index.d.ts +105 -0
  311. package/lib/services/swap-quotes/index.js +77 -0
  312. package/lib/services/swap-quotes/paraswap.d.ts +51 -0
  313. package/lib/services/swap-quotes/paraswap.js +138 -0
  314. package/lib/services/untangled/fetcher.d.ts +40 -0
  315. package/lib/services/untangled/fetcher.js +110 -0
  316. package/lib/services/untangled/index.d.ts +3 -0
  317. package/lib/services/untangled/index.js +20 -0
  318. package/lib/services/untangled/types.d.ts +83 -0
  319. package/lib/services/untangled/types.js +10 -0
  320. package/lib/services/untangled/utils.d.ts +91 -0
  321. package/lib/services/untangled/utils.js +339 -0
  322. package/lib/types/api.d.ts +498 -0
  323. package/lib/types/api.js +3 -0
  324. package/lib/types/index.d.ts +12 -0
  325. package/lib/types/index.js +28 -0
  326. package/lib/types/points.d.ts +28 -0
  327. package/lib/types/points.js +3 -0
  328. package/lib/types/pools.d.ts +144 -0
  329. package/lib/types/pools.js +3 -0
  330. package/lib/types/staking.d.ts +28 -0
  331. package/lib/types/staking.js +3 -0
  332. package/lib/types/sub-accounts.d.ts +150 -0
  333. package/lib/types/sub-accounts.js +3 -0
  334. package/lib/types/subgraph.d.ts +84 -0
  335. package/lib/types/subgraph.js +3 -0
  336. package/lib/types/typed-contract.d.ts +102 -0
  337. package/lib/types/typed-contract.js +3 -0
  338. package/lib/types/user.d.ts +1 -0
  339. package/lib/types/user.js +3 -0
  340. package/lib/types/vaults.d.ts +886 -0
  341. package/lib/types/vaults.js +30 -0
  342. package/lib/types/web3.d.ts +81 -0
  343. package/lib/types/web3.js +14 -0
  344. package/lib/types/webserver.d.ts +730 -0
  345. package/lib/types/webserver.js +3 -0
  346. package/package.json +78 -3
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformEmberVaultToIVault = transformEmberVaultToIVault;
4
+ exports.transformEmberVaultsToIVaults = transformEmberVaultsToIVaults;
5
+ const core_1 = require("../../core");
6
+ const constants_1 = require("./constants");
7
+ const utils_1 = require("./utils");
8
+ /**
9
+ * Transform Ember vault to IVault format
10
+ */
11
+ function transformEmberVaultToIVault(emberVault) {
12
+ const depositTokenDecimals = emberVault.depositCoin?.decimals || constants_1.EMBER_DEFAULTS.DECIMALS;
13
+ const receiptTokenDecimals = emberVault.receiptCoin?.decimals || constants_1.EMBER_DEFAULTS.DECIMALS;
14
+ const returnObj = {
15
+ chainId: constants_1.SUI_CHAIN_ID,
16
+ maxDailyDrawdown: 0,
17
+ risk: 'medium',
18
+ lagDuration: 0,
19
+ address: emberVault.address,
20
+ name: emberVault.name,
21
+ logoUrl: emberVault.logoUrl || '',
22
+ apy: {
23
+ apy: (0, utils_1.convertFromE9)(emberVault.reportedApy?.reportedApyE9 || 0) * 100,
24
+ pointsApy: null,
25
+ campaignApy: null,
26
+ explainer: '',
27
+ liquidApy: 0,
28
+ rewardsClaimable: 0,
29
+ rewardsCompounded: 0,
30
+ underlyingApy: (0, utils_1.convertFromE9)(emberVault.reportedApy?.reportedApyE9 || 0) * 100,
31
+ },
32
+ historical_apy: {
33
+ 7: (0, utils_1.convertFromE9)(emberVault.reportedApy?.reportedApyE9 || 0),
34
+ },
35
+ strategists: (emberVault.managers ||
36
+ emberVault.subAccounts?.map((s) => s.manager) ||
37
+ []).map((manager) => ({
38
+ address: manager?.id || '',
39
+ logo: manager?.logoUrl || '',
40
+ name: manager?.name?.toLowerCase() === 'gamma'
41
+ ? 'Gamma Research'
42
+ : manager?.name || 'Unknown',
43
+ type: 'subaccount',
44
+ website_url: null,
45
+ })),
46
+ fees: {
47
+ performance: (0, utils_1.convertFromE9)(emberVault.weeklyPerformanceFeeBpsE9 || 0) /
48
+ constants_1.EMBER_DEFAULTS.BPS_TO_PERCENT,
49
+ management: (0, utils_1.convertFromE9)(emberVault.managementFeePercentE9 || 0) * 100,
50
+ isManagementWaived: false,
51
+ managementFeeWaivedUntilDate: null,
52
+ managementFeeWaivedUntilTvl: null,
53
+ isPerformanceWaived: false,
54
+ performanceFeeWaivedUntilDate: null,
55
+ performanceFeeWaivedUntilTvl: null,
56
+ },
57
+ rewards: {
58
+ points: '0',
59
+ multiplier: 0,
60
+ multipliers: [],
61
+ additionalPoints: [],
62
+ additionalPointsDetailed: [],
63
+ },
64
+ version: constants_1.EMBER_DEFAULTS.VERSION,
65
+ description: emberVault.description || '',
66
+ startDatetime: new Date(emberVault.createdAt || Date.now()).toISOString(),
67
+ status: emberVault.status === 'deprecated' ? 'closed' : 'active',
68
+ tags: ['Sui DeFi', emberVault.publicType].filter(Boolean),
69
+ isFeatured: false,
70
+ isSpotlighted: false,
71
+ withdrawalOnly: undefined,
72
+ isVisible: emberVault.status === 'active' || emberVault.status === 'beta',
73
+ reserveTarget: 0,
74
+ reserveTolerance: 0,
75
+ isDepositPaused: emberVault.status === 'deprecated',
76
+ decimals: receiptTokenDecimals,
77
+ isWithdrawalPaused: emberVault.status === 'deprecated',
78
+ operator: '',
79
+ idleAssets: (0, core_1.toNormalizedBn)(0, receiptTokenDecimals),
80
+ depositAssets: [
81
+ {
82
+ address: emberVault.depositCoin?.address,
83
+ symbol: emberVault.depositCoin?.symbol || '',
84
+ decimals: depositTokenDecimals,
85
+ },
86
+ ],
87
+ totalAssets: (0, core_1.toNormalizedBn)(BigInt(emberVault.totalDeposits || '0'), depositTokenDecimals),
88
+ /**
89
+ * PLACEHOLDER: `totalSupply` mirrors `totalDeposits`, so any share price
90
+ * derived as totalAssets / totalSupply is always 1.0 for Ember vaults and
91
+ * is NOT the real receipt-token price. Ember's `rateE9` is not read: its
92
+ * exact semantics (and whether `totalDeposits` is current TVL or a
93
+ * cumulative figure) are not documented by the Ember API, so it is not
94
+ * used to derive supply until that is confirmed.
95
+ */
96
+ totalSupply: (0, core_1.toNormalizedBn)(BigInt(emberVault.totalDeposits || '0'), receiptTokenDecimals),
97
+ maxSupply: (0, core_1.toNormalizedBn)(BigInt(emberVault.maxDepositsAllowed || '0'), depositTokenDecimals),
98
+ receipt: {
99
+ symbol: emberVault.receiptCoin?.symbol || '',
100
+ address: emberVault.receiptCoin?.address,
101
+ decimals: receiptTokenDecimals,
102
+ },
103
+ composabilityIntegrations: [],
104
+ eoa_operators: [],
105
+ operators: [],
106
+ };
107
+ return returnObj;
108
+ }
109
+ /**
110
+ * Transform multiple Ember vaults
111
+ */
112
+ function transformEmberVaultsToIVaults(emberVaults) {
113
+ return emberVaults.map(transformEmberVaultToIVault);
114
+ }
115
+ //# sourceMappingURL=transformer.js.map
@@ -0,0 +1,70 @@
1
+ import type { IHIstoricalSnapshot } from '../../types';
2
+ export interface IEmberVault {
3
+ address: string;
4
+ id: string;
5
+ name: string;
6
+ description: string;
7
+ logoUrl: string;
8
+ status: 'active' | 'beta' | 'deprecated';
9
+ publicType: string;
10
+ strategy: string;
11
+ createdAt: number;
12
+ totalDeposits: string;
13
+ totalDepositsInUsdE9: string;
14
+ maxDepositsAllowed: string;
15
+ rateE9: string;
16
+ managementFeePercentE9: string;
17
+ weeklyPerformanceFeeBpsE9: string;
18
+ withdrawalPeriodDays: number;
19
+ minWithdrawalSharesE9: string;
20
+ historicalSnapshots?: IHIstoricalSnapshot[];
21
+ max_drawdown?: number | null;
22
+ depositCoin: {
23
+ address: string;
24
+ symbol: string;
25
+ name: string;
26
+ decimals: number;
27
+ logoUrl: string;
28
+ priceE9: string;
29
+ type: string;
30
+ };
31
+ receiptCoin: {
32
+ address: string;
33
+ symbol: string;
34
+ name: string;
35
+ decimals: number;
36
+ logoUrl: string;
37
+ priceE9: string;
38
+ type: string;
39
+ };
40
+ reportedApy: {
41
+ apyE9: string;
42
+ reportedApyE9: string;
43
+ updatedAt: string;
44
+ };
45
+ managers: Array<{
46
+ id: string;
47
+ name: string;
48
+ logoUrl: string;
49
+ websiteUrl: string;
50
+ }>;
51
+ subAccounts: Array<{
52
+ address: string;
53
+ manager: {
54
+ id: string;
55
+ name: string;
56
+ logoUrl: string;
57
+ websiteUrl: string;
58
+ };
59
+ }>;
60
+ /**
61
+ * Ember reward entries. Their shape is not documented by the Ember API and
62
+ * the SDK does not read them, so they are typed `unknown` — narrow before use.
63
+ */
64
+ rewards: unknown[];
65
+ }
66
+ export interface IFetchEmberVaultsOptions {
67
+ limit?: number;
68
+ offset?: number;
69
+ status?: string;
70
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,8 @@
1
+ export { isSuiAddress } from '../../core/helpers/chain-address';
2
+ /**
3
+ * Whether `chainId` is the SDK's Sui chain ID ({@link SUI_CHAIN_ID}, `-2`).
4
+ *
5
+ * @param chainId - Numeric chain ID, e.g. a backend vault row's `chain`.
6
+ * @returns `true` only for `-2`.
7
+ */
8
+ export declare function isSuiVault(chainId: number): boolean;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSuiAddress = void 0;
4
+ exports.isSuiVault = isSuiVault;
5
+ const constants_1 = require("./constants");
6
+ var chain_address_1 = require("../../core/helpers/chain-address");
7
+ Object.defineProperty(exports, "isSuiAddress", { enumerable: true, get: function () { return chain_address_1.isSuiAddress; } });
8
+ /**
9
+ * Whether `chainId` is the SDK's Sui chain ID ({@link SUI_CHAIN_ID}, `-2`).
10
+ *
11
+ * @param chainId - Numeric chain ID, e.g. a backend vault row's `chain`.
12
+ * @returns `true` only for `-2`.
13
+ */
14
+ function isSuiVault(chainId) {
15
+ return chainId === constants_1.SUI_CHAIN_ID;
16
+ }
17
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Validate an `appName` slug at SDK boundary points (the `UpshiftSDK`
3
+ * constructor and the standalone {@link initializeSentry} entry point).
4
+ *
5
+ * Rules (kept intentionally narrow so the value is safe to use as a Sentry
6
+ * tag, an HTTP header value, and a filesystem-safe identifier — this is
7
+ * why we accept slugs only, not display names):
8
+ * - non-empty after trim
9
+ * - 3..64 characters
10
+ * - only `[a-zA-Z0-9._-]`
11
+ * - not shaped like an EVM address (`0x` + 40 hex chars) — an address
12
+ * passes the character rules but is a high-cardinality wallet
13
+ * identifier, not an application name. This also catches callers of
14
+ * `initializeSentry` still passing the pre-v9 positional argument
15
+ * order, where a wallet address occupied the slot `appName` now holds.
16
+ *
17
+ * Throws a descriptive `UpshiftValidationError` (code `INVALID_INPUT`) that
18
+ * names the failed rule and includes a remediation hint pointing at the
19
+ * docs link.
20
+ *
21
+ * @param value - The candidate app name, as received from the caller.
22
+ * @returns The trimmed, validated slug.
23
+ * @throws UpshiftValidationError when the value is missing, empty,
24
+ * mis-typed, out of the 3–64 length range, contains disallowed
25
+ * characters, or is shaped like an EVM address.
26
+ */
27
+ export declare function validateAppName(value: unknown): string;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateAppName = validateAppName;
4
+ const errors_1 = require("../errors");
5
+ /**
6
+ * Validate an `appName` slug at SDK boundary points (the `UpshiftSDK`
7
+ * constructor and the standalone {@link initializeSentry} entry point).
8
+ *
9
+ * Rules (kept intentionally narrow so the value is safe to use as a Sentry
10
+ * tag, an HTTP header value, and a filesystem-safe identifier — this is
11
+ * why we accept slugs only, not display names):
12
+ * - non-empty after trim
13
+ * - 3..64 characters
14
+ * - only `[a-zA-Z0-9._-]`
15
+ * - not shaped like an EVM address (`0x` + 40 hex chars) — an address
16
+ * passes the character rules but is a high-cardinality wallet
17
+ * identifier, not an application name. This also catches callers of
18
+ * `initializeSentry` still passing the pre-v9 positional argument
19
+ * order, where a wallet address occupied the slot `appName` now holds.
20
+ *
21
+ * Throws a descriptive `UpshiftValidationError` (code `INVALID_INPUT`) that
22
+ * names the failed rule and includes a remediation hint pointing at the
23
+ * docs link.
24
+ *
25
+ * @param value - The candidate app name, as received from the caller.
26
+ * @returns The trimmed, validated slug.
27
+ * @throws UpshiftValidationError when the value is missing, empty,
28
+ * mis-typed, out of the 3–64 length range, contains disallowed
29
+ * characters, or is shaped like an EVM address.
30
+ */
31
+ function validateAppName(value) {
32
+ const docsHint = 'See https://docs.augustdigital.io/developers/typescript-sdk/javascript-sdk#app-name';
33
+ if (typeof value !== 'string' || value.trim().length === 0) {
34
+ throw new errors_1.UpshiftValidationError('INVALID_INPUT', `Upshift SDK: \`appName\` is required. Pass a stable kebab-case slug identifying your application (e.g. "acme-trader"). ${docsHint}`);
35
+ }
36
+ const trimmed = value.trim();
37
+ if (trimmed.length < 3 || trimmed.length > 64) {
38
+ throw new errors_1.UpshiftValidationError('INVALID_INPUT', `Upshift SDK: \`appName\` must be 3-64 characters (got ${trimmed.length}). ${docsHint}`);
39
+ }
40
+ if (!/^[a-zA-Z0-9._-]+$/.test(trimmed)) {
41
+ throw new errors_1.UpshiftValidationError('INVALID_INPUT', `Upshift SDK: \`appName\` may only contain letters, digits, '.', '_' and '-' (got "${trimmed}"). Use a slug like "acme-trader", not a display name. ${docsHint}`);
42
+ }
43
+ if (/^0x[0-9a-fA-F]{40}$/.test(trimmed)) {
44
+ throw new errors_1.UpshiftValidationError('INVALID_INPUT', `Upshift SDK: \`appName\` looks like a wallet address ("${trimmed}"). Pass an application slug like "acme-trader" — if you are calling initializeSentry directly, note that since v9 the argument order is (config, environment, appName, walletAddress?, apiKey?). ${docsHint}`);
45
+ }
46
+ return trimmed;
47
+ }
48
+ //# sourceMappingURL=app-name.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Map a numeric `chainId` to a stable lowercase slug for use as a Sentry tag
3
+ * value. Resolves both EVM chains ({@link NETWORKS}) and synthetic non-EVM
4
+ * chain IDs ({@link SPECIAL_CHAINS}); unknown IDs return `'unknown:<id>'`.
5
+ *
6
+ * @param chainId - Numeric chain ID, including negative IDs for non-EVM chains.
7
+ * @returns Slugified chain label (e.g. `'ethereum'`, `'arbitrum-one'`, `'solana'`).
8
+ */
9
+ export declare function chainIdToTagValue(chainId: number | undefined): string;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chainIdToTagValue = chainIdToTagValue;
4
+ const web3_1 = require("../constants/web3");
5
+ /**
6
+ * Map a numeric `chainId` to a stable lowercase slug for use as a Sentry tag
7
+ * value. Resolves both EVM chains ({@link NETWORKS}) and synthetic non-EVM
8
+ * chain IDs ({@link SPECIAL_CHAINS}); unknown IDs return `'unknown:<id>'`.
9
+ *
10
+ * @param chainId - Numeric chain ID, including negative IDs for non-EVM chains.
11
+ * @returns Slugified chain label (e.g. `'ethereum'`, `'arbitrum-one'`, `'solana'`).
12
+ */
13
+ function chainIdToTagValue(chainId) {
14
+ if (chainId === undefined || chainId === null || Number.isNaN(chainId)) {
15
+ return 'unknown';
16
+ }
17
+ for (const entry of Object.values(web3_1.SPECIAL_CHAINS)) {
18
+ if (entry.chainId === chainId) {
19
+ return slugify(entry.name);
20
+ }
21
+ }
22
+ const network = web3_1.NETWORKS[chainId];
23
+ if (network) {
24
+ return slugify(network.name);
25
+ }
26
+ return `unknown:${chainId}`;
27
+ }
28
+ function slugify(input) {
29
+ return input
30
+ .toLowerCase()
31
+ .replace(/[^a-z0-9]+/g, '-')
32
+ .replace(/^-+|-+$/g, '');
33
+ }
34
+ //# sourceMappingURL=chain-name.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Sentry DSN for SDK analytics.
3
+ * This is an internal constant - not exposed to SDK users.
4
+ */
5
+ export declare const SENTRY_DSN = "https://ca39246016d0b43154f0640314cbd3b5@o4507215496609792.ingest.de.sentry.io/4511864614813776";
6
+ /**
7
+ * `appName` slugs of applications Upshift operate themselves.
8
+ *
9
+ * Traffic from these is tagged `partner.tier: 'internal'` so that
10
+ * `partner.tier:unverified` in Sentry already means "external integrator"
11
+ * before the backend verification endpoint exists. Anything not listed stays
12
+ * `unverified`; the future verified flow adds a `verified` tier alongside
13
+ * rather than replacing this list.
14
+ */
15
+ export declare const FIRST_PARTY_APP_NAMES: ReadonlySet<string>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FIRST_PARTY_APP_NAMES = exports.SENTRY_DSN = void 0;
4
+ /**
5
+ * Sentry DSN for SDK analytics.
6
+ * This is an internal constant - not exposed to SDK users.
7
+ */
8
+ exports.SENTRY_DSN = 'https://ca39246016d0b43154f0640314cbd3b5@o4507215496609792.ingest.de.sentry.io/4511864614813776';
9
+ /**
10
+ * `appName` slugs of applications Upshift operate themselves.
11
+ *
12
+ * Traffic from these is tagged `partner.tier: 'internal'` so that
13
+ * `partner.tier:unverified` in Sentry already means "external integrator"
14
+ * before the backend verification endpoint exists. Anything not listed stays
15
+ * `unverified`; the future verified flow adds a `verified` tier alongside
16
+ * rather than replacing this list.
17
+ */
18
+ exports.FIRST_PARTY_APP_NAMES = new Set([
19
+ 'upshift-web-app',
20
+ 'upshift-earn',
21
+ 'upshift-prime',
22
+ 'upshift-cli',
23
+ 'upshift-mcp',
24
+ // Legacy slugs still emitted by pre-rebrand CLI/MCP installs.
25
+ 'august-cli',
26
+ 'august-mcp',
27
+ ]);
28
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Environment-variable gates for analytics. Pure functions — safe to import
3
+ * anywhere, no Sentry side effects. Tested directly in `analytics.test.js`.
4
+ */
5
+ /**
6
+ * Read a process env var without crashing in browsers or in bundles where
7
+ * `process.env` is a frozen / proxied object that throws on missing keys.
8
+ */
9
+ export declare function readEnv(name: string): string | undefined;
10
+ /**
11
+ * `UPSHIFT_SDK_FORCE_ANALYTICS=1` bypasses the dev/test and localhost gates.
12
+ * Used by our own smoke-test script and by partners deliberately exercising
13
+ * telemetry in a non-prod environment.
14
+ */
15
+ export declare function isAnalyticsForcedOnViaEnv(): boolean;
16
+ /**
17
+ * `UPSHIFT_SDK_DISABLE_ANALYTICS=1` is the env equivalent of passing
18
+ * `analytics: { enabled: false }`. Useful when partners can't easily plumb
19
+ * config through (CI runners, ops scripts).
20
+ */
21
+ export declare function isAnalyticsDisabledViaEnv(): boolean;
22
+ /**
23
+ * True when `NODE_ENV` is `'development'` or `'test'`. The SDK auto-disables
24
+ * analytics in these environments so partners' local dev runs and Jest suites
25
+ * don't pollute the production Sentry project.
26
+ *
27
+ * `NODE_ENV` undefined / `'production'` / `'staging'` / anything else → false.
28
+ */
29
+ export declare function isNodeDevOrTestEnv(): boolean;
30
+ /**
31
+ * True when the page is being served from a developer's own machine or private
32
+ * network.
33
+ *
34
+ * The browser counterpart to {@link isNodeDevOrTestEnv}: bundlers strip or
35
+ * stub `process.env`, so `NODE_ENV` cannot tell a `next dev` tab apart from a
36
+ * production deploy. The hostname can. Always false in Node, where
37
+ * `NODE_ENV` is the gate.
38
+ *
39
+ * Recognises `localhost` and the `.localhost` TLD (RFC 6761 reserves both for
40
+ * loopback), mDNS `.local` names, and any loopback / private / link-local IP
41
+ * literal in either address family. Anything else — including a public host
42
+ * that merely *contains* one of those names, like `localhost.acme.com` — is
43
+ * treated as a real deployment, because suppressing a genuine production
44
+ * origin is the more costly mistake of the two.
45
+ */
46
+ export declare function isLocalhost(): boolean;
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ /**
3
+ * Environment-variable gates for analytics. Pure functions — safe to import
4
+ * anywhere, no Sentry side effects. Tested directly in `analytics.test.js`.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.readEnv = readEnv;
8
+ exports.isAnalyticsForcedOnViaEnv = isAnalyticsForcedOnViaEnv;
9
+ exports.isAnalyticsDisabledViaEnv = isAnalyticsDisabledViaEnv;
10
+ exports.isNodeDevOrTestEnv = isNodeDevOrTestEnv;
11
+ exports.isLocalhost = isLocalhost;
12
+ /**
13
+ * Read a process env var without crashing in browsers or in bundles where
14
+ * `process.env` is a frozen / proxied object that throws on missing keys.
15
+ */
16
+ function readEnv(name) {
17
+ try {
18
+ if (typeof process !== 'undefined' && process.env) {
19
+ return process.env[name];
20
+ }
21
+ }
22
+ catch {
23
+ // Bundlers occasionally throw on `process.env` access. Treat as unset.
24
+ }
25
+ return undefined;
26
+ }
27
+ function isTruthyEnv(value) {
28
+ if (!value)
29
+ return false;
30
+ const v = value.toLowerCase();
31
+ return v === '1' || v === 'true' || v === 'yes' || v === 'on';
32
+ }
33
+ /**
34
+ * `UPSHIFT_SDK_FORCE_ANALYTICS=1` bypasses the dev/test and localhost gates.
35
+ * Used by our own smoke-test script and by partners deliberately exercising
36
+ * telemetry in a non-prod environment.
37
+ */
38
+ function isAnalyticsForcedOnViaEnv() {
39
+ return isTruthyEnv(readEnv('UPSHIFT_SDK_FORCE_ANALYTICS'));
40
+ }
41
+ /**
42
+ * `UPSHIFT_SDK_DISABLE_ANALYTICS=1` is the env equivalent of passing
43
+ * `analytics: { enabled: false }`. Useful when partners can't easily plumb
44
+ * config through (CI runners, ops scripts).
45
+ */
46
+ function isAnalyticsDisabledViaEnv() {
47
+ return isTruthyEnv(readEnv('UPSHIFT_SDK_DISABLE_ANALYTICS'));
48
+ }
49
+ /**
50
+ * True when `NODE_ENV` is `'development'` or `'test'`. The SDK auto-disables
51
+ * analytics in these environments so partners' local dev runs and Jest suites
52
+ * don't pollute the production Sentry project.
53
+ *
54
+ * `NODE_ENV` undefined / `'production'` / `'staging'` / anything else → false.
55
+ */
56
+ function isNodeDevOrTestEnv() {
57
+ const env = readEnv('NODE_ENV');
58
+ return env === 'development' || env === 'test';
59
+ }
60
+ /** Dotted-quad IPv4 literal. Anchored, so `10.acme.com` is not an address. */
61
+ const IPV4_LITERAL = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
62
+ /**
63
+ * True for an IPv4 literal that cannot be a public production origin: loopback
64
+ * (`127.0.0.0/8` — `127.0.0.1` is only the most common of 16.7M), the
65
+ * "this host" block (`0.0.0.0/8`), the three RFC 1918 private ranges, and
66
+ * link-local (`169.254.0.0/16`).
67
+ *
68
+ * Ranges are checked by octet rather than by string prefix on purpose: a
69
+ * `startsWith('10.')` test both misses `172.20.0.2` (a default Docker bridge
70
+ * address, and a very ordinary way to reach a container) and misfires on a
71
+ * public host that merely begins with those digits.
72
+ */
73
+ function isPrivateIpv4(hostname) {
74
+ const octets = IPV4_LITERAL.exec(hostname);
75
+ if (!octets)
76
+ return false;
77
+ const [a, b, c, d] = octets.slice(1).map(Number);
78
+ // The regex counts digits, not values, so an out-of-range quad still matches
79
+ // its shape. `127.0.0.999` is not an address — the URL parser rejects it
80
+ // rather than handing it over as a `hostname` — so it is a name, and names
81
+ // that are not the reserved ones are treated as deployed.
82
+ if (a > 255 || b > 255 || c > 255 || d > 255)
83
+ return false;
84
+ return (a === 127 ||
85
+ a === 0 ||
86
+ a === 10 ||
87
+ (a === 172 && b >= 16 && b <= 31) ||
88
+ (a === 192 && b === 168) ||
89
+ (a === 169 && b === 254));
90
+ }
91
+ /**
92
+ * True for an IPv6 literal that cannot be a public production origin:
93
+ * loopback (`::1`, in either notation), the unspecified address, an
94
+ * IPv4-mapped private address, unique-local (`fc00::/7`) and link-local
95
+ * (`fe80::/10`).
96
+ *
97
+ * `hostname` carries the brackets for an IPv6 host — `http://[::1]:3000/`
98
+ * yields `[::1]`, per the URL standard's host serialization — so they are
99
+ * stripped before matching.
100
+ */
101
+ function isLocalIpv6(hostname) {
102
+ const host = hostname.replace(/^\[/, '').replace(/\]$/, '');
103
+ if (!host.includes(':'))
104
+ return false;
105
+ if (host === '::1' || host === '::')
106
+ return true;
107
+ if (/^(?:0{1,4}:){7}0{0,3}1$/.test(host))
108
+ return true;
109
+ if (host.startsWith('::ffff:'))
110
+ return isPrivateIpv4(host.slice(7));
111
+ return /^f[cd]/.test(host) || /^fe[89ab]/.test(host);
112
+ }
113
+ /**
114
+ * True when the page is being served from a developer's own machine or private
115
+ * network.
116
+ *
117
+ * The browser counterpart to {@link isNodeDevOrTestEnv}: bundlers strip or
118
+ * stub `process.env`, so `NODE_ENV` cannot tell a `next dev` tab apart from a
119
+ * production deploy. The hostname can. Always false in Node, where
120
+ * `NODE_ENV` is the gate.
121
+ *
122
+ * Recognises `localhost` and the `.localhost` TLD (RFC 6761 reserves both for
123
+ * loopback), mDNS `.local` names, and any loopback / private / link-local IP
124
+ * literal in either address family. Anything else — including a public host
125
+ * that merely *contains* one of those names, like `localhost.acme.com` — is
126
+ * treated as a real deployment, because suppressing a genuine production
127
+ * origin is the more costly mistake of the two.
128
+ */
129
+ function isLocalhost() {
130
+ try {
131
+ if (typeof window !== 'undefined' && window.location) {
132
+ // Hostnames are case-insensitive; browsers normalize, other runtimes
133
+ // hosting a `window` shim may not.
134
+ const hostname = String(window.location.hostname).toLowerCase();
135
+ return (hostname === 'localhost' ||
136
+ hostname.endsWith('.localhost') ||
137
+ hostname.endsWith('.local') ||
138
+ isPrivateIpv4(hostname) ||
139
+ isLocalIpv6(hostname));
140
+ }
141
+ }
142
+ catch {
143
+ // Some embedded/sandboxed runtimes throw on `window.location`. Not local.
144
+ }
145
+ return false;
146
+ }
147
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Analytics module for SDK usage tracking via Sentry.
3
+ *
4
+ * Features:
5
+ * - User identification (API key hash, wallet, domain, fingerprint, session)
6
+ * - Method call tracking with timing, classified by {@link METHOD_CATEGORIES}
7
+ * - Application attribution (`app.name`, `partner.id`, `partner.tier`,
8
+ * `sdk.surface`) on every event and span
9
+ * - API response time tracking
10
+ * - Chain/network usage distribution
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Analytics enabled by default
15
+ * const sdk = new UpshiftSDK({
16
+ * appName: 'acme-trader',
17
+ * providers: { 1: 'https://...' },
18
+ * keys: { upshift: '...' },
19
+ * });
20
+ *
21
+ * // Opt-out of analytics
22
+ * const sdk = new UpshiftSDK({
23
+ * appName: 'acme-trader',
24
+ * providers: { 1: 'https://...' },
25
+ * keys: { upshift: '...' },
26
+ * analytics: { enabled: false },
27
+ * });
28
+ * ```
29
+ */
30
+ export type { IAnalyticsConfig, IUserIdentity, IMethodCallMetrics, } from './types';
31
+ export { hashApiKey, getSessionId, generateFingerprint, createUserIdentity, getUserId, } from './user-identity';
32
+ export { initializeSentry, updateUser, clearUser, isAnalyticsEnabled, getSentry, resetAnalytics, captureSdkException, } from './sentry';
33
+ export { getSentrySDK, getSentryRuntime } from './sentry-runtime';
34
+ export { readEnv, isAnalyticsDisabledViaEnv, isAnalyticsForcedOnViaEnv, isNodeDevOrTestEnv, } from './env';
35
+ export { trackApiCall, trackNetworkSwitch, trackKeyVerification, getCacheStats, resetCacheStats, } from './metrics';
36
+ export { sanitizeArgs, sanitizeObject, computeArgShape } from './sanitize';
37
+ export { withMethodTracking, withSyncMethodTracking, instrumentClass, } from './instrumentation';
38
+ export { METHOD_CATEGORIES, getMethodCategory, type MethodCategory, } from './method-taxonomy';
39
+ export { chainIdToTagValue } from './chain-name';