@upshiftfinance/sdk 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +408 -2
  3. package/lib/abis/AddressResolver.d.ts +28 -0
  4. package/lib/abis/AddressResolver.js +23 -0
  5. package/lib/abis/ChainlinkV3.d.ts +87 -0
  6. package/lib/abis/ChainlinkV3.js +117 -0
  7. package/lib/abis/ERC20.d.ts +168 -0
  8. package/lib/abis/ERC20.js +226 -0
  9. package/lib/abis/ERC20_Bytes32.d.ts +139 -0
  10. package/lib/abis/ERC20_Bytes32.js +196 -0
  11. package/lib/abis/ERC4626.d.ts +364 -0
  12. package/lib/abis/ERC4626.js +507 -0
  13. package/lib/abis/ERC721.d.ts +231 -0
  14. package/lib/abis/ERC721.js +321 -0
  15. package/lib/abis/FeeOracle.d.ts +120 -0
  16. package/lib/abis/FeeOracle.js +162 -0
  17. package/lib/abis/LendingPool.d.ts +1393 -0
  18. package/lib/abis/LendingPool.js +1807 -0
  19. package/lib/abis/LendingPoolV2.d.ts +1413 -0
  20. package/lib/abis/LendingPoolV2.js +1833 -0
  21. package/lib/abis/LendingPoolV3.d.ts +1677 -0
  22. package/lib/abis/LendingPoolV3.js +1160 -0
  23. package/lib/abis/Loan.d.ts +837 -0
  24. package/lib/abis/Loan.js +1080 -0
  25. package/lib/abis/MultiAssetNativeDepositWrapper.d.ts +137 -0
  26. package/lib/abis/MultiAssetNativeDepositWrapper.js +125 -0
  27. package/lib/abis/Multicall3.d.ts +30 -0
  28. package/lib/abis/Multicall3.js +97 -0
  29. package/lib/abis/OFT.d.ts +116 -0
  30. package/lib/abis/OFT.js +85 -0
  31. package/lib/abis/PoolAdapter.d.ts +36 -0
  32. package/lib/abis/PoolAdapter.js +51 -0
  33. package/lib/abis/RewardDistributor.d.ts +267 -0
  34. package/lib/abis/RewardDistributor.js +352 -0
  35. package/lib/abis/RwaRedeemSubaccount.d.ts +747 -0
  36. package/lib/abis/RwaRedeemSubaccount.js +548 -0
  37. package/lib/abis/SmartAccount.d.ts +17 -0
  38. package/lib/abis/SmartAccount.js +19 -0
  39. package/lib/abis/SwapRouter.d.ts +953 -0
  40. package/lib/abis/SwapRouter.js +1228 -0
  41. package/lib/abis/TextResolver.d.ts +16 -0
  42. package/lib/abis/TextResolver.js +16 -0
  43. package/lib/abis/TokenizedVaultV2.d.ts +1364 -0
  44. package/lib/abis/TokenizedVaultV2.js +1041 -0
  45. package/lib/abis/TokenizedVaultV2DepositWithPermit.d.ts +1456 -0
  46. package/lib/abis/TokenizedVaultV2DepositWithPermit.js +1878 -0
  47. package/lib/abis/TokenizedVaultV2Receipt.d.ts +1568 -0
  48. package/lib/abis/TokenizedVaultV2Receipt.js +1061 -0
  49. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.d.ts +454 -0
  50. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js +327 -0
  51. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.d.ts +1466 -0
  52. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js +1092 -0
  53. package/lib/abis/TokenizedVaultV2WhitelistedAssets.d.ts +274 -0
  54. package/lib/abis/TokenizedVaultV2WhitelistedAssets.js +167 -0
  55. package/lib/abis/UniversalResolverResolve.d.ts +69 -0
  56. package/lib/abis/UniversalResolverResolve.js +35 -0
  57. package/lib/abis/UniversalSignatureValidator.d.ts +17 -0
  58. package/lib/abis/UniversalSignatureValidator.js +30 -0
  59. package/lib/abis/WrapperAdapter.d.ts +71 -0
  60. package/lib/abis/WrapperAdapter.js +77 -0
  61. package/lib/abis/index.d.ts +34 -0
  62. package/lib/abis/index.js +51 -0
  63. package/lib/adapters/evm/getters.d.ts +19 -0
  64. package/lib/adapters/evm/getters.js +249 -0
  65. package/lib/adapters/evm/index.d.ts +539 -0
  66. package/lib/adapters/evm/index.js +656 -0
  67. package/lib/adapters/evm/utils.d.ts +8 -0
  68. package/lib/adapters/evm/utils.js +51 -0
  69. package/lib/adapters/solana/confirm.d.ts +88 -0
  70. package/lib/adapters/solana/confirm.js +291 -0
  71. package/lib/adapters/solana/constants.d.ts +42 -0
  72. package/lib/adapters/solana/constants.js +59 -0
  73. package/lib/adapters/solana/getters.d.ts +42 -0
  74. package/lib/adapters/solana/getters.js +275 -0
  75. package/lib/adapters/solana/idl/vault-idl.d.ts +700 -0
  76. package/lib/adapters/solana/idl/vault-idl.js +2101 -0
  77. package/lib/adapters/solana/idl/withdrawal-queue-idl.d.ts +795 -0
  78. package/lib/adapters/solana/idl/withdrawal-queue-idl.js +1864 -0
  79. package/lib/adapters/solana/index.d.ts +372 -0
  80. package/lib/adapters/solana/index.js +459 -0
  81. package/lib/adapters/solana/pricing.d.ts +184 -0
  82. package/lib/adapters/solana/pricing.js +239 -0
  83. package/lib/adapters/solana/queue-hints.d.ts +29 -0
  84. package/lib/adapters/solana/queue-hints.js +59 -0
  85. package/lib/adapters/solana/queue.actions.d.ts +97 -0
  86. package/lib/adapters/solana/queue.actions.js +468 -0
  87. package/lib/adapters/solana/token-reads.d.ts +108 -0
  88. package/lib/adapters/solana/token-reads.js +145 -0
  89. package/lib/adapters/solana/types.d.ts +325 -0
  90. package/lib/adapters/solana/types.js +3 -0
  91. package/lib/adapters/solana/utils.d.ts +229 -0
  92. package/lib/adapters/solana/utils.js +773 -0
  93. package/lib/adapters/solana/vault.actions.d.ts +140 -0
  94. package/lib/adapters/solana/vault.actions.js +657 -0
  95. package/lib/adapters/solana/withdrawal-queue.d.ts +125 -0
  96. package/lib/adapters/solana/withdrawal-queue.js +301 -0
  97. package/lib/adapters/stellar/actions.d.ts +41 -0
  98. package/lib/adapters/stellar/actions.js +126 -0
  99. package/lib/adapters/stellar/constants.d.ts +43 -0
  100. package/lib/adapters/stellar/constants.js +53 -0
  101. package/lib/adapters/stellar/getters.d.ts +68 -0
  102. package/lib/adapters/stellar/getters.js +290 -0
  103. package/lib/adapters/stellar/index.d.ts +126 -0
  104. package/lib/adapters/stellar/index.js +187 -0
  105. package/lib/adapters/stellar/invocation.d.ts +55 -0
  106. package/lib/adapters/stellar/invocation.js +92 -0
  107. package/lib/adapters/stellar/soroban.d.ts +131 -0
  108. package/lib/adapters/stellar/soroban.js +617 -0
  109. package/lib/adapters/stellar/submit.d.ts +42 -0
  110. package/lib/adapters/stellar/submit.js +195 -0
  111. package/lib/adapters/stellar/types.d.ts +57 -0
  112. package/lib/adapters/stellar/types.js +6 -0
  113. package/lib/adapters/stellar/utils.d.ts +24 -0
  114. package/lib/adapters/stellar/utils.js +34 -0
  115. package/lib/adapters/sui/constants.d.ts +1 -0
  116. package/lib/adapters/sui/constants.js +9 -0
  117. package/lib/adapters/sui/getters.d.ts +24 -0
  118. package/lib/adapters/sui/getters.js +134 -0
  119. package/lib/adapters/sui/index.d.ts +53 -0
  120. package/lib/adapters/sui/index.js +96 -0
  121. package/lib/adapters/sui/transformer.d.ts +10 -0
  122. package/lib/adapters/sui/transformer.js +115 -0
  123. package/lib/adapters/sui/types.d.ts +70 -0
  124. package/lib/adapters/sui/types.js +3 -0
  125. package/lib/adapters/sui/utils.d.ts +8 -0
  126. package/lib/adapters/sui/utils.js +17 -0
  127. package/lib/core/analytics/app-name.d.ts +27 -0
  128. package/lib/core/analytics/app-name.js +48 -0
  129. package/lib/core/analytics/chain-name.d.ts +9 -0
  130. package/lib/core/analytics/chain-name.js +34 -0
  131. package/lib/core/analytics/constants.d.ts +15 -0
  132. package/lib/core/analytics/constants.js +28 -0
  133. package/lib/core/analytics/env.d.ts +46 -0
  134. package/lib/core/analytics/env.js +147 -0
  135. package/lib/core/analytics/index.d.ts +39 -0
  136. package/lib/core/analytics/index.js +83 -0
  137. package/lib/core/analytics/instrumentation.d.ts +29 -0
  138. package/lib/core/analytics/instrumentation.js +292 -0
  139. package/lib/core/analytics/method-taxonomy.d.ts +19 -0
  140. package/lib/core/analytics/method-taxonomy.js +156 -0
  141. package/lib/core/analytics/metrics.d.ts +48 -0
  142. package/lib/core/analytics/metrics.js +142 -0
  143. package/lib/core/analytics/sanitize.d.ts +57 -0
  144. package/lib/core/analytics/sanitize.js +272 -0
  145. package/lib/core/analytics/sentry-runtime.d.ts +15 -0
  146. package/lib/core/analytics/sentry-runtime.js +131 -0
  147. package/lib/core/analytics/sentry.d.ts +100 -0
  148. package/lib/core/analytics/sentry.js +696 -0
  149. package/lib/core/analytics/types.d.ts +55 -0
  150. package/lib/core/analytics/types.js +3 -0
  151. package/lib/core/analytics/user-identity.d.ts +55 -0
  152. package/lib/core/analytics/user-identity.js +218 -0
  153. package/lib/core/analytics/version.d.ts +6 -0
  154. package/lib/core/analytics/version.js +10 -0
  155. package/lib/core/attribution.d.ts +159 -0
  156. package/lib/core/attribution.js +194 -0
  157. package/lib/core/auth/index.d.ts +1 -0
  158. package/lib/core/auth/index.js +18 -0
  159. package/lib/core/auth/verify.d.ts +2 -0
  160. package/lib/core/auth/verify.js +35 -0
  161. package/lib/core/base.class.d.ts +193 -0
  162. package/lib/core/base.class.js +163 -0
  163. package/lib/core/cache.d.ts +9 -0
  164. package/lib/core/cache.js +31 -0
  165. package/lib/core/constants/adapters.d.ts +103 -0
  166. package/lib/core/constants/adapters.js +180 -0
  167. package/lib/core/constants/core.d.ts +162 -0
  168. package/lib/core/constants/core.js +281 -0
  169. package/lib/core/constants/swap-router.d.ts +180 -0
  170. package/lib/core/constants/swap-router.js +203 -0
  171. package/lib/core/constants/vaults.d.ts +93 -0
  172. package/lib/core/constants/vaults.js +277 -0
  173. package/lib/core/constants/web3.d.ts +106 -0
  174. package/lib/core/constants/web3.js +251 -0
  175. package/lib/core/errors/index.d.ts +177 -0
  176. package/lib/core/errors/index.js +257 -0
  177. package/lib/core/fetcher.d.ts +237 -0
  178. package/lib/core/fetcher.js +1103 -0
  179. package/lib/core/helpers/adapters.d.ts +13 -0
  180. package/lib/core/helpers/adapters.js +39 -0
  181. package/lib/core/helpers/chain-address.d.ts +13 -0
  182. package/lib/core/helpers/chain-address.js +47 -0
  183. package/lib/core/helpers/chain-error.d.ts +207 -0
  184. package/lib/core/helpers/chain-error.js +697 -0
  185. package/lib/core/helpers/chain-support.d.ts +98 -0
  186. package/lib/core/helpers/chain-support.js +139 -0
  187. package/lib/core/helpers/concurrency.d.ts +51 -0
  188. package/lib/core/helpers/concurrency.js +79 -0
  189. package/lib/core/helpers/core.d.ts +92 -0
  190. package/lib/core/helpers/core.js +368 -0
  191. package/lib/core/helpers/explorer-link.d.ts +16 -0
  192. package/lib/core/helpers/explorer-link.js +26 -0
  193. package/lib/core/helpers/multicall.d.ts +68 -0
  194. package/lib/core/helpers/multicall.js +103 -0
  195. package/lib/core/helpers/revert-decode.d.ts +248 -0
  196. package/lib/core/helpers/revert-decode.js +515 -0
  197. package/lib/core/helpers/signer.d.ts +61 -0
  198. package/lib/core/helpers/signer.js +184 -0
  199. package/lib/core/helpers/swap-router.d.ts +269 -0
  200. package/lib/core/helpers/swap-router.js +542 -0
  201. package/lib/core/helpers/vault-version.d.ts +24 -0
  202. package/lib/core/helpers/vault-version.js +83 -0
  203. package/lib/core/helpers/vaults.d.ts +89 -0
  204. package/lib/core/helpers/vaults.js +241 -0
  205. package/lib/core/helpers/web3.d.ts +366 -0
  206. package/lib/core/helpers/web3.js +1034 -0
  207. package/lib/core/index.d.ts +23 -0
  208. package/lib/core/index.js +40 -0
  209. package/lib/core/logger/curator-alert.d.ts +217 -0
  210. package/lib/core/logger/curator-alert.js +276 -0
  211. package/lib/core/logger/index.d.ts +99 -0
  212. package/lib/core/logger/index.js +163 -0
  213. package/lib/core/logger/slack.d.ts +49 -0
  214. package/lib/core/logger/slack.js +111 -0
  215. package/lib/core/vault-metadata.d.ts +12 -0
  216. package/lib/core/vault-metadata.js +42 -0
  217. package/lib/core/version-check.d.ts +58 -0
  218. package/lib/core/version-check.js +182 -0
  219. package/lib/evm/index.d.ts +2 -0
  220. package/lib/evm/index.js +19 -0
  221. package/lib/evm/methods/crossChainVault.d.ts +132 -0
  222. package/lib/evm/methods/crossChainVault.js +857 -0
  223. package/lib/evm/methods/crossChainVaultRegistry.d.ts +92 -0
  224. package/lib/evm/methods/crossChainVaultRegistry.js +239 -0
  225. package/lib/evm/methods/index.d.ts +2 -0
  226. package/lib/evm/methods/index.js +19 -0
  227. package/lib/evm/types/crossChain.d.ts +363 -0
  228. package/lib/evm/types/crossChain.js +20 -0
  229. package/lib/evm/types/index.d.ts +1 -0
  230. package/lib/evm/types/index.js +18 -0
  231. package/lib/index.d.ts +30 -0
  232. package/lib/index.js +52 -0
  233. package/lib/main.d.ts +596 -0
  234. package/lib/main.js +681 -0
  235. package/lib/modules/api/fetcher.d.ts +108 -0
  236. package/lib/modules/api/fetcher.js +187 -0
  237. package/lib/modules/api/index.d.ts +1 -0
  238. package/lib/modules/api/index.js +6 -0
  239. package/lib/modules/api/main.d.ts +587 -0
  240. package/lib/modules/api/main.js +911 -0
  241. package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
  242. package/lib/modules/sub-accounts/fetcher.js +96 -0
  243. package/lib/modules/sub-accounts/index.d.ts +2 -0
  244. package/lib/modules/sub-accounts/index.js +19 -0
  245. package/lib/modules/sub-accounts/main.d.ts +249 -0
  246. package/lib/modules/sub-accounts/main.js +211 -0
  247. package/lib/modules/sub-accounts/utils.d.ts +106 -0
  248. package/lib/modules/sub-accounts/utils.js +112 -0
  249. package/lib/modules/vaults/adapter.helpers.d.ts +84 -0
  250. package/lib/modules/vaults/adapter.helpers.js +202 -0
  251. package/lib/modules/vaults/fetcher.d.ts +147 -0
  252. package/lib/modules/vaults/fetcher.js +357 -0
  253. package/lib/modules/vaults/getters.d.ts +1060 -0
  254. package/lib/modules/vaults/getters.js +4079 -0
  255. package/lib/modules/vaults/index.d.ts +20 -0
  256. package/lib/modules/vaults/index.js +44 -0
  257. package/lib/modules/vaults/main.d.ts +607 -0
  258. package/lib/modules/vaults/main.js +1687 -0
  259. package/lib/modules/vaults/prefetch.d.ts +65 -0
  260. package/lib/modules/vaults/prefetch.js +120 -0
  261. package/lib/modules/vaults/read.actions.d.ts +406 -0
  262. package/lib/modules/vaults/read.actions.js +891 -0
  263. package/lib/modules/vaults/types.d.ts +149 -0
  264. package/lib/modules/vaults/types.js +3 -0
  265. package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
  266. package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
  267. package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
  268. package/lib/modules/vaults/utils/date-utils.js +84 -0
  269. package/lib/modules/vaults/utils.d.ts +153 -0
  270. package/lib/modules/vaults/utils.js +818 -0
  271. package/lib/modules/vaults/write.actions.d.ts +812 -0
  272. package/lib/modules/vaults/write.actions.js +2377 -0
  273. package/lib/polyfills.d.ts +1 -0
  274. package/lib/polyfills.js +12 -0
  275. package/lib/sdk.d.ts +30154 -0
  276. package/lib/services/coingecko/fetcher.d.ts +15 -0
  277. package/lib/services/coingecko/fetcher.js +67 -0
  278. package/lib/services/coingecko/index.d.ts +2 -0
  279. package/lib/services/coingecko/index.js +19 -0
  280. package/lib/services/coingecko/utils.d.ts +1 -0
  281. package/lib/services/coingecko/utils.js +24 -0
  282. package/lib/services/debank/fetcher.d.ts +126 -0
  283. package/lib/services/debank/fetcher.js +47 -0
  284. package/lib/services/debank/index.d.ts +2 -0
  285. package/lib/services/debank/index.js +19 -0
  286. package/lib/services/debank/utils.d.ts +50 -0
  287. package/lib/services/debank/utils.js +325 -0
  288. package/lib/services/layerzero/deposits.d.ts +55 -0
  289. package/lib/services/layerzero/deposits.js +174 -0
  290. package/lib/services/layerzero/redeems.d.ts +20 -0
  291. package/lib/services/layerzero/redeems.js +92 -0
  292. package/lib/services/layerzero/utils.d.ts +9 -0
  293. package/lib/services/layerzero/utils.js +22 -0
  294. package/lib/services/octavfi/fetcher.d.ts +33 -0
  295. package/lib/services/octavfi/fetcher.js +39 -0
  296. package/lib/services/octavfi/index.d.ts +3 -0
  297. package/lib/services/octavfi/index.js +20 -0
  298. package/lib/services/octavfi/types.d.ts +34 -0
  299. package/lib/services/octavfi/types.js +3 -0
  300. package/lib/services/octavfi/utils.d.ts +16 -0
  301. package/lib/services/octavfi/utils.js +244 -0
  302. package/lib/services/subgraph/fetcher.d.ts +2 -0
  303. package/lib/services/subgraph/fetcher.js +66 -0
  304. package/lib/services/subgraph/index.d.ts +2 -0
  305. package/lib/services/subgraph/index.js +19 -0
  306. package/lib/services/subgraph/schema.d.ts +48 -0
  307. package/lib/services/subgraph/schema.js +87 -0
  308. package/lib/services/subgraph/vaults.d.ts +83 -0
  309. package/lib/services/subgraph/vaults.js +1282 -0
  310. package/lib/services/swap-quotes/index.d.ts +105 -0
  311. package/lib/services/swap-quotes/index.js +77 -0
  312. package/lib/services/swap-quotes/paraswap.d.ts +51 -0
  313. package/lib/services/swap-quotes/paraswap.js +138 -0
  314. package/lib/services/untangled/fetcher.d.ts +40 -0
  315. package/lib/services/untangled/fetcher.js +110 -0
  316. package/lib/services/untangled/index.d.ts +3 -0
  317. package/lib/services/untangled/index.js +20 -0
  318. package/lib/services/untangled/types.d.ts +83 -0
  319. package/lib/services/untangled/types.js +10 -0
  320. package/lib/services/untangled/utils.d.ts +91 -0
  321. package/lib/services/untangled/utils.js +339 -0
  322. package/lib/types/api.d.ts +498 -0
  323. package/lib/types/api.js +3 -0
  324. package/lib/types/index.d.ts +12 -0
  325. package/lib/types/index.js +28 -0
  326. package/lib/types/points.d.ts +28 -0
  327. package/lib/types/points.js +3 -0
  328. package/lib/types/pools.d.ts +144 -0
  329. package/lib/types/pools.js +3 -0
  330. package/lib/types/staking.d.ts +28 -0
  331. package/lib/types/staking.js +3 -0
  332. package/lib/types/sub-accounts.d.ts +150 -0
  333. package/lib/types/sub-accounts.js +3 -0
  334. package/lib/types/subgraph.d.ts +84 -0
  335. package/lib/types/subgraph.js +3 -0
  336. package/lib/types/typed-contract.d.ts +102 -0
  337. package/lib/types/typed-contract.js +3 -0
  338. package/lib/types/user.d.ts +1 -0
  339. package/lib/types/user.js +3 -0
  340. package/lib/types/vaults.d.ts +886 -0
  341. package/lib/types/vaults.js +30 -0
  342. package/lib/types/web3.d.ts +81 -0
  343. package/lib/types/web3.js +14 -0
  344. package/lib/types/webserver.d.ts +730 -0
  345. package/lib/types/webserver.js +3 -0
  346. package/package.json +78 -3
