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,61 @@
1
+ /**
2
+ * Withdrawal Processing Transaction Decoder
3
+ *
4
+ * Decodes transaction calldata to extract which (year, month, day) cluster
5
+ * was processed when a WithdrawalProcessed event was emitted.
6
+ */
7
+ import type { ContractTransactionReceipt, Interface } from 'ethers';
8
+ export interface ProcessingCallData {
9
+ functionName: 'processAllClaimsByDate' | 'claim' | 'unknown';
10
+ year: number;
11
+ month: number;
12
+ day: number;
13
+ maxLimit?: number;
14
+ receiverAddr?: string;
15
+ error?: string;
16
+ }
17
+ /**
18
+ * Decode withdrawal processing transaction calldata.
19
+ * Handles both processAllClaimsByDate() and claim() functions.
20
+ *
21
+ * Both functions have the same first 3 parameters: (year, month, day)
22
+ *
23
+ * @param txData - Raw transaction data (tx.data from provider.getTransaction())
24
+ * @param iface - ethers Interface initialized with vault ABI
25
+ * @returns Decoded parameters or error
26
+ */
27
+ export declare function decodeWithdrawalProcessing(txData: string, iface: Interface): ProcessingCallData;
28
+ /**
29
+ * Fallback: Parse receipt logs if calldata decoding fails.
30
+ *
31
+ * This handles the multicall wrapper case where the outer tx.data
32
+ * is the multicall wrapper, not the vault function. By parsing logs,
33
+ * we can infer what happened on-chain.
34
+ *
35
+ * Note: This is a best-effort fallback. Ideal solution is Option 2
36
+ * (subgraph indexing) to avoid RPC calls altogether.
37
+ *
38
+ * @param receipt - Transaction receipt from provider
39
+ * @param vaultAddress - Expected vault address
40
+ * @param iface - ethers Interface with vault ABI
41
+ * @returns Decoded parameters from logs, or error
42
+ */
43
+ export declare function decodeFromReceiptLogs(receipt: ContractTransactionReceipt | null, vaultAddress: string, iface: Interface): Promise<ProcessingCallData>;
44
+ /**
45
+ * Detect if this is a multicall/batch transaction.
46
+ * Common patterns:
47
+ * - Uniswap Multicall: 0x1f0464f6
48
+ * - Gnosis Safe: 0x6a761202
49
+ * - 1inch Aggregator: 0x7c025200
50
+ *
51
+ * @param functionName - Function name from parsed decoded tx
52
+ * @returns true if this appears to be a batch/multicall
53
+ */
54
+ export declare function isMulticall(functionName: string): boolean;
55
+ /**
56
+ * Detect if the decoded function is one we care about for withdrawal processing.
57
+ *
58
+ * @param functionName - Function name from decoding
59
+ * @returns true if this is a withdrawal processing function
60
+ */
61
+ export declare function isWithdrawalProcessingFunction(functionName: string): boolean;
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ /**
3
+ * Withdrawal Processing Transaction Decoder
4
+ *
5
+ * Decodes transaction calldata to extract which (year, month, day) cluster
6
+ * was processed when a WithdrawalProcessed event was emitted.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.decodeWithdrawalProcessing = decodeWithdrawalProcessing;
10
+ exports.decodeFromReceiptLogs = decodeFromReceiptLogs;
11
+ exports.isMulticall = isMulticall;
12
+ exports.isWithdrawalProcessingFunction = isWithdrawalProcessingFunction;
13
+ /**
14
+ * Decode withdrawal processing transaction calldata.
15
+ * Handles both processAllClaimsByDate() and claim() functions.
16
+ *
17
+ * Both functions have the same first 3 parameters: (year, month, day)
18
+ *
19
+ * @param txData - Raw transaction data (tx.data from provider.getTransaction())
20
+ * @param iface - ethers Interface initialized with vault ABI
21
+ * @returns Decoded parameters or error
22
+ */
23
+ function decodeWithdrawalProcessing(txData, iface) {
24
+ try {
25
+ const decoded = iface.parseTransaction({ data: txData });
26
+ // Validation
27
+ if (!decoded || !decoded.args || decoded.args.length < 3) {
28
+ return {
29
+ functionName: 'unknown',
30
+ year: 0,
31
+ month: 0,
32
+ day: 0,
33
+ error: 'Invalid calldata: insufficient args',
34
+ };
35
+ }
36
+ // Extract first 3 parameters (shared by both functions)
37
+ const year = Number(decoded.args[0]);
38
+ const month = Number(decoded.args[1]);
39
+ const day = Number(decoded.args[2]);
40
+ // Validate date parameters are reasonable
41
+ if (year < 2000 || year > 2100 || month < 1 || month > 12 || day < 1) {
42
+ return {
43
+ functionName: 'unknown',
44
+ year,
45
+ month,
46
+ day,
47
+ error: 'Invalid date parameters',
48
+ };
49
+ }
50
+ // Validate day is valid for the month
51
+ const daysInMonth = new Date(Date.UTC(year, month, 0)).getUTCDate();
52
+ if (day > daysInMonth) {
53
+ return {
54
+ functionName: 'unknown',
55
+ year,
56
+ month,
57
+ day,
58
+ error: `Invalid day for month: ${day} > ${daysInMonth}`,
59
+ };
60
+ }
61
+ if (decoded.name === 'processAllClaimsByDate') {
62
+ const maxLimit = decoded.args[3] ? Number(decoded.args[3]) : undefined;
63
+ return {
64
+ functionName: 'processAllClaimsByDate',
65
+ year,
66
+ month,
67
+ day,
68
+ maxLimit,
69
+ };
70
+ }
71
+ else if (decoded.name === 'claim') {
72
+ const receiverAddr = decoded.args[3];
73
+ if (!receiverAddr) {
74
+ return {
75
+ functionName: 'unknown',
76
+ year,
77
+ month,
78
+ day,
79
+ error: 'Missing receiver address in claim()',
80
+ };
81
+ }
82
+ return {
83
+ functionName: 'claim',
84
+ year,
85
+ month,
86
+ day,
87
+ receiverAddr: receiverAddr.toString(),
88
+ };
89
+ }
90
+ // Unknown function that decoded successfully
91
+ return {
92
+ functionName: 'unknown',
93
+ year,
94
+ month,
95
+ day,
96
+ error: `Unknown withdrawal function: ${decoded.name}`,
97
+ };
98
+ }
99
+ catch (error) {
100
+ return {
101
+ functionName: 'unknown',
102
+ year: 0,
103
+ month: 0,
104
+ day: 0,
105
+ error: error instanceof Error ? error.message : 'Unknown decoding error',
106
+ };
107
+ }
108
+ }
109
+ /**
110
+ * Fallback: Parse receipt logs if calldata decoding fails.
111
+ *
112
+ * This handles the multicall wrapper case where the outer tx.data
113
+ * is the multicall wrapper, not the vault function. By parsing logs,
114
+ * we can infer what happened on-chain.
115
+ *
116
+ * Note: This is a best-effort fallback. Ideal solution is Option 2
117
+ * (subgraph indexing) to avoid RPC calls altogether.
118
+ *
119
+ * @param receipt - Transaction receipt from provider
120
+ * @param vaultAddress - Expected vault address
121
+ * @param iface - ethers Interface with vault ABI
122
+ * @returns Decoded parameters from logs, or error
123
+ */
124
+ async function decodeFromReceiptLogs(receipt, vaultAddress, iface) {
125
+ if (!receipt) {
126
+ return {
127
+ functionName: 'unknown',
128
+ year: 0,
129
+ month: 0,
130
+ day: 0,
131
+ error: 'No receipt available',
132
+ };
133
+ }
134
+ // Look for WithdrawalProcessed events in the logs
135
+ for (const log of receipt.logs) {
136
+ if (log.address.toLowerCase() !== vaultAddress.toLowerCase()) {
137
+ continue;
138
+ }
139
+ try {
140
+ const parsed = iface.parseLog(log);
141
+ if (parsed && parsed.name === 'WithdrawalProcessed') {
142
+ // Event found but date cannot be extracted from the current event schema.
143
+ // Return with year/month/day = 0 to signal caller should use fallback.
144
+ return {
145
+ functionName: 'processAllClaimsByDate',
146
+ year: 0,
147
+ month: 0,
148
+ day: 0,
149
+ error: 'Event found but date not available in event schema',
150
+ };
151
+ }
152
+ }
153
+ catch (e) {
154
+ // Not a matching event, continue
155
+ }
156
+ }
157
+ return {
158
+ functionName: 'unknown',
159
+ year: 0,
160
+ month: 0,
161
+ day: 0,
162
+ error: 'No WithdrawalProcessed logs found',
163
+ };
164
+ }
165
+ /**
166
+ * Detect if this is a multicall/batch transaction.
167
+ * Common patterns:
168
+ * - Uniswap Multicall: 0x1f0464f6
169
+ * - Gnosis Safe: 0x6a761202
170
+ * - 1inch Aggregator: 0x7c025200
171
+ *
172
+ * @param functionName - Function name from parsed decoded tx
173
+ * @returns true if this appears to be a batch/multicall
174
+ */
175
+ function isMulticall(functionName) {
176
+ const multicallNames = [
177
+ 'multicall',
178
+ 'aggregate',
179
+ 'aggregate3',
180
+ 'batchcall',
181
+ 'batch',
182
+ ];
183
+ return multicallNames.includes(functionName.toLowerCase());
184
+ }
185
+ /**
186
+ * Detect if the decoded function is one we care about for withdrawal processing.
187
+ *
188
+ * @param functionName - Function name from decoding
189
+ * @returns true if this is a withdrawal processing function
190
+ */
191
+ function isWithdrawalProcessingFunction(functionName) {
192
+ return functionName === 'processAllClaimsByDate' || functionName === 'claim';
193
+ }
194
+ //# sourceMappingURL=call-data-decoder.js.map
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Withdrawal Date Utilities
3
+ *
4
+ * Mirrors TimelockedVault.sol's DateUtils logic for computing claimable dates.
5
+ * All operations are in UTC to match contract behavior.
6
+ */
7
+ export interface ClaimableDate {
8
+ year: number;
9
+ month: number;
10
+ day: number;
11
+ epoch: number;
12
+ }
13
+ /**
14
+ * Compute the claimable date for a withdrawal request.
15
+ * Replicates TimelockedVault.requestRedeem() logic exactly.
16
+ *
17
+ * The contract does:
18
+ * (year, month, day) = DateUtils.timestampToDate(block.timestamp + 300 + lagDuration)
19
+ *
20
+ * @param requestTimestamp - Block timestamp of the request (in seconds, UTC)
21
+ * @param lagDuration - Lag duration in seconds (e.g., 86400 for 1 day)
22
+ * @returns The date when the withdrawal becomes claimable (UTC)
23
+ */
24
+ export declare function computeClaimableDate(requestTimestamp: number, lagDuration: number): ClaimableDate;
25
+ /**
26
+ * Check if a withdrawal request is ready to claim.
27
+ * The contract allows claiming when: block.timestamp + 300 >= claimableEpoch
28
+ *
29
+ * @param claimableEpoch - The epoch when this request became claimable
30
+ * @param currentEpoch - Current timestamp (usually block.timestamp or now)
31
+ * @returns true if claimable now
32
+ */
33
+ export declare function isClaimableNow(claimableEpoch: number, currentEpoch: number): boolean;
34
+ /**
35
+ * Format date for use as a lookup key (e.g., "2024-03-16")
36
+ * Ensures consistent formatting across the codebase.
37
+ */
38
+ export declare function formatDateKey(year: number, month: number, day: number): string;
39
+ /**
40
+ * Verify that computed date matches expected format.
41
+ * Used for debugging and validation.
42
+ */
43
+ export declare function isValidClaimableDate(date: ClaimableDate): boolean;
44
+ /**
45
+ * Get the number of days in a given month.
46
+ * @param year - Year (4-digit)
47
+ * @param month - Month (1-12)
48
+ * @returns Number of days in that month
49
+ */
50
+ export declare function getDaysInMonth(year: number, month: number): number;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ /**
3
+ * Withdrawal Date Utilities
4
+ *
5
+ * Mirrors TimelockedVault.sol's DateUtils logic for computing claimable dates.
6
+ * All operations are in UTC to match contract behavior.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.computeClaimableDate = computeClaimableDate;
10
+ exports.isClaimableNow = isClaimableNow;
11
+ exports.formatDateKey = formatDateKey;
12
+ exports.isValidClaimableDate = isValidClaimableDate;
13
+ exports.getDaysInMonth = getDaysInMonth;
14
+ const TIMESTAMP_MANIPULATION_WINDOW = 300;
15
+ /**
16
+ * Compute the claimable date for a withdrawal request.
17
+ * Replicates TimelockedVault.requestRedeem() logic exactly.
18
+ *
19
+ * The contract does:
20
+ * (year, month, day) = DateUtils.timestampToDate(block.timestamp + 300 + lagDuration)
21
+ *
22
+ * @param requestTimestamp - Block timestamp of the request (in seconds, UTC)
23
+ * @param lagDuration - Lag duration in seconds (e.g., 86400 for 1 day)
24
+ * @returns The date when the withdrawal becomes claimable (UTC)
25
+ */
26
+ function computeClaimableDate(requestTimestamp, lagDuration) {
27
+ // Add 300s + lagDuration to the request timestamp
28
+ // This must be done BEFORE converting to date, not after
29
+ const claimableEpoch = requestTimestamp + TIMESTAMP_MANIPULATION_WINDOW + lagDuration;
30
+ // Convert to UTC date
31
+ // CRITICAL: Use getUTC* methods, not local timezone methods
32
+ const date = new Date(claimableEpoch * 1000);
33
+ const year = date.getUTCFullYear();
34
+ const month = date.getUTCMonth() + 1; // getUTCMonth() returns 0-11
35
+ const day = date.getUTCDate();
36
+ return { year, month, day, epoch: claimableEpoch };
37
+ }
38
+ /**
39
+ * Check if a withdrawal request is ready to claim.
40
+ * The contract allows claiming when: block.timestamp + 300 >= claimableEpoch
41
+ *
42
+ * @param claimableEpoch - The epoch when this request became claimable
43
+ * @param currentEpoch - Current timestamp (usually block.timestamp or now)
44
+ * @returns true if claimable now
45
+ */
46
+ function isClaimableNow(claimableEpoch, currentEpoch) {
47
+ // Ready to claim when: currentEpoch + 300 >= claimableEpoch
48
+ // Which means: currentEpoch >= claimableEpoch - 300
49
+ return currentEpoch >= claimableEpoch - TIMESTAMP_MANIPULATION_WINDOW;
50
+ }
51
+ /**
52
+ * Format date for use as a lookup key (e.g., "2024-03-16")
53
+ * Ensures consistent formatting across the codebase.
54
+ */
55
+ function formatDateKey(year, month, day) {
56
+ return `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
57
+ }
58
+ /**
59
+ * Verify that computed date matches expected format.
60
+ * Used for debugging and validation.
61
+ */
62
+ function isValidClaimableDate(date) {
63
+ if (date.year < 2000 ||
64
+ date.year > 2100 ||
65
+ date.month < 1 ||
66
+ date.month > 12 ||
67
+ date.day < 1 ||
68
+ date.epoch <= 0) {
69
+ return false;
70
+ }
71
+ // Validate day is valid for the month (use Date.UTC to avoid local timezone issues)
72
+ const daysInMonth = new Date(Date.UTC(date.year, date.month, 0)).getUTCDate();
73
+ return date.day <= daysInMonth;
74
+ }
75
+ /**
76
+ * Get the number of days in a given month.
77
+ * @param year - Year (4-digit)
78
+ * @param month - Month (1-12)
79
+ * @returns Number of days in that month
80
+ */
81
+ function getDaysInMonth(year, month) {
82
+ return new Date(Date.UTC(year, month, 0)).getUTCDate();
83
+ }
84
+ //# sourceMappingURL=date-utils.js.map
@@ -0,0 +1,140 @@
1
+ import type { IAddress, IContractRunner, INormalizedNumber, IPoolFunctions, ITokenizedVault, IVault, IVaultFreshness } from '../../types';
2
+ import { ethers } from 'ethers';
3
+ import type { WalletClient } from 'viem';
4
+ /**
5
+ * @param walletClient a wagmi-derived client (from useWalletClient)
6
+ * @returns An ethers JsonRpcSigner object used in sdk.evm.setSigner
7
+ */
8
+ export declare function walletClientToSigner(walletClient: WalletClient): Promise<ethers.JsonRpcSigner>;
9
+ /**
10
+ * Calculates the reward multiplier based on the vault and optional timestamp.
11
+ * Returns the applicable multiplier for a given vault at a specific timestamp,
12
+ * or the latest multiplier if no timestamp is provided.
13
+ * @param foundPool The vault to get the multiplier for
14
+ * @param timestamp Optional timestamp to get historical multiplier
15
+ * @returns The reward multiplier value
16
+ */
17
+ export declare const getRewardMultiplierByTimestamp: (foundPool: IVault, timestamp?: number) => number;
18
+ /**
19
+ * Get the rewards for the vault.
20
+ *
21
+ * Builds the display-facing rewards summary from the raw tokenized-vault
22
+ * rewards array. In addition to the legacy `additionalPoints` string list, it
23
+ * emits `additionalPointsDetailed`, which pairs each label with its
24
+ * backend-provided `img_url`. Consumers (e.g. the Upshift app) resolve a
25
+ * reward's logo from this `imgUrl` first, falling back to a bundled asset only
26
+ * when it is absent — so a newly-added reward with a backend logo (e.g.
27
+ * "Cores") renders its icon without any client-side keyword mapping.
28
+ *
29
+ * @param tokenizedVault - The tokenized vault.
30
+ * @returns The rewards summary, including `additionalPointsDetailed`.
31
+ */
32
+ export declare function getVaultRewards(tokenizedVault: ITokenizedVault): {
33
+ points: string;
34
+ multiplier: number;
35
+ multipliers: {
36
+ timestamp: number;
37
+ value: number;
38
+ }[];
39
+ additionalPoints: string[];
40
+ additionalPointsDetailed: {
41
+ id: string;
42
+ label: string;
43
+ text: string;
44
+ imgUrl: string;
45
+ multiplier: number;
46
+ }[];
47
+ };
48
+ /**
49
+ * Get the idle assets for the vault
50
+ * @param provider - The provider
51
+ * @param vaultAddress - The vault address
52
+ * @param totalAssets - The total assets of the vault
53
+ * @returns The idle assets
54
+ */
55
+ export declare function getIdleAssets(provider: IContractRunner, vaultAddress: IAddress, underlying: IAddress, totalAssets: INormalizedNumber): Promise<bigint>;
56
+ export declare function getYieldLastRealizedOn(provider: IContractRunner, vaultAddress: IAddress): Promise<number>;
57
+ /**
58
+ * Format APY data from backend tokenized vault into the unified IVaultApy shape.
59
+ * Shared across all chain adapters (EVM, Solana, Stellar).
60
+ */
61
+ export declare function formatVaultApy(tokenizedVault: ITokenizedVault): IVault['apy'];
62
+ /**
63
+ * Map the backend `freshness` object onto the camelCased {@link IVaultFreshness}
64
+ * shape carried on `IVault`. Shared across all chain adapters (EVM, Solana,
65
+ * Stellar) so every surface reports provenance identically.
66
+ *
67
+ * Each of the three stamps is passed through independently: a missing member
68
+ * becomes `null` and is never defaulted from one of the others. That is the point
69
+ * of the object — `apy_computed_at` and `share_ratio_snapshot_at` describe two
70
+ * different pipelines, and collapsing them would erase the very staleness signal
71
+ * (snapshot newer than APY) the field exists to expose.
72
+ *
73
+ * @param tokenizedVault - Backend tokenized-vault payload. `freshness` is absent on
74
+ * responses predating the backend change, and may be explicitly null.
75
+ * @returns The mapped freshness object, or `null` when the backend reported none.
76
+ * Values are the backend's RFC 3339 UTC strings verbatim — no reformatting, so
77
+ * the trailing `Z` is preserved.
78
+ */
79
+ export declare function mapVaultFreshness(tokenizedVault: ITokenizedVault | undefined | null): IVaultFreshness | null;
80
+ /**
81
+ * Map strategists from backend subaccounts or hardcoded list.
82
+ * Shared across all chain adapters.
83
+ */
84
+ export declare function mapStrategists(tokenizedVault: ITokenizedVault): {
85
+ address: IAddress;
86
+ logo: string;
87
+ name: string;
88
+ type: string;
89
+ website_url: string;
90
+ }[];
91
+ /**
92
+ * Map composability integrations from backend format to vault format.
93
+ * Shared across all chain adapters.
94
+ */
95
+ export declare function mapComposabilityIntegrations(tokenizedVault: ITokenizedVault): IVault['composabilityIntegrations'];
96
+ /**
97
+ * Convert a backend-reported TVL (whole token units) to a NormalizedBn.
98
+ * Handles null, undefined, and non-finite values (NaN, Infinity) safely, defaulting to 0.
99
+ * Shared between non-EVM adapters (Solana, Stellar) and the module-level getVaultTvl handler.
100
+ */
101
+ export declare function backendTvlToNormalizedBn(tvl: number | null | undefined, decimals: number): INormalizedNumber;
102
+ /**
103
+ * Build a base IVault from backend data, shared across non-EVM adapters (Solana, Stellar).
104
+ * Chain-specific fields (chainId, version, name, totalAssets, totalSupply, depositAssets, receipt)
105
+ * must be provided via the overrides parameter.
106
+ */
107
+ export declare function buildBackendVault(tokenizedVault: ITokenizedVault, overrides: Pick<IVault, 'chainId' | 'version' | 'name' | 'totalAssets' | 'totalSupply' | 'depositAssets' | 'receipt'> & Pick<Partial<IVault>, 'programId' | 'enabled_historical_price_horizons' | 'defaultApyHorizon' | 'latest_reported_tvl' | 'isDepositPaused' | 'isWithdrawalPaused'>): IVault;
108
+ /**
109
+ * Build the formatted vault
110
+ * @param provider - The provider
111
+ * @param tokenizedVault - The tokenized vault
112
+ * @param contractCalls - The contract calls
113
+ * @returns The formatted vault
114
+ */
115
+ export declare function buildFormattedVault(provider: IContractRunner, tokenizedVault: ITokenizedVault, contractCalls: Record<IPoolFunctions, string | number | INormalizedNumber | boolean | IAddress[]>): Promise<IVault>;
116
+ export declare const ERC_20_PERMIT_HASH = "0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9";
117
+ export interface PermitSignature {
118
+ r: string;
119
+ s: string;
120
+ v: number;
121
+ deadline: number;
122
+ }
123
+ /**
124
+ * Generate an ERC2612 permit signature
125
+ * @param token - The ERC20 token contract address
126
+ * @param owner - The token owner's address (signer)
127
+ * @param spender - The address that will be approved to spend (your pool contract)
128
+ * @param value - The amount to approve
129
+ * @param deadline - Unix timestamp for when the permit expires
130
+ * @param signer - The ethers.js Signer (wallet)
131
+ * @param provider - The ethers.js Provider
132
+ * @returns The signature components (v, r, s) and deadline
133
+ */
134
+ export declare function generatePermitSignature(token: string, owner: string, spender: string, value: string | bigint, deadline: number, signer: ethers.Signer, chainId: number): Promise<PermitSignature>;
135
+ /**
136
+ * Helper to create a deadline (current time + offset in seconds)
137
+ * @param offsetSeconds - Number of seconds from now (default: 20 minutes)
138
+ * @returns Unix timestamp
139
+ */
140
+ export declare function createDeadline(offsetSeconds?: number): number;