@upshiftfinance/sdk 0.0.0-stage → 0.2.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 (344) 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/client.d.ts +83 -0
  116. package/lib/adapters/sui/client.js +216 -0
  117. package/lib/adapters/sui/constants.d.ts +33 -0
  118. package/lib/adapters/sui/constants.js +31 -0
  119. package/lib/adapters/sui/index.d.ts +57 -0
  120. package/lib/adapters/sui/index.js +100 -0
  121. package/lib/adapters/sui/targets.d.ts +171 -0
  122. package/lib/adapters/sui/targets.js +225 -0
  123. package/lib/adapters/sui/utils.d.ts +8 -0
  124. package/lib/adapters/sui/utils.js +17 -0
  125. package/lib/core/analytics/app-name.d.ts +27 -0
  126. package/lib/core/analytics/app-name.js +48 -0
  127. package/lib/core/analytics/chain-name.d.ts +9 -0
  128. package/lib/core/analytics/chain-name.js +34 -0
  129. package/lib/core/analytics/constants.d.ts +15 -0
  130. package/lib/core/analytics/constants.js +28 -0
  131. package/lib/core/analytics/env.d.ts +46 -0
  132. package/lib/core/analytics/env.js +147 -0
  133. package/lib/core/analytics/index.d.ts +39 -0
  134. package/lib/core/analytics/index.js +83 -0
  135. package/lib/core/analytics/instrumentation.d.ts +29 -0
  136. package/lib/core/analytics/instrumentation.js +292 -0
  137. package/lib/core/analytics/method-taxonomy.d.ts +19 -0
  138. package/lib/core/analytics/method-taxonomy.js +156 -0
  139. package/lib/core/analytics/metrics.d.ts +48 -0
  140. package/lib/core/analytics/metrics.js +142 -0
  141. package/lib/core/analytics/sanitize.d.ts +57 -0
  142. package/lib/core/analytics/sanitize.js +272 -0
  143. package/lib/core/analytics/sentry-runtime.d.ts +15 -0
  144. package/lib/core/analytics/sentry-runtime.js +131 -0
  145. package/lib/core/analytics/sentry.d.ts +100 -0
  146. package/lib/core/analytics/sentry.js +696 -0
  147. package/lib/core/analytics/types.d.ts +55 -0
  148. package/lib/core/analytics/types.js +3 -0
  149. package/lib/core/analytics/user-identity.d.ts +55 -0
  150. package/lib/core/analytics/user-identity.js +218 -0
  151. package/lib/core/analytics/version.d.ts +6 -0
  152. package/lib/core/analytics/version.js +10 -0
  153. package/lib/core/attribution.d.ts +159 -0
  154. package/lib/core/attribution.js +194 -0
  155. package/lib/core/auth/index.d.ts +1 -0
  156. package/lib/core/auth/index.js +18 -0
  157. package/lib/core/auth/verify.d.ts +2 -0
  158. package/lib/core/auth/verify.js +35 -0
  159. package/lib/core/base.class.d.ts +193 -0
  160. package/lib/core/base.class.js +163 -0
  161. package/lib/core/cache.d.ts +9 -0
  162. package/lib/core/cache.js +31 -0
  163. package/lib/core/constants/adapters.d.ts +103 -0
  164. package/lib/core/constants/adapters.js +180 -0
  165. package/lib/core/constants/core.d.ts +162 -0
  166. package/lib/core/constants/core.js +281 -0
  167. package/lib/core/constants/swap-router.d.ts +180 -0
  168. package/lib/core/constants/swap-router.js +203 -0
  169. package/lib/core/constants/vaults.d.ts +93 -0
  170. package/lib/core/constants/vaults.js +277 -0
  171. package/lib/core/constants/web3.d.ts +106 -0
  172. package/lib/core/constants/web3.js +251 -0
  173. package/lib/core/errors/index.d.ts +177 -0
  174. package/lib/core/errors/index.js +257 -0
  175. package/lib/core/fetcher.d.ts +237 -0
  176. package/lib/core/fetcher.js +1103 -0
  177. package/lib/core/helpers/adapters.d.ts +13 -0
  178. package/lib/core/helpers/adapters.js +39 -0
  179. package/lib/core/helpers/chain-address.d.ts +13 -0
  180. package/lib/core/helpers/chain-address.js +47 -0
  181. package/lib/core/helpers/chain-error.d.ts +207 -0
  182. package/lib/core/helpers/chain-error.js +697 -0
  183. package/lib/core/helpers/chain-support.d.ts +98 -0
  184. package/lib/core/helpers/chain-support.js +139 -0
  185. package/lib/core/helpers/concurrency.d.ts +51 -0
  186. package/lib/core/helpers/concurrency.js +79 -0
  187. package/lib/core/helpers/core.d.ts +92 -0
  188. package/lib/core/helpers/core.js +368 -0
  189. package/lib/core/helpers/explorer-link.d.ts +16 -0
  190. package/lib/core/helpers/explorer-link.js +26 -0
  191. package/lib/core/helpers/multicall.d.ts +68 -0
  192. package/lib/core/helpers/multicall.js +103 -0
  193. package/lib/core/helpers/revert-decode.d.ts +248 -0
  194. package/lib/core/helpers/revert-decode.js +515 -0
  195. package/lib/core/helpers/signer.d.ts +61 -0
  196. package/lib/core/helpers/signer.js +184 -0
  197. package/lib/core/helpers/swap-router.d.ts +269 -0
  198. package/lib/core/helpers/swap-router.js +542 -0
  199. package/lib/core/helpers/vault-version.d.ts +24 -0
  200. package/lib/core/helpers/vault-version.js +83 -0
  201. package/lib/core/helpers/vaults.d.ts +89 -0
  202. package/lib/core/helpers/vaults.js +241 -0
  203. package/lib/core/helpers/web3.d.ts +366 -0
  204. package/lib/core/helpers/web3.js +1034 -0
  205. package/lib/core/index.d.ts +23 -0
  206. package/lib/core/index.js +40 -0
  207. package/lib/core/logger/curator-alert.d.ts +217 -0
  208. package/lib/core/logger/curator-alert.js +276 -0
  209. package/lib/core/logger/index.d.ts +99 -0
  210. package/lib/core/logger/index.js +163 -0
  211. package/lib/core/logger/slack.d.ts +49 -0
  212. package/lib/core/logger/slack.js +111 -0
  213. package/lib/core/vault-metadata.d.ts +12 -0
  214. package/lib/core/vault-metadata.js +42 -0
  215. package/lib/core/version-check.d.ts +58 -0
  216. package/lib/core/version-check.js +182 -0
  217. package/lib/evm/index.d.ts +2 -0
  218. package/lib/evm/index.js +19 -0
  219. package/lib/evm/methods/crossChainVault.d.ts +132 -0
  220. package/lib/evm/methods/crossChainVault.js +857 -0
  221. package/lib/evm/methods/crossChainVaultRegistry.d.ts +92 -0
  222. package/lib/evm/methods/crossChainVaultRegistry.js +239 -0
  223. package/lib/evm/methods/index.d.ts +2 -0
  224. package/lib/evm/methods/index.js +19 -0
  225. package/lib/evm/types/crossChain.d.ts +363 -0
  226. package/lib/evm/types/crossChain.js +20 -0
  227. package/lib/evm/types/index.d.ts +1 -0
  228. package/lib/evm/types/index.js +18 -0
  229. package/lib/index.d.ts +30 -0
  230. package/lib/index.js +52 -0
  231. package/lib/main.d.ts +596 -0
  232. package/lib/main.js +681 -0
  233. package/lib/modules/api/fetcher.d.ts +108 -0
  234. package/lib/modules/api/fetcher.js +187 -0
  235. package/lib/modules/api/index.d.ts +1 -0
  236. package/lib/modules/api/index.js +6 -0
  237. package/lib/modules/api/main.d.ts +587 -0
  238. package/lib/modules/api/main.js +911 -0
  239. package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
  240. package/lib/modules/sub-accounts/fetcher.js +96 -0
  241. package/lib/modules/sub-accounts/index.d.ts +2 -0
  242. package/lib/modules/sub-accounts/index.js +19 -0
  243. package/lib/modules/sub-accounts/main.d.ts +249 -0
  244. package/lib/modules/sub-accounts/main.js +211 -0
  245. package/lib/modules/sub-accounts/utils.d.ts +106 -0
  246. package/lib/modules/sub-accounts/utils.js +112 -0
  247. package/lib/modules/vaults/adapter.helpers.d.ts +84 -0
  248. package/lib/modules/vaults/adapter.helpers.js +202 -0
  249. package/lib/modules/vaults/fetcher.d.ts +147 -0
  250. package/lib/modules/vaults/fetcher.js +357 -0
  251. package/lib/modules/vaults/getters.d.ts +1060 -0
  252. package/lib/modules/vaults/getters.js +4079 -0
  253. package/lib/modules/vaults/index.d.ts +20 -0
  254. package/lib/modules/vaults/index.js +44 -0
  255. package/lib/modules/vaults/main.d.ts +607 -0
  256. package/lib/modules/vaults/main.js +1687 -0
  257. package/lib/modules/vaults/prefetch.d.ts +65 -0
  258. package/lib/modules/vaults/prefetch.js +120 -0
  259. package/lib/modules/vaults/read.actions.d.ts +406 -0
  260. package/lib/modules/vaults/read.actions.js +891 -0
  261. package/lib/modules/vaults/types.d.ts +149 -0
  262. package/lib/modules/vaults/types.js +3 -0
  263. package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
  264. package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
  265. package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
  266. package/lib/modules/vaults/utils/date-utils.js +84 -0
  267. package/lib/modules/vaults/utils.d.ts +153 -0
  268. package/lib/modules/vaults/utils.js +818 -0
  269. package/lib/modules/vaults/write.actions.d.ts +812 -0
  270. package/lib/modules/vaults/write.actions.js +2377 -0
  271. package/lib/polyfills.d.ts +1 -0
  272. package/lib/polyfills.js +12 -0
  273. package/lib/sdk.d.ts +30173 -0
  274. package/lib/services/coingecko/fetcher.d.ts +15 -0
  275. package/lib/services/coingecko/fetcher.js +67 -0
  276. package/lib/services/coingecko/index.d.ts +2 -0
  277. package/lib/services/coingecko/index.js +19 -0
  278. package/lib/services/coingecko/utils.d.ts +1 -0
  279. package/lib/services/coingecko/utils.js +24 -0
  280. package/lib/services/debank/fetcher.d.ts +126 -0
  281. package/lib/services/debank/fetcher.js +47 -0
  282. package/lib/services/debank/index.d.ts +2 -0
  283. package/lib/services/debank/index.js +19 -0
  284. package/lib/services/debank/utils.d.ts +50 -0
  285. package/lib/services/debank/utils.js +325 -0
  286. package/lib/services/layerzero/deposits.d.ts +55 -0
  287. package/lib/services/layerzero/deposits.js +174 -0
  288. package/lib/services/layerzero/redeems.d.ts +20 -0
  289. package/lib/services/layerzero/redeems.js +92 -0
  290. package/lib/services/layerzero/utils.d.ts +9 -0
  291. package/lib/services/layerzero/utils.js +22 -0
  292. package/lib/services/octavfi/fetcher.d.ts +33 -0
  293. package/lib/services/octavfi/fetcher.js +39 -0
  294. package/lib/services/octavfi/index.d.ts +3 -0
  295. package/lib/services/octavfi/index.js +20 -0
  296. package/lib/services/octavfi/types.d.ts +34 -0
  297. package/lib/services/octavfi/types.js +3 -0
  298. package/lib/services/octavfi/utils.d.ts +16 -0
  299. package/lib/services/octavfi/utils.js +244 -0
  300. package/lib/services/subgraph/fetcher.d.ts +2 -0
  301. package/lib/services/subgraph/fetcher.js +66 -0
  302. package/lib/services/subgraph/index.d.ts +2 -0
  303. package/lib/services/subgraph/index.js +19 -0
  304. package/lib/services/subgraph/schema.d.ts +48 -0
  305. package/lib/services/subgraph/schema.js +87 -0
  306. package/lib/services/subgraph/vaults.d.ts +83 -0
  307. package/lib/services/subgraph/vaults.js +1282 -0
  308. package/lib/services/swap-quotes/index.d.ts +105 -0
  309. package/lib/services/swap-quotes/index.js +77 -0
  310. package/lib/services/swap-quotes/paraswap.d.ts +51 -0
  311. package/lib/services/swap-quotes/paraswap.js +138 -0
  312. package/lib/services/untangled/fetcher.d.ts +40 -0
  313. package/lib/services/untangled/fetcher.js +110 -0
  314. package/lib/services/untangled/index.d.ts +3 -0
  315. package/lib/services/untangled/index.js +20 -0
  316. package/lib/services/untangled/types.d.ts +83 -0
  317. package/lib/services/untangled/types.js +10 -0
  318. package/lib/services/untangled/utils.d.ts +91 -0
  319. package/lib/services/untangled/utils.js +339 -0
  320. package/lib/types/api.d.ts +498 -0
  321. package/lib/types/api.js +3 -0
  322. package/lib/types/index.d.ts +12 -0
  323. package/lib/types/index.js +28 -0
  324. package/lib/types/points.d.ts +28 -0
  325. package/lib/types/points.js +3 -0
  326. package/lib/types/pools.d.ts +144 -0
  327. package/lib/types/pools.js +3 -0
  328. package/lib/types/staking.d.ts +28 -0
  329. package/lib/types/staking.js +3 -0
  330. package/lib/types/sub-accounts.d.ts +150 -0
  331. package/lib/types/sub-accounts.js +3 -0
  332. package/lib/types/subgraph.d.ts +84 -0
  333. package/lib/types/subgraph.js +3 -0
  334. package/lib/types/typed-contract.d.ts +102 -0
  335. package/lib/types/typed-contract.js +3 -0
  336. package/lib/types/user.d.ts +1 -0
  337. package/lib/types/user.js +3 -0
  338. package/lib/types/vaults.d.ts +886 -0
  339. package/lib/types/vaults.js +30 -0
  340. package/lib/types/web3.d.ts +100 -0
  341. package/lib/types/web3.js +14 -0
  342. package/lib/types/webserver.d.ts +730 -0
  343. package/lib/types/webserver.js +3 -0
  344. package/package.json +79 -3