@@ -0,0 +1,106 @@
1
+ import type { IWSSubaccountSummary } from '../../types';
2
+ /**
3
+ * Transform the raw API response to camelCase
4
+ */
5
+ export declare const transformSubaccountSummary: (response: IWSSubaccountSummary) => {
6
+ address: `0x${string}`;
7
+ name: string;
8
+ type: "eoa" | "subaccount";
9
+ portfolio: {
10
+ tokens: {
11
+ value: number;
12
+ balance: number;
13
+ token: {
14
+ type: string;
15
+ name: string;
16
+ address: string;
17
+ chain: number;
18
+ symbol: string;
19
+ decimals: number;
20
+ imgUrl: string;
21
+ };
22
+ }[];
23
+ marginBalances: unknown[];
24
+ collateralBalances: unknown[];
25
+ cefiPositions: unknown[];
26
+ defiPositions: unknown[];
27
+ trsPositions: unknown[];
28
+ strategyContractPositions: unknown[];
29
+ legacyHedgerPositions: unknown[];
30
+ otcPositions: unknown[];
31
+ totalValue: number;
32
+ discountedValue: number;
33
+ };
34
+ loanbook: {
35
+ loans: {
36
+ subaccountAddress: `0x${string}`;
37
+ book: {
38
+ address: `0x${string}`;
39
+ lender: `0x${string}`;
40
+ borrower: `0x${string}`;
41
+ state: string;
42
+ totalRepaid: number;
43
+ principalToken: {
44
+ type: string;
45
+ name: string;
46
+ address: string;
47
+ chain: number;
48
+ symbol: string;
49
+ decimals: number;
50
+ imgUrl: string;
51
+ tokenType: number;
52
+ discountFactor: number;
53
+ price: number;
54
+ };
55
+ principalAmount: number;
56
+ interestAmount: number;
57
+ upcomingPayment: {
58
+ amount: number;
59
+ dueDate: string;
60
+ };
61
+ apr: number;
62
+ initialPrincipalAmount: number;
63
+ deployedDate: string;
64
+ paymentInterval: number;
65
+ totalInterestPaymentFees: number;
66
+ };
67
+ isBorrow: boolean;
68
+ debtInfo: {
69
+ interestOwed: number;
70
+ principalDebtOwed: number;
71
+ interestRepaid: number;
72
+ };
73
+ creditInfo: {
74
+ netInterestOwed: number;
75
+ principalDebtOwed: number;
76
+ netInterestRepaid: number;
77
+ };
78
+ }[];
79
+ totalDebt: number;
80
+ totalCredit: number;
81
+ aggregatesByToken: unknown[];
82
+ };
83
+ chains: {
84
+ name: string;
85
+ chainId: number;
86
+ }[];
87
+ tokens: {
88
+ type: string;
89
+ name: string;
90
+ address: string;
91
+ chain: number;
92
+ symbol: string;
93
+ decimals: number;
94
+ imgUrl: string;
95
+ price: number;
96
+ rawBalance: number;
97
+ balance: number;
98
+ value: number;
99
+ }[];
100
+ totalAccountValue: number;
101
+ totalCollateralValue: number;
102
+ totalLoanValue: number;
103
+ healthFactor: number;
104
+ netAccountValue: number;
105
+ totalEquityValue: number;
106
+ };
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformSubaccountSummary = void 0;
4
+ /**
5
+ * Transform the raw API response to camelCase
6
+ */
7
+ const transformSubaccountSummary = (response) => {
8
+ return {
9
+ address: response.address,
10
+ name: response.name,
11
+ type: response.type,
12
+ portfolio: {
13
+ tokens: response.portfolio.tokens.map((t) => ({
14
+ value: t.value,
15
+ balance: t.balance,
16
+ token: {
17
+ type: t.token.type,
18
+ name: t.token.name,
19
+ address: t.token.address,
20
+ chain: t.token.chain,
21
+ symbol: t.token.symbol,
22
+ decimals: t.token.decimals,
23
+ imgUrl: t.token.img_url,
24
+ },
25
+ })),
26
+ marginBalances: response.portfolio.margin_balances,
27
+ collateralBalances: response.portfolio.collateral_balances,
28
+ cefiPositions: response.portfolio.cefi_positions,
29
+ defiPositions: response.portfolio.defi_positions,
30
+ trsPositions: response.portfolio.trs_positions,
31
+ strategyContractPositions: response.portfolio.strategy_contract_positions,
32
+ legacyHedgerPositions: response.portfolio.legacy_hedger_positions,
33
+ otcPositions: response.portfolio.otc_positions,
34
+ totalValue: response.portfolio.total_value,
35
+ discountedValue: response.portfolio.discounted_value,
36
+ },
37
+ loanbook: {
38
+ loans: response.loanbook.loans.map((loan) => ({
39
+ subaccountAddress: loan.subaccount_address,
40
+ book: {
41
+ address: loan.book.address,
42
+ lender: loan.book.lender,
43
+ borrower: loan.book.borrower,
44
+ state: loan.book.state,
45
+ totalRepaid: loan.book.total_repaid,
46
+ principalToken: {
47
+ type: loan.book.principal_token.type,
48
+ name: loan.book.principal_token.name,
49
+ address: loan.book.principal_token.address,
50
+ chain: loan.book.principal_token.chain,
51
+ symbol: loan.book.principal_token.symbol,
52
+ decimals: loan.book.principal_token.decimals,
53
+ imgUrl: loan.book.principal_token.img_url,
54
+ tokenType: loan.book.principal_token.token_type,
55
+ discountFactor: loan.book.principal_token.discount_factor,
56
+ price: loan.book.principal_token.price,
57
+ },
58
+ principalAmount: loan.book.principal_amount,
59
+ interestAmount: loan.book.interest_amount,
60
+ upcomingPayment: {
61
+ amount: loan.book.upcoming_payment.amount,
62
+ dueDate: loan.book.upcoming_payment.due_date,
63
+ },
64
+ apr: loan.book.apr,
65
+ initialPrincipalAmount: loan.book.initial_principal_amount,
66
+ deployedDate: loan.book.deployed_date,
67
+ paymentInterval: loan.book.payment_interval,
68
+ totalInterestPaymentFees: loan.book.total_interest_payment_fees,
69
+ },
70
+ isBorrow: loan.is_borrow,
71
+ debtInfo: {
72
+ interestOwed: loan.debt_info.interest_owed,
73
+ principalDebtOwed: loan.debt_info.principal_debt_owed,
74
+ interestRepaid: loan.debt_info.interest_repaid,
75
+ },
76
+ creditInfo: {
77
+ netInterestOwed: loan.credit_info.net_interest_owed,
78
+ principalDebtOwed: loan.credit_info.principal_debt_owed,
79
+ netInterestRepaid: loan.credit_info.net_interest_repaid,
80
+ },
81
+ })),
82
+ totalDebt: response.loanbook.total_debt,
83
+ totalCredit: response.loanbook.total_credit,
84
+ aggregatesByToken: response.loanbook.aggregates_by_token,
85
+ },
86
+ chains: response.chains.map((c) => ({
87
+ name: c.name,
88
+ chainId: c.chain_id,
89
+ })),
90
+ tokens: response.tokens.map((t) => ({
91
+ type: t.type,
92
+ name: t.name,
93
+ address: t.address,
94
+ chain: t.chain,
95
+ symbol: t.symbol,
96
+ decimals: t.decimals,
97
+ imgUrl: t.img_url,
98
+ price: t.price,
99
+ rawBalance: t.raw_balance,
100
+ balance: t.balance,
101
+ value: t.value,
102
+ })),
103
+ totalAccountValue: response.total_account_value,
104
+ totalCollateralValue: response.total_collateral_value,
105
+ totalLoanValue: response.total_loan_value,
106
+ healthFactor: response.health_factor,
107
+ netAccountValue: response.net_account_value,
108
+ totalEquityValue: response.total_equity_value,
109
+ };
110
+ };
111
+ exports.transformSubaccountSummary = transformSubaccountSummary;
112
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Adapter Helper Functions
3
+ *
4
+ * Functions to support deposits with alternative tokens through swap adapters,
5
+ * wrapper contracts, and Paraswap integration.
6
+ */
7
+ import type { BaseContract, Signer, Wallet } from 'ethers';
8
+ import type { IAddress } from '../../types';
9
+ import type { IVaultAdapterConfig } from '../../types/vaults';
10
+ /**
11
+ * Get quote from Paraswap for token swap
12
+ */
13
+ export declare function getParaswapQuote({ srcToken, destToken, amount, network, srcDecimals, destDecimals, }: {
14
+ srcToken: string;
15
+ destToken: string;
16
+ amount: string;
17
+ network: string;
18
+ srcDecimals: number;
19
+ destDecimals: number;
20
+ }): Promise<any>;
21
+ /**
22
+ * Fetch a Paraswap price quote and return the pool-adapter contract for a
23
+ * Paraswap-bridge (`bridgeId === 2`) vault.
24
+ *
25
+ * @deprecated No longer used by the SDK. It never built the Paraswap swap
26
+ * calldata (the quote is fetched and discarded, and the returned contract
27
+ * carries no transaction data), so it cannot produce a valid
28
+ * `swapAndDeposit` call. `vaultDeposit` now rejects the Paraswap adapter
29
+ * route up front; use `swapRouterDeposit` for any-token deposits. Kept
30
+ * exported for back-compat only and will be removed in the next major.
31
+ *
32
+ * @param params.signer - Signer used to bind the returned contract.
33
+ * @param params.srcToken - Token being deposited.
34
+ * @param params.srcDecimals - Decimals of `srcToken`.
35
+ * @param params.destToken - Vault underlying asset.
36
+ * @param params.destDecimals - Decimals of `destToken`.
37
+ * @param params.amount - Raw (wei-style) amount of `srcToken`.
38
+ * @param params.network - Chain id as a string, for the Paraswap API.
39
+ * @param params.adapterConfig - Adapter config carrying `wrapperAddress`.
40
+ * @param params.userAddress - Depositor address (unused).
41
+ * @returns The pool-adapter contract bound to `signer`.
42
+ * @throws Error when Paraswap returns no price route.
43
+ */
44
+ export declare function buildSwapAndDepositTransaction({ signer, srcToken, srcDecimals, destToken, destDecimals, amount, network, adapterConfig, userAddress, }: {
45
+ signer: Signer | Wallet;
46
+ srcToken: IAddress;
47
+ srcDecimals: number;
48
+ destToken: IAddress;
49
+ destDecimals: number;
50
+ amount: string;
51
+ network: string;
52
+ adapterConfig: IVaultAdapterConfig;
53
+ userAddress: IAddress;
54
+ }): Promise<BaseContract>;
55
+ /**
56
+ * Build native/wrapped token deposit transaction
57
+ */
58
+ export declare function buildNativeDepositTransaction({ signer, srcToken, amount, poolName, adapterConfig, userAddress, }: {
59
+ signer: Signer | Wallet;
60
+ srcToken: IAddress;
61
+ amount: string;
62
+ poolName?: string;
63
+ adapterConfig: IVaultAdapterConfig;
64
+ userAddress: IAddress;
65
+ }): Promise<{
66
+ contract: BaseContract;
67
+ functionName: string;
68
+ args: any[];
69
+ value?: bigint;
70
+ }>;
71
+ /**
72
+ * Preview adapter deposit output
73
+ */
74
+ export declare function previewAdapterDeposit({ signer, vaultAddress, srcToken, srcAmount, srcDecimals, destToken, destDecimals, adapterConfig, chainId, }: {
75
+ signer: Signer | Wallet;
76
+ vaultAddress: IAddress;
77
+ srcToken: IAddress;
78
+ srcAmount: string;
79
+ srcDecimals: number;
80
+ destToken: IAddress;
81
+ destDecimals: number;
82
+ adapterConfig: IVaultAdapterConfig;
83
+ chainId: number;
84
+ }): Promise<bigint>;
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ /**
3
+ * Adapter Helper Functions
4
+ *
5
+ * Functions to support deposits with alternative tokens through swap adapters,
6
+ * wrapper contracts, and Paraswap integration.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.getParaswapQuote = getParaswapQuote;
10
+ exports.buildSwapAndDepositTransaction = buildSwapAndDepositTransaction;
11
+ exports.buildNativeDepositTransaction = buildNativeDepositTransaction;
12
+ exports.previewAdapterDeposit = previewAdapterDeposit;
13
+ const adapters_1 = require("../../core/constants/adapters");
14
+ const abis_1 = require("../../abis");
15
+ const core_1 = require("../../core");
16
+ /**
17
+ * Paraswap API endpoints
18
+ */
19
+ const PARASWAP_PRICES_API = 'https://api.paraswap.io/prices';
20
+ /**
21
+ * Paraswap partner configuration
22
+ */
23
+ const PARASWAP_PARTNER = 'upshift';
24
+ const PARASWAP_PARTNER_ADDRESS = '0xb60ee0FA5B6bA917255A03e744967E0Bda531dD0';
25
+ const PARASWAP_VERSION = '6.2';
26
+ /**
27
+ * Get quote from Paraswap for token swap
28
+ */
29
+ async function getParaswapQuote({ srcToken, destToken, amount, network, srcDecimals, destDecimals, }) {
30
+ const params = new URLSearchParams();
31
+ params.append('network', network);
32
+ params.append('srcToken', srcToken);
33
+ params.append('srcDecimals', srcDecimals.toString());
34
+ params.append('destToken', destToken);
35
+ params.append('destDecimals', destDecimals.toString());
36
+ params.append('amount', amount);
37
+ params.append('partner', PARASWAP_PARTNER);
38
+ params.append('partnerAddress', PARASWAP_PARTNER_ADDRESS);
39
+ params.append('version', PARASWAP_VERSION);
40
+ const priceUrl = `${PARASWAP_PRICES_API}?${params.toString()}`;
41
+ const response = await fetch(priceUrl, {
42
+ method: 'GET',
43
+ headers: {
44
+ 'Content-Type': 'application/json',
45
+ },
46
+ });
47
+ const data = await response.json();
48
+ return data?.priceRoute || {};
49
+ }
50
+ /**
51
+ * Fetch a Paraswap price quote and return the pool-adapter contract for a
52
+ * Paraswap-bridge (`bridgeId === 2`) vault.
53
+ *
54
+ * @deprecated No longer used by the SDK. It never built the Paraswap swap
55
+ * calldata (the quote is fetched and discarded, and the returned contract
56
+ * carries no transaction data), so it cannot produce a valid
57
+ * `swapAndDeposit` call. `vaultDeposit` now rejects the Paraswap adapter
58
+ * route up front; use `swapRouterDeposit` for any-token deposits. Kept
59
+ * exported for back-compat only and will be removed in the next major.
60
+ *
61
+ * @param params.signer - Signer used to bind the returned contract.
62
+ * @param params.srcToken - Token being deposited.
63
+ * @param params.srcDecimals - Decimals of `srcToken`.
64
+ * @param params.destToken - Vault underlying asset.
65
+ * @param params.destDecimals - Decimals of `destToken`.
66
+ * @param params.amount - Raw (wei-style) amount of `srcToken`.
67
+ * @param params.network - Chain id as a string, for the Paraswap API.
68
+ * @param params.adapterConfig - Adapter config carrying `wrapperAddress`.
69
+ * @param params.userAddress - Depositor address (unused).
70
+ * @returns The pool-adapter contract bound to `signer`.
71
+ * @throws Error when Paraswap returns no price route.
72
+ */
73
+ async function buildSwapAndDepositTransaction({ signer, srcToken, srcDecimals, destToken, destDecimals, amount, network, adapterConfig, userAddress, }) {
74
+ // Get price quote from Paraswap
75
+ const priceRoute = await getParaswapQuote({
76
+ srcToken,
77
+ destToken,
78
+ amount,
79
+ network,
80
+ srcDecimals,
81
+ destDecimals,
82
+ });
83
+ if (!priceRoute || !priceRoute.destAmount) {
84
+ throw new Error('No price route found from Paraswap');
85
+ }
86
+ // Create adapter contract
87
+ // Note: Transaction data will be built in the calling code
88
+ const adapterContract = (0, core_1.createContract)({
89
+ address: adapterConfig.wrapperAddress,
90
+ provider: signer,
91
+ abi: abis_1.ABI_POOL_ADAPTER,
92
+ });
93
+ return adapterContract;
94
+ }
95
+ /**
96
+ * Build native/wrapped token deposit transaction
97
+ */
98
+ async function buildNativeDepositTransaction({ signer, srcToken, amount, poolName, adapterConfig, userAddress, }) {
99
+ const isNative = srcToken === '0x0000000000000000000000000000000000000000';
100
+ const wrapperContract = (0, core_1.createContract)({
101
+ address: adapterConfig.wrapperAddress,
102
+ provider: signer,
103
+ abi: (adapterConfig.abi ||
104
+ abis_1.ABI_WRAPPER_ADAPTER),
105
+ });
106
+ // Handle different pool types
107
+ if (poolName === adapters_1.POOL_NAMES.ETH_TREEHOUSE_GROWTH) {
108
+ if (isNative) {
109
+ return {
110
+ contract: wrapperContract,
111
+ functionName: 'depositETH',
112
+ args: [adapterConfig.referralId],
113
+ value: BigInt(amount),
114
+ };
115
+ }
116
+ return {
117
+ contract: wrapperContract,
118
+ functionName: 'depositWETH',
119
+ args: [BigInt(amount), adapterConfig.referralId],
120
+ };
121
+ }
122
+ if (poolName === adapters_1.POOL_NAMES.AVAX_AVAX) {
123
+ return {
124
+ contract: wrapperContract,
125
+ functionName: 'depositETH',
126
+ args: [],
127
+ value: BigInt(amount),
128
+ };
129
+ }
130
+ if (poolName === adapters_1.POOL_NAMES.ETH_KELP_TAC_RSETH) {
131
+ if (isNative) {
132
+ return {
133
+ contract: wrapperContract,
134
+ functionName: 'getRSETHWithETH',
135
+ args: [adapterConfig.referralId],
136
+ value: BigInt(amount),
137
+ };
138
+ }
139
+ return {
140
+ contract: wrapperContract,
141
+ functionName: 'getRSETHWithERC20',
142
+ args: [
143
+ adapterConfig.wrappedTokenAddress,
144
+ BigInt(amount),
145
+ adapterConfig.referralId,
146
+ ],
147
+ };
148
+ }
149
+ // Default native deposit
150
+ if (isNative && adapterConfig.isNativeTokenDeposit) {
151
+ return {
152
+ contract: wrapperContract,
153
+ functionName: 'depositETH',
154
+ args: adapterConfig.referralId ? [adapterConfig.referralId] : [],
155
+ value: BigInt(amount),
156
+ };
157
+ }
158
+ throw new Error('Unsupported deposit configuration');
159
+ }
160
+ /**
161
+ * Preview adapter deposit output
162
+ */
163
+ async function previewAdapterDeposit({ signer, vaultAddress, srcToken, srcAmount, srcDecimals, destToken, destDecimals, adapterConfig, chainId, }) {
164
+ // If using Paraswap bridge, get quote
165
+ if (adapterConfig.bridgeId === 2) {
166
+ const quote = await getParaswapQuote({
167
+ srcToken,
168
+ destToken,
169
+ amount: srcAmount,
170
+ network: chainId.toString(),
171
+ srcDecimals,
172
+ destDecimals,
173
+ });
174
+ return BigInt(quote.destAmount || 0);
175
+ }
176
+ // If view adapter is available, use it
177
+ if (adapterConfig.viewAdapter) {
178
+ const viewContract = (0, core_1.createContract)({
179
+ address: adapterConfig.viewAdapter,
180
+ provider: signer,
181
+ abi: [
182
+ {
183
+ inputs: [
184
+ { internalType: 'address', name: 'asset', type: 'address' },
185
+ { internalType: 'uint256', name: 'depositAmount', type: 'uint256' },
186
+ ],
187
+ name: 'getRsETHAmountToMint',
188
+ outputs: [
189
+ { internalType: 'uint256', name: 'rsETHAmount', type: 'uint256' },
190
+ ],
191
+ stateMutability: 'view',
192
+ type: 'function',
193
+ },
194
+ ],
195
+ });
196
+ const output = await viewContract.getRsETHAmountToMint(srcToken, BigInt(srcAmount));
197
+ return BigInt(output);
198
+ }
199
+ // Default: assume 1:1 ratio
200
+ return BigInt(srcAmount);
201
+ }
202
+ //# sourceMappingURL=adapter.helpers.js.map
@@ -0,0 +1,147 @@
1
+ import type { IAddress } from '../../types';
2
+ /**
3
+ * Fetch the set of vaults whose deposit/withdraw history is served from the
4
+ * backend Mongo snapshot (`/upshift/vault_history`) rather than their (retired)
5
+ * Goldsky subgraph.
6
+ *
7
+ * This is the routing source of truth: a vault appears here only once its
8
+ * history has been backfilled, so the SDK can never reroute a vault to empty
9
+ * snapshot data ahead of its backfill. Result is cached for 10 minutes.
10
+ *
11
+ * Side effects: one HTTP GET to the public API (cached).
12
+ *
13
+ * @returns A set of lowercased vault addresses. Empty on any error — callers
14
+ * then fall back to the subgraph path, which is the safe default while
15
+ * subgraphs still exist.
16
+ */
17
+ export declare function fetchArchivedVaults(): Promise<Set<string>>;
18
+ /**
19
+ * Whether a vault's history should be served from the backend snapshot rather
20
+ * than its subgraph. Backed by {@link fetchArchivedVaults} (cached).
21
+ *
22
+ * @param vaultAddress - The vault contract address (any casing).
23
+ * @returns `true` if the vault has a backfilled history snapshot.
24
+ */
25
+ export declare function isArchivedVault(vaultAddress: IAddress): Promise<boolean>;
26
+ /**
27
+ * Specialized vault fetching with enhanced retry logic and fallback strategies
28
+ * This function attempts to fetch vault data with multiple fallback approaches
29
+ *
30
+ * The return shape is "success flag wins": when `success === true`, `data` is
31
+ * the resolved value (which may legitimately be falsy — `0`, `''`, `0n`,
32
+ * `null`); when `success === false`, `error` is populated. Callers must branch
33
+ * on `success`, not on the truthiness of `data`.
34
+ */
35
+ export declare function fetchVaultWithFallback<T>(vaultAddress: string, fetchFn: () => Promise<T>, options?: {
36
+ maxRetries?: number;
37
+ baseDelay?: number;
38
+ fallbackStrategies?: Array<() => Promise<T>>;
39
+ timeout?: number;
40
+ }): Promise<{
41
+ success: boolean;
42
+ data?: T;
43
+ error?: Error;
44
+ strategy: string;
45
+ }>;
46
+ /**
47
+ * Batch vault fetching with intelligent retry and fallback
48
+ * Ensures maximum vault coverage by trying multiple strategies
49
+ */
50
+ export declare function fetchVaultsBatch<T>(vaults: Array<{
51
+ address: string;
52
+ fetchFn: () => Promise<T>;
53
+ }>, options?: {
54
+ maxRetries?: number;
55
+ baseDelay?: number;
56
+ batchSize?: number;
57
+ parallelLimit?: number;
58
+ }): Promise<{
59
+ successful: Array<{
60
+ index: number;
61
+ data: T;
62
+ strategy: string;
63
+ }>;
64
+ failed: Array<{
65
+ index: number;
66
+ error: Error;
67
+ address: string;
68
+ }>;
69
+ totalAttempted: number;
70
+ successRate: number;
71
+ }>;
72
+ /**
73
+ * Comprehensive vault fetching that handles all failure points
74
+ * This function ensures maximum vault coverage by implementing multiple strategies
75
+ */
76
+ export declare function fetchVaultsComprehensive<T>(vaults: Array<{
77
+ address: string;
78
+ chain: number;
79
+ }>, fetchFn: (vault: {
80
+ address: string;
81
+ chain: number;
82
+ fallbackRpc?: string;
83
+ minimal?: boolean;
84
+ }) => Promise<T>, options?: {
85
+ maxRetries?: number;
86
+ baseDelay?: number;
87
+ batchSize?: number;
88
+ parallelLimit?: number;
89
+ includeClosed?: boolean;
90
+ includeInvisible?: boolean;
91
+ fallbackRpcUrls?: Record<number, string[]>;
92
+ timeout?: number;
93
+ }): Promise<{
94
+ successful: Array<{
95
+ index: number;
96
+ data: T;
97
+ strategy: string;
98
+ attempts: number;
99
+ }>;
100
+ failed: Array<{
101
+ index: number;
102
+ error: Error;
103
+ address: string;
104
+ chain: number;
105
+ attempts: number;
106
+ }>;
107
+ totalAttempted: number;
108
+ successRate: number;
109
+ coverageReport: {
110
+ totalVaults: number;
111
+ successfulVaults: number;
112
+ failedVaults: number;
113
+ closedVaults: number;
114
+ invisibleVaults: number;
115
+ rpcFailures: Record<number, number>;
116
+ };
117
+ }>;
118
+ /**
119
+ * Enhanced vault filtering that preserves more vaults while maintaining quality
120
+ */
121
+ export declare function filterVaultsIntelligently<T extends {
122
+ status?: string;
123
+ isVisible?: boolean;
124
+ is_visible?: boolean;
125
+ }>(vaults: (T | null)[], options?: {
126
+ includeClosed?: boolean;
127
+ includeInvisible?: boolean;
128
+ includeNull?: boolean;
129
+ minStatus?: string[];
130
+ }): {
131
+ active: T[];
132
+ closed: T[];
133
+ invisible: T[];
134
+ failed: Array<{
135
+ index: number;
136
+ reason: string;
137
+ }>;
138
+ summary: {
139
+ total: number;
140
+ active: number;
141
+ closed: number;
142
+ invisible: number;
143
+ failed: number;
144
+ successRate: number;
145
+ };
146
+ };
147
+ export { fetchVaultMetadata } from '../../core/vault-metadata';