@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,187 @@
1
+ "use strict";
2
+ /**
3
+ * Stellar Adapter for Upshift SDK
4
+ *
5
+ * Provides Stellar vault operations: deposit, redeem, position queries,
6
+ * and on-chain data fetching via Soroban RPC.
7
+ *
8
+ * @module StellarAdapter
9
+ */
10
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ var desc = Object.getOwnPropertyDescriptor(m, k);
13
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }) : (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ o[k2] = m[k];
20
+ }));
21
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
22
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
23
+ }) : function(o, v) {
24
+ o["default"] = v;
25
+ });
26
+ var __importStar = (this && this.__importStar) || (function () {
27
+ var ownKeys = function(o) {
28
+ ownKeys = Object.getOwnPropertyNames || function (o) {
29
+ var ar = [];
30
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
31
+ return ar;
32
+ };
33
+ return ownKeys(o);
34
+ };
35
+ return function (mod) {
36
+ if (mod && mod.__esModule) return mod;
37
+ var result = {};
38
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
39
+ __setModuleDefault(result, mod);
40
+ return result;
41
+ };
42
+ })();
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.StellarAdapter = exports.Stellar = void 0;
45
+ const StellarConstants = __importStar(require("./constants"));
46
+ const StellarGetters = __importStar(require("./getters"));
47
+ const StellarActions = __importStar(require("./actions"));
48
+ const StellarSubmit = __importStar(require("./submit"));
49
+ const utils_1 = require("./utils");
50
+ exports.Stellar = {
51
+ utils: utils_1.StellarUtils,
52
+ constants: StellarConstants,
53
+ actions: StellarActions,
54
+ submit: StellarSubmit,
55
+ getters: StellarGetters,
56
+ };
57
+ /**
58
+ * Stellar Adapter for Upshift SDK
59
+ *
60
+ * @example
61
+ * ```
62
+ * const adapter = new StellarAdapter('testnet');
63
+ * const xdr = await adapter.vaultDeposit({
64
+ * contractId: 'CBGWW5...',
65
+ * amount: '1000000',
66
+ * senderAddress: 'GDLZ...',
67
+ * });
68
+ * // Sign xdr with wallet (e.g. Freighter), then submit via adapter.submitTransaction()
69
+ * ```
70
+ */
71
+ class StellarAdapter {
72
+ _network;
73
+ /**
74
+ * Optional consumer-supplied Soroban RPC endpoint (e.g. a keyed Alchemy URL).
75
+ * When set it is the primary, with the SDK's public endpoints as failover.
76
+ */
77
+ _sorobanRpcUrl;
78
+ /**
79
+ * @param network - Stellar network to operate on; defaults to `'mainnet'`.
80
+ * @param options - Optional adapter configuration. Its `sorobanRpcUrl` field
81
+ * overrides the Soroban RPC endpoint (e.g. a keyed Alchemy URL): it becomes
82
+ * the primary with the SDK's built-in public endpoints kept behind it as
83
+ * failover, and a per-call `sorobanRpcUrl` (on the deposit/redeem params)
84
+ * takes precedence over this adapter-level one.
85
+ */
86
+ constructor(network = 'mainnet', options) {
87
+ this._network = network;
88
+ this._sorobanRpcUrl = options?.sorobanRpcUrl;
89
+ }
90
+ get network() {
91
+ return this._network;
92
+ }
93
+ isStellarAddress(address) {
94
+ return utils_1.StellarUtils.isStellarAddress(address);
95
+ }
96
+ getExplorerLink(id, type) {
97
+ return utils_1.StellarUtils.getExplorerLink({ id, type, network: this._network });
98
+ }
99
+ /**
100
+ * Build an unsigned deposit transaction for a Stellar vault.
101
+ * @returns Base64-encoded XDR of the unsigned transaction.
102
+ */
103
+ async vaultDeposit(params) {
104
+ return StellarActions.handleStellarDeposit({
105
+ ...params,
106
+ network: this._network,
107
+ // A per-call override (params.sorobanRpcUrl) wins over the adapter-level one.
108
+ sorobanRpcUrl: params.sorobanRpcUrl ?? this._sorobanRpcUrl,
109
+ });
110
+ }
111
+ /**
112
+ * Build an unsigned redeem transaction for a Stellar vault.
113
+ *
114
+ * Side effect on failure: a redemption the vault cannot serve is reported to
115
+ * that vault's curator, since Stellar vaults are instant-redeem only and this
116
+ * is the curator's only signal. Fire-and-forget — it never delays or alters
117
+ * the error you receive. On by default in production; see
118
+ * `monitoring.curatorAlerts` and the Curator Notifications section of the
119
+ * Stellar Actions guide for exactly what is sent and how to opt out.
120
+ *
121
+ * @returns Base64-encoded XDR of the unsigned transaction.
122
+ */
123
+ async vaultRedeem(params) {
124
+ return StellarActions.handleStellarRedeem({
125
+ ...params,
126
+ network: this._network,
127
+ // A per-call override (params.sorobanRpcUrl) wins over the adapter-level one.
128
+ sorobanRpcUrl: params.sorobanRpcUrl ?? this._sorobanRpcUrl,
129
+ });
130
+ }
131
+ /**
132
+ * Side effect: a submitted transaction that the network reports as a failed
133
+ * `redeem` operation is reported to that vault's curator, on the same
134
+ * fire-and-forget terms as {@link StellarAdapter.vaultRedeem}.
135
+ *
136
+ * Submit a signed Soroban transaction and poll until the network confirms it.
137
+ *
138
+ * Submits on the network this adapter was constructed with, so `signedXdr`
139
+ * must be signed for that same network.
140
+ *
141
+ * @param signedXdr - Base64-encoded XDR of the signed transaction.
142
+ * @returns The transaction hash once the network confirms it as successful.
143
+ * @throws {@link UpshiftTimeoutError} when the transaction is not confirmed
144
+ * within the poll budget (`MAX_POLL_ATTEMPTS`).
145
+ * @throws {@link UpshiftSDKError} when the RPC rejects the submission or the
146
+ * transaction confirms as failed. Its `context` carries `{ network, status }`
147
+ * plus, when the result XDR decodes, a `resultCode` string holding the
148
+ * transaction-level reason (e.g. `"txBadSeq"`, `"txTooLate"`); `resultCode`
149
+ * is `undefined` when the code cannot be decoded.
150
+ * @example
151
+ * ```ts
152
+ * try {
153
+ * const hash = await adapter.submitTransaction(signedXdr);
154
+ * } catch (err) {
155
+ * if (err instanceof UpshiftSDKError && err.context?.resultCode === 'txBadSeq') {
156
+ * // stale sequence number — rebuild the transaction and resubmit
157
+ * }
158
+ * }
159
+ * ```
160
+ */
161
+ async submitTransaction(signedXdr) {
162
+ return StellarSubmit.submitStellarTransaction(signedXdr, this._network, this._sorobanRpcUrl);
163
+ }
164
+ /**
165
+ * Get user's vault share balance.
166
+ *
167
+ * @returns The position `{ shares, decimals, decimalsFromFallback }`, or null
168
+ * if the balance read fails. When `decimalsFromFallback` is `true` the
169
+ * `decimals()` read failed and `decimals` is the fallback (7) — callers sizing
170
+ * a redeem MUST refuse rather than trust it.
171
+ */
172
+ async getUserPosition(vaultAddress, walletAddress) {
173
+ return StellarGetters.getStellarUserPosition(vaultAddress, walletAddress, this._network, this._sorobanRpcUrl);
174
+ }
175
+ /**
176
+ * Preview how many vault shares a deposit amount would yield.
177
+ * @param vaultAddress Stellar contract ID (C… address)
178
+ * @param rawAmount Deposit amount in the deposit token's smallest unit
179
+ * @returns Raw share amount as a string, or null if query fails.
180
+ */
181
+ async convertToShares(vaultAddress, rawAmount) {
182
+ return StellarGetters.convertToShares(vaultAddress, rawAmount, this._network, this._sorobanRpcUrl);
183
+ }
184
+ }
185
+ exports.StellarAdapter = StellarAdapter;
186
+ exports.default = StellarAdapter;
187
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Stellar Invocation Decoding
3
+ *
4
+ * Reads back what a built transaction actually invokes. `submitStellarTransaction`
5
+ * takes an opaque signed XDR — it has no idea whether it is broadcasting a
6
+ * deposit, a redeem, or something else — so a failure there cannot be attributed
7
+ * to a vault operation without looking inside the envelope.
8
+ */
9
+ import type { FeeBumpTransaction, Transaction } from '@stellar/stellar-sdk';
10
+ /** A vault contract invocation recovered from a transaction envelope. */
11
+ export interface IVaultInvocation {
12
+ /** Invoked contract (C-address). */
13
+ contractId: string;
14
+ /** Contract function name, e.g. `'redeem'` or `'deposit'`. */
15
+ functionName: string;
16
+ /**
17
+ * First argument as a decimal string, when it decodes to an integer. Both
18
+ * `deposit(assets, …)` and `redeem(shares, …)` lead with the `i128` amount.
19
+ * `undefined` when the argument is absent or not an integer.
20
+ */
21
+ amountRaw?: string;
22
+ /**
23
+ * Second argument as a Stellar address, when it decodes to one — the
24
+ * `receiver` in both vault signatures. `undefined` otherwise.
25
+ */
26
+ receiver?: string;
27
+ /**
28
+ * Third argument as a Stellar address, when it decodes to one — `owner` in
29
+ * `redeem(shares, receiver, owner, operator)`, i.e. the account whose shares
30
+ * are burned. Identical to `receiver` for the self-redeem the SDK builds, but
31
+ * they differ for a delegated redemption. `undefined` otherwise.
32
+ */
33
+ owner?: string;
34
+ }
35
+ /**
36
+ * Decode the single Soroban contract invocation in a transaction.
37
+ *
38
+ * Every transaction the SDK builds carries exactly one `invokeHostFunction`
39
+ * operation (see `buildSorobanTx`), so the first one found is authoritative.
40
+ * Purely local — no RPC, no network.
41
+ *
42
+ * Written defensively rather than optimistically: this is called from an error
43
+ * path where the envelope may be anything a caller handed us, and a throw here
44
+ * would replace the real transaction failure with a decoding error. Anything
45
+ * unexpected — a fee-bump wrapper, a classic payment, a shape-drifted SDK
46
+ * union, a non-address argument — yields `undefined`.
47
+ *
48
+ * @param tx - Parsed transaction (e.g. `TransactionBuilder.fromXDR(...)`, whose
49
+ * return type includes the fee-bump wrapper — that case yields `undefined`,
50
+ * since the invocation lives in the inner transaction and the SDK never
51
+ * builds one).
52
+ * @returns The invocation, or `undefined` when the transaction does not carry a
53
+ * decodable contract call.
54
+ */
55
+ export declare function describeVaultInvocation(tx: Transaction | FeeBumpTransaction): IVaultInvocation | undefined;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /**
3
+ * Stellar Invocation Decoding
4
+ *
5
+ * Reads back what a built transaction actually invokes. `submitStellarTransaction`
6
+ * takes an opaque signed XDR — it has no idea whether it is broadcasting a
7
+ * deposit, a redeem, or something else — so a failure there cannot be attributed
8
+ * to a vault operation without looking inside the envelope.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.describeVaultInvocation = describeVaultInvocation;
12
+ const stellar_sdk_1 = require("@stellar/stellar-sdk");
13
+ /**
14
+ * Decode the single Soroban contract invocation in a transaction.
15
+ *
16
+ * Every transaction the SDK builds carries exactly one `invokeHostFunction`
17
+ * operation (see `buildSorobanTx`), so the first one found is authoritative.
18
+ * Purely local — no RPC, no network.
19
+ *
20
+ * Written defensively rather than optimistically: this is called from an error
21
+ * path where the envelope may be anything a caller handed us, and a throw here
22
+ * would replace the real transaction failure with a decoding error. Anything
23
+ * unexpected — a fee-bump wrapper, a classic payment, a shape-drifted SDK
24
+ * union, a non-address argument — yields `undefined`.
25
+ *
26
+ * @param tx - Parsed transaction (e.g. `TransactionBuilder.fromXDR(...)`, whose
27
+ * return type includes the fee-bump wrapper — that case yields `undefined`,
28
+ * since the invocation lives in the inner transaction and the SDK never
29
+ * builds one).
30
+ * @returns The invocation, or `undefined` when the transaction does not carry a
31
+ * decodable contract call.
32
+ */
33
+ function describeVaultInvocation(tx) {
34
+ try {
35
+ if (!('operations' in tx))
36
+ return undefined;
37
+ for (const op of tx.operations ?? []) {
38
+ if (op.type !== 'invokeHostFunction')
39
+ continue;
40
+ const hostFn = op.func;
41
+ if (hostFn.switch() !==
42
+ stellar_sdk_1.xdr.HostFunctionType.hostFunctionTypeInvokeContract()) {
43
+ continue;
44
+ }
45
+ const invocation = hostFn.invokeContract();
46
+ const contractId = stellar_sdk_1.Address.fromScAddress(invocation.contractAddress()).toString();
47
+ const functionName = invocation.functionName().toString();
48
+ const args = invocation.args();
49
+ return {
50
+ contractId,
51
+ functionName,
52
+ amountRaw: decodeInteger(args[0]),
53
+ receiver: decodeAddress(args[1]),
54
+ owner: decodeAddress(args[2]),
55
+ };
56
+ }
57
+ }
58
+ catch {
59
+ // Shape drift or an envelope we don't recognise. The caller falls back to
60
+ // reporting nothing rather than misattributing the failure.
61
+ }
62
+ return undefined;
63
+ }
64
+ /** `bigint` / `number` ScVal → decimal string; `undefined` for anything else. */
65
+ function decodeInteger(value) {
66
+ if (!value)
67
+ return undefined;
68
+ try {
69
+ const native = (0, stellar_sdk_1.scValToNative)(value);
70
+ if (typeof native === 'bigint')
71
+ return native.toString();
72
+ if (typeof native === 'number' && Number.isInteger(native)) {
73
+ return String(native);
74
+ }
75
+ }
76
+ catch {
77
+ // Not an integer ScVal.
78
+ }
79
+ return undefined;
80
+ }
81
+ /** Address ScVal → strkey; `undefined` for anything else. */
82
+ function decodeAddress(value) {
83
+ if (!value)
84
+ return undefined;
85
+ try {
86
+ return stellar_sdk_1.Address.fromScVal(value).toString();
87
+ }
88
+ catch {
89
+ return undefined;
90
+ }
91
+ }
92
+ //# sourceMappingURL=invocation.js.map
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Shared Soroban RPC utilities
3
+ *
4
+ * Common transaction building and read-only query helpers used by
5
+ * actions, submit, and getters modules.
6
+ */
7
+ import { type xdr, rpc } from '@stellar/stellar-sdk';
8
+ import type { IStellarNetwork } from './types';
9
+ /** Resolved network configuration for Soroban RPC calls. */
10
+ export interface ISorobanNetworkConfig {
11
+ /** Primary endpoint — the first of {@link rpcUrls}; kept for convenience. */
12
+ rpcUrl: string;
13
+ /** Ordered endpoints for health-gated failover: primary first, fallbacks after. */
14
+ rpcUrls: readonly string[];
15
+ passphrase: string;
16
+ }
17
+ export declare function createServer(rpcUrl: string): rpc.Server;
18
+ /**
19
+ * Resolve the ordered RPC endpoints and network passphrase for a Stellar network.
20
+ *
21
+ * When `overrideRpcUrl` is supplied (e.g. a consumer's keyed Alchemy endpoint),
22
+ * it becomes the primary with the built-in public endpoints kept behind it as
23
+ * failover — so opting into a premium provider still degrades to the public
24
+ * network rather than becoming a new single point of failure. The endpoint is
25
+ * injected rather than hardcoded, so the adapter depends on configuration, not a
26
+ * constant.
27
+ */
28
+ export declare function resolveNetworkConfig(network: IStellarNetwork, overrideRpcUrl?: string): ISorobanNetworkConfig;
29
+ /**
30
+ * Clear the health-check cache and any in-flight probes. Test-only seam.
31
+ * @internal
32
+ */
33
+ export declare function resetHealthyServerCache(): void;
34
+ /**
35
+ * Host-only view of an RPC URL, safe for logs. Keyed provider endpoints put the
36
+ * API key in the path (e.g. Alchemy `/v2/<key>`), so logging the raw URL would
37
+ * leak the secret into SDK logs / crash reporters. Returns just protocol+host.
38
+ * @internal
39
+ */
40
+ export declare function redactRpcUrl(url: string): string;
41
+ /**
42
+ * Return a Soroban RPC server backed by a healthy endpoint for `config`. Thin
43
+ * wrapper over {@link resolveHealthyServer} for callers (e.g. submission) that
44
+ * only need the server, not the URL it resolved to.
45
+ *
46
+ * @internal
47
+ */
48
+ export declare function getHealthyServer(config: ISorobanNetworkConfig): Promise<rpc.Server>;
49
+ /**
50
+ * A thrown RPC error is retryable on another endpoint UNLESS it is one of our
51
+ * typed domain errors. Those mark a *deterministic* outcome — a contract revert,
52
+ * an unfunded account, archived state needing restore, a bad input, or a local
53
+ * assembly failure — which reproduces identically on every node, so retrying
54
+ * elsewhere only wastes calls. Any other throw (a transport hang/reset, or a
55
+ * method-specific node error from an endpoint that still answered `getHealth()`)
56
+ * is worth the next endpoint.
57
+ *
58
+ * Exported so an operation with different semantics (e.g. an idempotency-aware
59
+ * submission path) can compose or replace this policy via
60
+ * {@link FailoverOptions.isRetryable} — extension without editing the core.
61
+ *
62
+ * Named distinctly from `core/helpers/chain-error`'s `isRetryableRpcError`
63
+ * (the EVM transport classifier, deliberately public) — the internal-dts
64
+ * leak check matches `@internal` tags by name across the whole `src.ts` tree,
65
+ * so a same-named pair would make it flag the public EVM one as a leak.
66
+ * @internal
67
+ */
68
+ export declare function isRetryableSorobanRpcError(err: unknown): boolean;
69
+ /**
70
+ * Whether a simulation *error* string is a node/infrastructure failure (which
71
+ * clears on another endpoint) rather than a genuine contract revert (which
72
+ * reproduces on every node). `isSimulationError` alone can't tell these apart —
73
+ * both arrive as a populated `error` field — so callers use this to decide
74
+ * whether to fail over or treat the error as terminal.
75
+ * @internal
76
+ */
77
+ export declare function isRetryableSimulationError(errorText: string): boolean;
78
+ /**
79
+ * Tunables for {@link withEndpointFailover}, injected with sensible defaults so
80
+ * a new operation can vary retry policy or latency budget without editing the
81
+ * failover core (Open/Closed at the call site).
82
+ */
83
+ export interface FailoverOptions {
84
+ /** Which thrown errors get the next endpoint. Defaults to {@link isRetryableSorobanRpcError}. */
85
+ isRetryable?: (err: unknown) => boolean;
86
+ /** Per-attempt timeout in ms. Defaults to {@link RPC_OPERATION_TIMEOUT_MS}. */
87
+ timeoutMs?: number;
88
+ }
89
+ /**
90
+ * Run an idempotent, side-effect-free `operation` (a read or a tx build) against
91
+ * a Soroban endpoint, failing over to the remaining endpoints on a retryable
92
+ * failure.
93
+ *
94
+ * {@link getHealthyServer} only proves an endpoint answered `getHealth()`, and
95
+ * caches that choice for {@link HEALTHY_SERVER_TTL_MS} — but the node can still
96
+ * hang or return a method-specific error on the *real* call. So we run the op on
97
+ * the health-gated server first (the fast, cached path) and, on a retryable
98
+ * failure, drop that cached choice and retry the op against every endpoint in
99
+ * priority order. Deterministic contract/domain errors short-circuit (see
100
+ * {@link isRetryableSorobanRpcError}); each attempt is time-boxed so a hung node can't
101
+ * stall the loop.
102
+ *
103
+ * The `operation` is a strategy (dependency-injected), so new read/build calls
104
+ * reuse this failover without changing it; `options` keeps retry policy and
105
+ * timeout open for extension. Submission is deliberately NOT routed through here
106
+ * — re-sending a signed transaction across endpoints risks a double-submit, so
107
+ * it needs sequence/DUPLICATE-based idempotency rather than blind retry.
108
+ * @internal
109
+ */
110
+ export declare function withEndpointFailover<T>(config: ISorobanNetworkConfig, method: string, operation: (server: rpc.Server) => Promise<T>, options?: FailoverOptions): Promise<T>;
111
+ /**
112
+ * Validate and convert a string amount to a non-negative BigInt.
113
+ * Throws a descriptive error if the value is not a valid non-negative integer string.
114
+ */
115
+ export declare function toBigIntAmount(value: string, label: string): bigint;
116
+ export declare function queryContract(config: ISorobanNetworkConfig, contractId: string, method: string, args?: xdr.ScVal[]): Promise<xdr.ScVal | null>;
117
+ /**
118
+ * Build an unsigned Soroban contract invocation transaction.
119
+ * Fetches the real source account from the network (the account must exist and be funded).
120
+ * Simulates via Soroban RPC to attach resource footprint and auth entries,
121
+ * using MAX_FEE_STROOPS as the fee ceiling and incorporating the simulated resource fee.
122
+ *
123
+ * Thrown errors carry `context.stage` naming where the build broke:
124
+ * `'simulation'` (the contract itself rejected the call), `'restore-required'`,
125
+ * `'assembly'`, or `'rpc-failover'` (no endpoint answered). Callers use it to
126
+ * separate a vault-level rejection from a transport problem — see the curator
127
+ * alerting in `handleStellarRedeem`. Validation errors (e.g.
128
+ * `ACCOUNT_NOT_FUNDED`) carry no stage, so treat a missing one as "not a
129
+ * vault-level failure" rather than assuming the field is always present.
130
+ */
131
+ export declare function buildSorobanTx(config: ISorobanNetworkConfig, sourceAddress: string, contractId: string, method: string, args: xdr.ScVal[]): Promise<string>;