upshift-config 0.5.14

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,277 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withMethodTracking = withMethodTracking;
4
+ exports.withSyncMethodTracking = withSyncMethodTracking;
5
+ exports.instrumentClass = instrumentClass;
6
+ const chain_name_1 = require("./chain-name");
7
+ const method_taxonomy_1 = require("./method-taxonomy");
8
+ const sanitize_1 = require("./sanitize");
9
+ const sentry_runtime_1 = require("./sentry-runtime");
10
+ const sentry_1 = require("./sentry");
11
+ /**
12
+ * Higher-order function to wrap SDK methods with performance tracking.
13
+ * Tracks method calls, timing, chain usage, and errors.
14
+ *
15
+ * @param methodName - Name of the method being wrapped
16
+ * @param method - The original async method
17
+ * @param getChainId - Function to get current chain ID
18
+ * @returns Wrapped method with tracking
19
+ */
20
+ function withMethodTracking(methodName, method, getChainId) {
21
+ return async function trackedMethod(...args) {
22
+ if (!(0, sentry_1.isAnalyticsEnabled)()) {
23
+ return method(...args);
24
+ }
25
+ // Resolve the SDK before the sanitize/shape/category work — when
26
+ // @sentry/node fails to resolve, every call would otherwise pay the
27
+ // hot-path cost only to discard the result below.
28
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
29
+ if (!sdk) {
30
+ return method(...args);
31
+ }
32
+ const startTime = performance.now();
33
+ const chainId = getChainId?.();
34
+ const category = (0, method_taxonomy_1.getMethodCategory)(methodName);
35
+ const sanitizedArgs = (0, sanitize_1.sanitizeArgs)(args);
36
+ const argShape = (0, sanitize_1.computeArgShape)(args);
37
+ try {
38
+ // Use Sentry's startSpan for performance tracking (v8 API)
39
+ return await sdk.startSpan({
40
+ op: 'sdk.method',
41
+ name: methodName,
42
+ attributes: {
43
+ chainId: chainId?.toString() || 'unknown',
44
+ 'sdk.chain': (0, chain_name_1.chainIdToTagValue)(chainId),
45
+ 'sdk.category': category,
46
+ // Joined to a string because Sentry span attributes are scalar.
47
+ 'sdk.argShape': argShape.join('|'),
48
+ ...sanitizedArgs,
49
+ },
50
+ }, async (span) => {
51
+ try {
52
+ const result = await method(...args);
53
+ const duration = performance.now() - startTime;
54
+ // Record success metrics
55
+ span?.setAttribute('duration', Math.round(duration));
56
+ span?.setAttribute('success', true);
57
+ // Track method call
58
+ trackMethodCall(methodName, {
59
+ method: methodName,
60
+ category,
61
+ chainId,
62
+ duration,
63
+ success: true,
64
+ }, { ...sanitizedArgs, argShape: argShape.join('|') });
65
+ span?.setStatus({ code: 1 }); // OK status
66
+ return result;
67
+ }
68
+ catch (error) {
69
+ const duration = performance.now() - startTime;
70
+ const errorType = error instanceof Error ? error.name : 'UnknownError';
71
+ // Record error metrics
72
+ span?.setAttribute('duration', Math.round(duration));
73
+ span?.setAttribute('success', false);
74
+ span?.setAttribute('error', error instanceof Error ? error.message : String(error));
75
+ // Track failed method call
76
+ trackMethodCall(methodName, {
77
+ method: methodName,
78
+ category,
79
+ chainId,
80
+ duration,
81
+ success: false,
82
+ errorType,
83
+ }, { ...sanitizedArgs, argShape: argShape.join('|') });
84
+ span?.setStatus({ code: 2, message: errorType }); // Error status
85
+ throw error;
86
+ }
87
+ });
88
+ }
89
+ catch (error) {
90
+ // If Sentry.startSpan fails, fall back to direct method call
91
+ // This ensures analytics never breaks SDK functionality
92
+ if (error instanceof Error && error.message?.includes('Sentry')) {
93
+ return method(...args);
94
+ }
95
+ // Re-throw the original method error
96
+ throw error;
97
+ }
98
+ };
99
+ }
100
+ /**
101
+ * Track individual method calls as breadcrumbs and measurements.
102
+ */
103
+ function trackMethodCall(methodName, metrics, args) {
104
+ try {
105
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
106
+ if (!sdk)
107
+ return;
108
+ // Add breadcrumb for method call
109
+ sdk.addBreadcrumb({
110
+ category: 'sdk.method',
111
+ message: methodName,
112
+ level: metrics.success ? 'info' : 'error',
113
+ data: {
114
+ chainId: metrics.chainId,
115
+ category: metrics.category,
116
+ duration: Math.round(metrics.duration),
117
+ errorType: metrics.errorType,
118
+ ...args,
119
+ },
120
+ });
121
+ // Set measurement for method duration
122
+ sdk.setMeasurement('sdk.method.duration', metrics.duration, 'millisecond');
123
+ // Counters: SUM(invocation) → total calls; SUM(error)/SUM(invocation) → error rate.
124
+ sdk.setMeasurement('sdk.method.invocation', 1, 'none');
125
+ sdk.setMeasurement('sdk.method.error', metrics.success ? 0 : 1, 'none');
126
+ // Only sticky-tag the last method name — useful for attributing errors that fire
127
+ // outside an active SDK span. sdk.category and sdk.chain are already recorded as
128
+ // span attributes on each call, so mutating the global scope with them here would
129
+ // just contaminate subsequent unrelated events with stale values.
130
+ sdk.setTag('sdk.last_method', methodName);
131
+ }
132
+ catch {
133
+ // Silently fail - analytics should never break SDK
134
+ }
135
+ }
136
+ /**
137
+ * Check if a function is async (returns a Promise).
138
+ */
139
+ function isAsyncMethod(fn) {
140
+ // Check if constructor name indicates async
141
+ if (fn.constructor.name === 'AsyncFunction') {
142
+ return true;
143
+ }
144
+ // Check if function body suggests async
145
+ const fnString = fn.toString();
146
+ return fnString.includes('__awaiter') || fnString.startsWith('async');
147
+ }
148
+ /**
149
+ * Higher-order function to wrap synchronous SDK methods with tracking.
150
+ * Uses breadcrumbs for tracking since spans require async context.
151
+ *
152
+ * @param methodName - Name of the method being wrapped
153
+ * @param method - The original sync method
154
+ * @param getChainId - Function to get current chain ID
155
+ * @returns Wrapped method with tracking
156
+ */
157
+ function withSyncMethodTracking(methodName, method, getChainId) {
158
+ return function trackedSyncMethod(...args) {
159
+ if (!(0, sentry_1.isAnalyticsEnabled)()) {
160
+ return method(...args);
161
+ }
162
+ // Same hot-path short-circuit as the async path.
163
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
164
+ if (!sdk) {
165
+ return method(...args);
166
+ }
167
+ const startTime = performance.now();
168
+ const chainId = getChainId?.();
169
+ const category = (0, method_taxonomy_1.getMethodCategory)(methodName);
170
+ const sanitizedArgs = (0, sanitize_1.sanitizeArgs)(args);
171
+ const argShape = (0, sanitize_1.computeArgShape)(args);
172
+ try {
173
+ const result = method(...args);
174
+ const duration = performance.now() - startTime;
175
+ // Track successful sync method call via breadcrumb
176
+ trackSyncMethodCall(methodName, {
177
+ method: methodName,
178
+ category,
179
+ chainId,
180
+ duration,
181
+ success: true,
182
+ }, { ...sanitizedArgs, argShape: argShape.join('|') });
183
+ return result;
184
+ }
185
+ catch (error) {
186
+ const duration = performance.now() - startTime;
187
+ const errorType = error instanceof Error ? error.name : 'UnknownError';
188
+ // Track failed sync method call
189
+ trackSyncMethodCall(methodName, {
190
+ method: methodName,
191
+ category,
192
+ chainId,
193
+ duration,
194
+ success: false,
195
+ errorType,
196
+ }, { ...sanitizedArgs, argShape: argShape.join('|') });
197
+ throw error;
198
+ }
199
+ };
200
+ }
201
+ /**
202
+ * Track synchronous method calls as breadcrumbs.
203
+ */
204
+ function trackSyncMethodCall(methodName, metrics, args) {
205
+ try {
206
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
207
+ if (!sdk)
208
+ return;
209
+ // Add breadcrumb for sync method call
210
+ sdk.addBreadcrumb({
211
+ category: 'sdk.sync_method',
212
+ message: methodName,
213
+ level: metrics.success ? 'info' : 'error',
214
+ data: {
215
+ chainId: metrics.chainId,
216
+ category: metrics.category,
217
+ duration: Math.round(metrics.duration),
218
+ errorType: metrics.errorType,
219
+ ...args,
220
+ },
221
+ });
222
+ // Measurements omitted: sync methods have no span of their own, so setMeasurement
223
+ // would attach to whatever parent transaction happens to be active on the scope,
224
+ // overwriting its counters. The breadcrumb above already captures success/failure.
225
+ sdk.setTag('sdk.last_sync_method', methodName);
226
+ if (metrics.category) {
227
+ sdk.setTag('sdk.category', metrics.category);
228
+ }
229
+ if (metrics.chainId !== undefined) {
230
+ sdk.setTag('sdk.chain', (0, chain_name_1.chainIdToTagValue)(metrics.chainId));
231
+ sdk.setTag('sdk.last_chainId', metrics.chainId.toString());
232
+ }
233
+ }
234
+ catch {
235
+ // Silently fail - analytics should never break SDK
236
+ }
237
+ }
238
+ /**
239
+ * Instrument all methods on a class instance with tracking.
240
+ * This auto-wraps all public methods (both async and sync) without boilerplate.
241
+ *
242
+ * @param instance - The class instance to instrument
243
+ * @param getChainId - Function to get current chain ID
244
+ * @returns The same instance with instrumented methods
245
+ */
246
+ function instrumentClass(instance, getChainId) {
247
+ try {
248
+ const proto = Object.getPrototypeOf(instance);
249
+ const methodNames = Object.getOwnPropertyNames(proto).filter((name) => {
250
+ // Skip constructor and private methods
251
+ if (name === 'constructor' || name.startsWith('_'))
252
+ return false;
253
+ const descriptor = Object.getOwnPropertyDescriptor(proto, name);
254
+ return typeof descriptor?.value === 'function';
255
+ });
256
+ for (const methodName of methodNames) {
257
+ const original = instance[methodName];
258
+ if (typeof original === 'function') {
259
+ if (isAsyncMethod(original)) {
260
+ // Wrap async methods with span-based tracking
261
+ instance[methodName] =
262
+ withMethodTracking(methodName, original.bind(instance), getChainId);
263
+ }
264
+ else {
265
+ // Wrap sync methods with breadcrumb-based tracking
266
+ instance[methodName] =
267
+ withSyncMethodTracking(methodName, original.bind(instance), getChainId);
268
+ }
269
+ }
270
+ }
271
+ }
272
+ catch {
273
+ // Silently fail - analytics should never break SDK
274
+ }
275
+ return instance;
276
+ }
277
+ //# sourceMappingURL=instrumentation.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Canonical category for an SDK public method, used as the `sdk.category`
3
+ * Sentry tag so the partner-usage dashboard can roll calls up into
4
+ * `read.*` / `write.*` / `network` / `bridge` buckets.
5
+ */
6
+ export type MethodCategory = 'read.vault' | 'read.position' | 'read.redemption' | 'read.price' | 'read.points' | 'read.subaccount' | 'read.staking' | 'read.layerzero' | 'read.solana' | 'read.stellar' | 'read.sui' | 'read.evm' | 'write.deposit' | 'write.redeem' | 'write.approve' | 'write.points' | 'write.stellar' | 'network' | 'bridge' | 'unknown';
7
+ /**
8
+ * Map of public SDK method names to their {@link MethodCategory}.
9
+ *
10
+ * Keys are unqualified because `instrumentClass` walks the prototype and
11
+ * surfaces them that way; the same name on multiple adapters (e.g.
12
+ * `vaultDeposit` on EVM, Solana, Stellar) shares the same category.
13
+ */
14
+ export declare const METHOD_CATEGORIES: Readonly<Record<string, MethodCategory>>;
15
+ /**
16
+ * Look up the category for a method name, defaulting to `'unknown'` for
17
+ * methods not yet added to {@link METHOD_CATEGORIES}.
18
+ */
19
+ export declare function getMethodCategory(methodName: string): MethodCategory;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.METHOD_CATEGORIES = void 0;
4
+ exports.getMethodCategory = getMethodCategory;
5
+ /**
6
+ * Map of public SDK method names to their {@link MethodCategory}.
7
+ *
8
+ * Keys are unqualified because `instrumentClass` walks the prototype and
9
+ * surfaces them that way; the same name on multiple adapters (e.g.
10
+ * `vaultDeposit` on EVM, Solana, Stellar) shares the same category.
11
+ */
12
+ exports.METHOD_CATEGORIES = {
13
+ getVault: 'read.vault',
14
+ getVaults: 'read.vault',
15
+ getTotalDeposited: 'read.vault',
16
+ getVaultLoans: 'read.vault',
17
+ getVaultSubaccountLoans: 'read.vault',
18
+ getVaultAllocations: 'read.vault',
19
+ getVaultApy: 'read.vault',
20
+ getVaultAnnualizedApy: 'read.vault',
21
+ getVaultTvl: 'read.vault',
22
+ getVaultHistoricalTimeseries: 'read.vault',
23
+ getVaultSummary: 'read.vault',
24
+ getVaultPnl: 'read.vault',
25
+ getVaultUnrealizedPnlHistory: 'read.vault',
26
+ getLatestUnrealizedPnl: 'read.vault',
27
+ getDashboardLoans: 'read.vault',
28
+ getDiscountFactors: 'read.vault',
29
+ getCollateralExcessOrDeficit: 'read.vault',
30
+ simulateCollateral: 'read.vault',
31
+ getRevertReason: 'read.vault',
32
+ getOtcPositions: 'read.vault',
33
+ getOtcMarginRequirements: 'read.vault',
34
+ getCuratorVaultSubaccounts: 'read.vault',
35
+ getCuratorVaultWhitelist: 'read.vault',
36
+ getTimelockRequests: 'read.vault',
37
+ getVaultPerformanceFees: 'read.vault',
38
+ getVaultOracleClassification: 'read.vault',
39
+ getVaultBorrowerHealthFactor: 'read.vault',
40
+ getYieldLastRealizedOn: 'read.vault',
41
+ getVaultActivity: 'read.vault',
42
+ getSwapRouterDepositResult: 'read.vault',
43
+ getSwapRouterWhitelistedTokens: 'read.vault',
44
+ getSwapRouterEligibleVaults: 'read.vault',
45
+ getVaultPositions: 'read.position',
46
+ getVaultUserHistory: 'read.position',
47
+ getUserHistory: 'read.position',
48
+ getVaultUserTransfers: 'read.position',
49
+ getUserTransfers: 'read.position',
50
+ getVaultUserLifetimePnl: 'read.position',
51
+ getVaultAvailableRedemptions: 'read.redemption',
52
+ getVaultRedemptionHistory: 'read.redemption',
53
+ getVaultPendingRedemptions: 'read.redemption',
54
+ getVaultWithdrawals: 'read.redemption',
55
+ getWithdrawalRequestsWithStatus: 'read.redemption',
56
+ previewRedemption: 'read.redemption',
57
+ getPrice: 'read.price',
58
+ getUserPoints: 'read.points',
59
+ fetchPointsLeaderboard: 'read.points',
60
+ getAllSubaccounts: 'read.subaccount',
61
+ getSubaccountHealthFactor: 'read.subaccount',
62
+ getSubaccountLoans: 'read.subaccount',
63
+ getSubaccountCefiPositions: 'read.subaccount',
64
+ getSubaccountOtcPositions: 'read.subaccount',
65
+ getSubaccountSummary: 'read.subaccount',
66
+ getSubaccountTransactions: 'read.subaccount',
67
+ getSubaccountLoanByAddress: 'read.subaccount',
68
+ getSubaccountDebank: 'read.subaccount',
69
+ getStakingPositions: 'read.staking',
70
+ getVaultStakingPositions: 'read.staking',
71
+ getLayerZeroDeposits: 'read.layerzero',
72
+ getLayerZeroRedeems: 'read.layerzero',
73
+ getVaultState: 'read.solana',
74
+ getVaultStateReadOnly: 'read.solana',
75
+ getToken: 'read.solana',
76
+ getTokenSymbol: 'read.solana',
77
+ fetchUserTokenBalance: 'read.solana',
78
+ fetchUserShareBalance: 'read.solana',
79
+ fetchUserShareBalanceRaw: 'read.solana',
80
+ // Both are offline resolvers (no RPC) — classified so the partner dashboard
81
+ // sees program-targeting calls instead of dropping them into 'unknown'.
82
+ getProgram: 'read.solana',
83
+ getProgramId: 'read.solana',
84
+ // submitTransaction broadcasts a signed Soroban tx — it mutates on-chain
85
+ // state and belongs in the write bucket even though Stellar adapter call
86
+ // shape mirrors the read helpers (returns a hash, takes signed XDR).
87
+ submitTransaction: 'write.stellar',
88
+ getUserPosition: 'read.stellar',
89
+ // convertToShares is a read-only Soroban simulation despite its mutative-
90
+ // sounding name — runs through queryContract, no broadcast.
91
+ convertToShares: 'read.stellar',
92
+ getEmberVaults: 'read.sui',
93
+ getEmberTVL: 'read.sui',
94
+ vaultAllowance: 'read.evm',
95
+ sendersWhitelistAddress: 'read.evm',
96
+ isWhitelisted: 'read.evm',
97
+ getDeposited: 'read.evm',
98
+ getRemainingAllocations: 'read.evm',
99
+ previewDeposit: 'read.vault',
100
+ previewRedeem: 'read.redemption',
101
+ allowance: 'read.evm',
102
+ balanceOf: 'read.evm',
103
+ maxDeposit: 'read.vault',
104
+ vaultDeposit: 'write.deposit',
105
+ depositNative: 'write.deposit',
106
+ swapAndDeposit: 'write.deposit',
107
+ depositViaSwapRouter: 'write.deposit',
108
+ depositNativeViaSwapRouter: 'write.deposit',
109
+ swapRouterDeposit: 'write.deposit',
110
+ vaultRedeem: 'write.redeem',
111
+ vaultRequestRedeem: 'write.redeem',
112
+ rwaRedeemAsset: 'write.redeem',
113
+ vaultApprove: 'write.approve',
114
+ approve: 'write.approve',
115
+ registerUserForPoints: 'write.points',
116
+ switchNetwork: 'network',
117
+ updateWallet: 'network',
118
+ clearWallet: 'network',
119
+ setSigner: 'network',
120
+ };
121
+ /**
122
+ * Look up the category for a method name, defaulting to `'unknown'` for
123
+ * methods not yet added to {@link METHOD_CATEGORIES}.
124
+ */
125
+ function getMethodCategory(methodName) {
126
+ return exports.METHOD_CATEGORIES[methodName] ?? 'unknown';
127
+ }
128
+ //# sourceMappingURL=method-taxonomy.js.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Aggregated cache statistics for monitoring.
3
+ */
4
+ declare let cacheStats: {
5
+ hits: number;
6
+ misses: number;
7
+ sets: number;
8
+ };
9
+ /**
10
+ * Track API response times and status.
11
+ *
12
+ * @param endpoint - The API endpoint called
13
+ * @param method - HTTP method used
14
+ * @param startTime - Start timestamp from performance.now()
15
+ * @param status - HTTP response status code (0 for network errors)
16
+ * @param server - Server identifier (production, staging, etc.)
17
+ */
18
+ export declare function trackApiCall(endpoint: string, method: string, startTime: number, status: number, server: string): void;
19
+ /**
20
+ * Track chain/network switches for usage distribution analysis.
21
+ *
22
+ * @param chainId - The chain ID being switched to
23
+ */
24
+ export declare function trackNetworkSwitch(chainId: number): void;
25
+ /**
26
+ * Get current cache statistics.
27
+ */
28
+ export declare function getCacheStats(): typeof cacheStats;
29
+ /**
30
+ * Reset cache statistics (useful for testing).
31
+ */
32
+ export declare function resetCacheStats(): void;
33
+ export {};
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.trackApiCall = trackApiCall;
4
+ exports.trackNetworkSwitch = trackNetworkSwitch;
5
+ exports.getCacheStats = getCacheStats;
6
+ exports.resetCacheStats = resetCacheStats;
7
+ const chain_name_1 = require("./chain-name");
8
+ const sentry_runtime_1 = require("./sentry-runtime");
9
+ const sentry_1 = require("./sentry");
10
+ /**
11
+ * Aggregated cache statistics for monitoring.
12
+ */
13
+ let cacheStats = {
14
+ hits: 0,
15
+ misses: 0,
16
+ sets: 0,
17
+ };
18
+ /**
19
+ * Track API response times and status.
20
+ *
21
+ * @param endpoint - The API endpoint called
22
+ * @param method - HTTP method used
23
+ * @param startTime - Start timestamp from performance.now()
24
+ * @param status - HTTP response status code (0 for network errors)
25
+ * @param server - Server identifier (production, staging, etc.)
26
+ */
27
+ function trackApiCall(endpoint, method, startTime, status, server) {
28
+ if (!(0, sentry_1.isAnalyticsEnabled)())
29
+ return;
30
+ try {
31
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
32
+ if (!sdk)
33
+ return;
34
+ const duration = performance.now() - startTime;
35
+ // Normalize endpoint for aggregation (replace dynamic segments)
36
+ const normalizedEndpoint = normalizeEndpoint(endpoint);
37
+ // Add breadcrumb
38
+ sdk.addBreadcrumb({
39
+ category: 'api',
40
+ message: `${method} ${normalizedEndpoint}`,
41
+ level: status >= 400 || status === 0 ? 'error' : 'info',
42
+ data: {
43
+ endpoint: normalizedEndpoint,
44
+ method,
45
+ duration: Math.round(duration),
46
+ status,
47
+ server,
48
+ },
49
+ });
50
+ // Set measurement for performance tracking
51
+ sdk.setMeasurement('api.duration', duration, 'millisecond');
52
+ // Update tags for filtering
53
+ sdk.setTag('api.last_endpoint', normalizedEndpoint);
54
+ sdk.setTag('api.server', server);
55
+ }
56
+ catch {
57
+ // Silently fail - analytics should never break SDK
58
+ }
59
+ }
60
+ /**
61
+ * Track chain/network switches for usage distribution analysis.
62
+ *
63
+ * @param chainId - The chain ID being switched to
64
+ */
65
+ function trackNetworkSwitch(chainId) {
66
+ if (!(0, sentry_1.isAnalyticsEnabled)())
67
+ return;
68
+ try {
69
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
70
+ if (!sdk)
71
+ return;
72
+ const chainLabel = (0, chain_name_1.chainIdToTagValue)(chainId);
73
+ sdk.addBreadcrumb({
74
+ category: 'network',
75
+ message: `Switched to chain ${chainId} (${chainLabel})`,
76
+ level: 'info',
77
+ data: { chainId, chain: chainLabel },
78
+ });
79
+ sdk.setTag('active.chainId', chainId.toString());
80
+ sdk.setTag('sdk.chain', chainLabel);
81
+ }
82
+ catch {
83
+ // Silently fail - analytics should never break SDK
84
+ }
85
+ }
86
+ /**
87
+ * Normalize endpoint URLs for aggregation.
88
+ * Replaces dynamic segments (addresses, IDs) with placeholders.
89
+ *
90
+ * @param endpoint - Raw endpoint URL
91
+ * @returns Normalized endpoint pattern
92
+ */
93
+ function normalizeEndpoint(endpoint) {
94
+ return (endpoint
95
+ // Replace Ethereum addresses (0x + 40 hex chars)
96
+ .replace(/0x[a-fA-F0-9]{40}/g, ':address')
97
+ // Replace chain IDs (5+ digit numbers)
98
+ .replace(/\/\d{5,}/g, '/:chainId')
99
+ // Replace UUIDs
100
+ .replace(/[a-f0-9-]{36}/gi, ':uuid')
101
+ // Replace numeric IDs in paths
102
+ .replace(/\/\d+(?=\/|$)/g, '/:id'));
103
+ }
104
+ /**
105
+ * Get current cache statistics.
106
+ */
107
+ function getCacheStats() {
108
+ return { ...cacheStats };
109
+ }
110
+ /**
111
+ * Reset cache statistics (useful for testing).
112
+ */
113
+ function resetCacheStats() {
114
+ cacheStats = { hits: 0, misses: 0, sets: 0 };
115
+ }
116
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Redact secrets from a free-form string (error messages, URLs, log lines).
3
+ *
4
+ * @example
5
+ * sanitizeString('Request failed: https://api.example.com/v1?api_key=abc123')
6
+ * // → 'Request failed: https://api.example.com/v1?api_key=[REDACTED]'
7
+ */
8
+ export declare function sanitizeString(input: string): string;
9
+ /**
10
+ * Return a redacted clone of `err`. Preserves prototype (so `instanceof` checks
11
+ * keep working), `name`, all own properties (`code`, `status`, `correlationId`,
12
+ * …), and `cause`. Subclass constructors are NOT invoked — they may have
13
+ * positional signatures (`new AugustAuthError(code, message, opts)`) that would
14
+ * misalign if we naively passed the sanitized message as the first arg.
15
+ */
16
+ export declare function sanitizeError(err: unknown): unknown;
17
+ /** Sanitize arbitrary log input (strings, errors, objects, arrays, primitives). */
18
+ export declare function sanitizeForLogging(input: unknown, depth?: number): unknown;
19
+ /**
20
+ * Compute a value-free structural signature for a list of arguments — used
21
+ * as the `sdk.argShape` Sentry tag so dashboards can count which overload of
22
+ * a method partners call without ingesting wallet addresses or other PII.
23
+ *
24
+ * Tokens: primitives keep their `typeof` name; 0x-prefixed strings narrow to
25
+ * `'address'` / `'tx-hash'` / `'hex'`; arrays render as `'array(<length>)'`;
26
+ * objects render as `'options{<sorted,keys>}'`, capped at 12 keys.
27
+ *
28
+ * @param args - The `arguments` array of an instrumented method.
29
+ * @returns Shape tokens, one per arg, in argument order.
30
+ *
31
+ * @example
32
+ * computeArgShape(['0xabc…ef', { vault: '0x…', chainId: 1 }])
33
+ * // → ['address', 'options{chainId,vault}']
34
+ */
35
+ export declare function computeArgShape(args: unknown[]): string[];
36
+ /**
37
+ * Sanitize method arguments for safe logging to Sentry.
38
+ * Removes sensitive data and truncates large values.
39
+ */
40
+ export declare function sanitizeArgs(args: unknown[]): Record<string, unknown>;
41
+ /**
42
+ * Recursively sanitize an object, removing sensitive keys.
43
+ */
44
+ export declare function sanitizeObject(obj: Record<string, unknown>, depth?: number): Record<string, unknown>;