@@ -0,0 +1,149 @@
1
+ import type { Connection } from '@solana/web3.js';
2
+ import type { IAddress, IEnv, ISolanaNetwork, IStellarNetwork, IWSMonitorHeaders } from '../../types';
3
+ /**
4
+ * Structural interface for the Solana adapter surface used by vault operations.
5
+ * Avoids importing the concrete SolanaAdapter class to prevent circular dependencies.
6
+ */
7
+ export interface ISolanaService {
8
+ connection: Connection;
9
+ getVaultState: (vaultProgramId: any, idl: any, vaultAddress?: any) => Promise<any>;
10
+ fetchUserShareBalance: (publicKey: any, shareMint: any) => Promise<any>;
11
+ /**
12
+ * Raw (BigInt-safe) variant. Required — `fetchUserShareBalance` alone
13
+ * returns a JS-number `uiAmount` which is lossy and silently encodes
14
+ * against 18 decimals when fed back through `toNormalizedBn` without an
15
+ * explicit decimals argument. Every consumer that needs a correct
16
+ * `walletBalance.raw` (positions, redemptions, max actions) MUST use this
17
+ * entry point.
18
+ *
19
+ * Returns `{ amount, decimals }`:
20
+ * - `amount` is the on-chain u64 as a base-units string (always set;
21
+ * `'0'` when no balance / no account / no args / RPC failure).
22
+ * - `decimals` matches the mint when a parsed `tokenAmount` is
23
+ * available; otherwise **`null`**. `decimals === null` is the
24
+ * "scale unknown" signal — callers must substitute a known decimals
25
+ * value (typically the deposit mint's decimals from backend metadata)
26
+ * before constructing an `INormalizedNumber`. Never throws.
27
+ */
28
+ fetchUserShareBalanceRaw: (publicKey: any, shareMint: any) => Promise<{
29
+ amount: string;
30
+ decimals: number | null;
31
+ }>;
32
+ /**
33
+ * Canonical program id for this service's network, as
34
+ * `SolanaAdapter.getProgramId`. Optional so a hand-built service keeps
35
+ * working: without it the withdrawal-queue reads are skipped, and vaults and
36
+ * positions come back without queue data.
37
+ */
38
+ getProgramId?: (type: 'vault' | 'withdrawalQueue') => string;
39
+ /**
40
+ * This service's network, as `SolanaAdapter.network`. When present, the
41
+ * withdrawal-queue reads look the queue program up in `programIds` directly
42
+ * instead of calling `getProgramId`.
43
+ */
44
+ network?: ISolanaNetwork;
45
+ }
46
+ /**
47
+ * Base configuration for vault operations.
48
+ */
49
+ export interface IVaultBaseOptions {
50
+ rpcUrl: string;
51
+ env?: IEnv;
52
+ upshiftKey?: string;
53
+ subgraphKey?: string;
54
+ chainId?: number;
55
+ solanaService?: ISolanaService;
56
+ /**
57
+ * Optional Soroban RPC override (e.g. a keyed Alchemy URL) for Stellar vault
58
+ * reads, threaded from the SDK's `stellar` config. Carries the network it was
59
+ * configured for so it is only applied to matching-network vaults — a testnet
60
+ * override must not be used for a mainnet read. Unset → built-in endpoints.
61
+ */
62
+ stellarRpc?: {
63
+ rpcUrl: string;
64
+ network: IStellarNetwork;
65
+ };
66
+ headers?: IWSMonitorHeaders;
67
+ /**
68
+ * Portfolio mode: when true, the per-vault EVM getter does NOT null out a
69
+ * closed + invisible vault. Needed so a user's position in a closed,
70
+ * invisible vault can still resolve its metadata. Defaults to undefined
71
+ * (false) so marketplace/discovery reads keep hiding closed staging vaults.
72
+ */
73
+ includeClosed?: boolean;
74
+ }
75
+ /**
76
+ * Optional enrichment options for vault queries.
77
+ */
78
+ export interface IVaultCustomOptions {
79
+ loans?: boolean;
80
+ allocations?: boolean;
81
+ wallet?: IAddress;
82
+ solanaWallet?: string;
83
+ stellarWallet?: string;
84
+ /**
85
+ * Portfolio mode for a SINGLE vault read: when true, a `closed` +
86
+ * `is_visible: false` vault resolves normally instead of coming back as
87
+ * null. Needed by any caller reading ONE vault by address on behalf of a
88
+ * holder — a position in a closed vault must still resolve its metadata, or
89
+ * the holder is left with no way to act on it.
90
+ *
91
+ * The plural counterpart is {@link IGetVaultsOptions.includeClosed}; this is
92
+ * the same flag on the per-address path.
93
+ *
94
+ * @default false
95
+ */
96
+ includeClosed?: boolean;
97
+ }
98
+ /**
99
+ * Options accepted by `getVaults` — on both the `UpshiftSDK` facade and the
100
+ * underlying `UpshiftVaults` module. Defined once so the two signatures cannot
101
+ * drift (the facade previously declared a narrower inline type that rejected
102
+ * documented options like `includeClosed` at compile time).
103
+ */
104
+ export interface IGetVaultsOptions extends IVaultCustomOptions {
105
+ chainIds?: number[];
106
+ headers?: IWSMonitorHeaders;
107
+ loadSubaccounts?: boolean;
108
+ loadSnapshots?: boolean;
109
+ /**
110
+ * Portfolio mode: include closed vaults in the result.
111
+ *
112
+ * By default (`false`) closed vaults are excluded, so marketplace /
113
+ * discovery callers never receive a `status: 'closed'` vault. When set,
114
+ * closed vaults are returned regardless of `is_visible` (closed +
115
+ * invisible vaults bucket as closed), so a consumer joining user
116
+ * positions can render a position held in a closed vault on the
117
+ * portfolio page.
118
+ *
119
+ * In this mode, loans/allocations enrichment is also skipped for closed
120
+ * vaults: they have none, and the per-vault enrichment
121
+ * (`getVault` → `getVaultAllocations`) otherwise re-throws when a closed
122
+ * vault has no live strategy/debank data or no subaccounts, which would
123
+ * land the vault in the `failed` bucket and silently drop it before it
124
+ * reaches the filter. Skipping enrichment lets the vault survive on its
125
+ * backend metadata + base on-chain read.
126
+ *
127
+ * @default false
128
+ */
129
+ includeClosed?: boolean;
130
+ /**
131
+ * Maximum primary-fetch attempts per vault before the fallback
132
+ * strategies (fallback RPCs, minimal fetch, extended retry) run.
133
+ * Attempt `n` waits `baseDelay * 2^(n-1)` ms before retrying, so the
134
+ * default (5 attempts, 2000 ms base) can spend up to 30s of backoff on
135
+ * a single persistently-failing vault. Callers racing this method
136
+ * against their own timeout should lower it (e.g. `2`) so one flaky
137
+ * vault cannot exhaust the whole budget.
138
+ *
139
+ * @default 5
140
+ */
141
+ maxRetries?: number;
142
+ /**
143
+ * Base backoff delay in **milliseconds** for the per-vault retry
144
+ * schedule (see `maxRetries`).
145
+ *
146
+ * @default 2000
147
+ */
148
+ baseDelay?: number;
149
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -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