upshift-finance 1.0.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 (316) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -0
  3. package/lib/abis/AddressResolver.d.ts +28 -0
  4. package/lib/abis/AddressResolver.js +23 -0
  5. package/lib/abis/ChainlinkV3.d.ts +87 -0
  6. package/lib/abis/ChainlinkV3.js +117 -0
  7. package/lib/abis/ERC20.d.ts +168 -0
  8. package/lib/abis/ERC20.js +226 -0
  9. package/lib/abis/ERC20_Bytes32.d.ts +139 -0
  10. package/lib/abis/ERC20_Bytes32.js +196 -0
  11. package/lib/abis/ERC4626.d.ts +364 -0
  12. package/lib/abis/ERC4626.js +507 -0
  13. package/lib/abis/ERC721.d.ts +231 -0
  14. package/lib/abis/ERC721.js +321 -0
  15. package/lib/abis/FeeOracle.d.ts +120 -0
  16. package/lib/abis/FeeOracle.js +162 -0
  17. package/lib/abis/LendingPool.d.ts +1393 -0
  18. package/lib/abis/LendingPool.js +1807 -0
  19. package/lib/abis/LendingPoolV2.d.ts +1413 -0
  20. package/lib/abis/LendingPoolV2.js +1833 -0
  21. package/lib/abis/LendingPoolV3.d.ts +1677 -0
  22. package/lib/abis/LendingPoolV3.js +1160 -0
  23. package/lib/abis/Loan.d.ts +837 -0
  24. package/lib/abis/Loan.js +1080 -0
  25. package/lib/abis/MultiAssetNativeDepositWrapper.d.ts +137 -0
  26. package/lib/abis/MultiAssetNativeDepositWrapper.js +125 -0
  27. package/lib/abis/Multicall3.d.ts +30 -0
  28. package/lib/abis/Multicall3.js +97 -0
  29. package/lib/abis/OFT.d.ts +116 -0
  30. package/lib/abis/OFT.js +85 -0
  31. package/lib/abis/PoolAdapter.d.ts +36 -0
  32. package/lib/abis/PoolAdapter.js +51 -0
  33. package/lib/abis/RewardDistributor.d.ts +267 -0
  34. package/lib/abis/RewardDistributor.js +352 -0
  35. package/lib/abis/RwaRedeemSubaccount.d.ts +747 -0
  36. package/lib/abis/RwaRedeemSubaccount.js +548 -0
  37. package/lib/abis/SmartAccount.d.ts +17 -0
  38. package/lib/abis/SmartAccount.js +19 -0
  39. package/lib/abis/SwapRouter.d.ts +1043 -0
  40. package/lib/abis/SwapRouter.js +740 -0
  41. package/lib/abis/TextResolver.d.ts +16 -0
  42. package/lib/abis/TextResolver.js +16 -0
  43. package/lib/abis/TokenizedVaultV2.d.ts +1364 -0
  44. package/lib/abis/TokenizedVaultV2.js +1041 -0
  45. package/lib/abis/TokenizedVaultV2DepositWithPermit.d.ts +1456 -0
  46. package/lib/abis/TokenizedVaultV2DepositWithPermit.js +1878 -0
  47. package/lib/abis/TokenizedVaultV2Receipt.d.ts +1568 -0
  48. package/lib/abis/TokenizedVaultV2Receipt.js +1061 -0
  49. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.d.ts +454 -0
  50. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js +327 -0
  51. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.d.ts +1466 -0
  52. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js +1092 -0
  53. package/lib/abis/TokenizedVaultV2WhitelistedAssets.d.ts +274 -0
  54. package/lib/abis/TokenizedVaultV2WhitelistedAssets.js +167 -0
  55. package/lib/abis/UniversalResolverResolve.d.ts +69 -0
  56. package/lib/abis/UniversalResolverResolve.js +35 -0
  57. package/lib/abis/UniversalSignatureValidator.d.ts +17 -0
  58. package/lib/abis/UniversalSignatureValidator.js +30 -0
  59. package/lib/abis/WrapperAdapter.d.ts +71 -0
  60. package/lib/abis/WrapperAdapter.js +77 -0
  61. package/lib/abis/index.d.ts +34 -0
  62. package/lib/abis/index.js +51 -0
  63. package/lib/adapters/evm/getters.d.ts +19 -0
  64. package/lib/adapters/evm/getters.js +209 -0
  65. package/lib/adapters/evm/index.d.ts +353 -0
  66. package/lib/adapters/evm/index.js +434 -0
  67. package/lib/adapters/evm/utils.d.ts +8 -0
  68. package/lib/adapters/evm/utils.js +51 -0
  69. package/lib/adapters/solana/constants.d.ts +33 -0
  70. package/lib/adapters/solana/constants.js +52 -0
  71. package/lib/adapters/solana/getters.d.ts +11 -0
  72. package/lib/adapters/solana/getters.js +165 -0
  73. package/lib/adapters/solana/idl/vault-idl.d.ts +272 -0
  74. package/lib/adapters/solana/idl/vault-idl.js +1084 -0
  75. package/lib/adapters/solana/index.d.ts +233 -0
  76. package/lib/adapters/solana/index.js +291 -0
  77. package/lib/adapters/solana/types.d.ts +67 -0
  78. package/lib/adapters/solana/types.js +3 -0
  79. package/lib/adapters/solana/utils.d.ts +141 -0
  80. package/lib/adapters/solana/utils.js +595 -0
  81. package/lib/adapters/solana/vault.actions.d.ts +57 -0
  82. package/lib/adapters/solana/vault.actions.js +379 -0
  83. package/lib/adapters/stellar/actions.d.ts +28 -0
  84. package/lib/adapters/stellar/actions.js +77 -0
  85. package/lib/adapters/stellar/constants.d.ts +43 -0
  86. package/lib/adapters/stellar/constants.js +53 -0
  87. package/lib/adapters/stellar/getters.d.ts +68 -0
  88. package/lib/adapters/stellar/getters.js +290 -0
  89. package/lib/adapters/stellar/index.d.ts +114 -0
  90. package/lib/adapters/stellar/index.js +175 -0
  91. package/lib/adapters/stellar/soroban.d.ts +123 -0
  92. package/lib/adapters/stellar/soroban.js +613 -0
  93. package/lib/adapters/stellar/submit.d.ts +34 -0
  94. package/lib/adapters/stellar/submit.js +149 -0
  95. package/lib/adapters/stellar/types.d.ts +58 -0
  96. package/lib/adapters/stellar/types.js +6 -0
  97. package/lib/adapters/stellar/utils.d.ts +24 -0
  98. package/lib/adapters/stellar/utils.js +34 -0
  99. package/lib/adapters/sui/constants.d.ts +14 -0
  100. package/lib/adapters/sui/constants.js +29 -0
  101. package/lib/adapters/sui/getters.d.ts +9 -0
  102. package/lib/adapters/sui/getters.js +60 -0
  103. package/lib/adapters/sui/index.d.ts +45 -0
  104. package/lib/adapters/sui/index.js +101 -0
  105. package/lib/adapters/sui/transformer.d.ts +10 -0
  106. package/lib/adapters/sui/transformer.js +107 -0
  107. package/lib/adapters/sui/types.d.ts +66 -0
  108. package/lib/adapters/sui/types.js +3 -0
  109. package/lib/adapters/sui/utils.d.ts +10 -0
  110. package/lib/adapters/sui/utils.js +29 -0
  111. package/lib/core/analytics/chain-name.d.ts +9 -0
  112. package/lib/core/analytics/chain-name.js +34 -0
  113. package/lib/core/analytics/constants.d.ts +5 -0
  114. package/lib/core/analytics/constants.js +9 -0
  115. package/lib/core/analytics/env.d.ts +29 -0
  116. package/lib/core/analytics/env.js +59 -0
  117. package/lib/core/analytics/index.d.ts +36 -0
  118. package/lib/core/analytics/index.js +79 -0
  119. package/lib/core/analytics/instrumentation.d.ts +29 -0
  120. package/lib/core/analytics/instrumentation.js +277 -0
  121. package/lib/core/analytics/method-taxonomy.d.ts +19 -0
  122. package/lib/core/analytics/method-taxonomy.js +128 -0
  123. package/lib/core/analytics/metrics.d.ts +33 -0
  124. package/lib/core/analytics/metrics.js +116 -0
  125. package/lib/core/analytics/sanitize.d.ts +44 -0
  126. package/lib/core/analytics/sanitize.js +260 -0
  127. package/lib/core/analytics/sentry-runtime.d.ts +15 -0
  128. package/lib/core/analytics/sentry-runtime.js +97 -0
  129. package/lib/core/analytics/sentry.d.ts +67 -0
  130. package/lib/core/analytics/sentry.js +613 -0
  131. package/lib/core/analytics/types.d.ts +48 -0
  132. package/lib/core/analytics/types.js +3 -0
  133. package/lib/core/analytics/user-identity.d.ts +41 -0
  134. package/lib/core/analytics/user-identity.js +141 -0
  135. package/lib/core/analytics/version.d.ts +6 -0
  136. package/lib/core/analytics/version.js +10 -0
  137. package/lib/core/attribution.d.ts +111 -0
  138. package/lib/core/attribution.js +142 -0
  139. package/lib/core/auth/index.d.ts +1 -0
  140. package/lib/core/auth/index.js +18 -0
  141. package/lib/core/auth/verify.d.ts +2 -0
  142. package/lib/core/auth/verify.js +31 -0
  143. package/lib/core/base.class.d.ts +152 -0
  144. package/lib/core/base.class.js +172 -0
  145. package/lib/core/cache.d.ts +9 -0
  146. package/lib/core/cache.js +31 -0
  147. package/lib/core/constants/adapters.d.ts +103 -0
  148. package/lib/core/constants/adapters.js +180 -0
  149. package/lib/core/constants/core.d.ts +133 -0
  150. package/lib/core/constants/core.js +209 -0
  151. package/lib/core/constants/swap-router.d.ts +150 -0
  152. package/lib/core/constants/swap-router.js +169 -0
  153. package/lib/core/constants/vaults.d.ts +93 -0
  154. package/lib/core/constants/vaults.js +273 -0
  155. package/lib/core/constants/web3.d.ts +91 -0
  156. package/lib/core/constants/web3.js +229 -0
  157. package/lib/core/errors/index.d.ts +114 -0
  158. package/lib/core/errors/index.js +183 -0
  159. package/lib/core/fetcher.d.ts +198 -0
  160. package/lib/core/fetcher.js +903 -0
  161. package/lib/core/helpers/adapters.d.ts +13 -0
  162. package/lib/core/helpers/adapters.js +39 -0
  163. package/lib/core/helpers/chain-address.d.ts +13 -0
  164. package/lib/core/helpers/chain-address.js +47 -0
  165. package/lib/core/helpers/chain-error.d.ts +207 -0
  166. package/lib/core/helpers/chain-error.js +682 -0
  167. package/lib/core/helpers/chain-support.d.ts +80 -0
  168. package/lib/core/helpers/chain-support.js +115 -0
  169. package/lib/core/helpers/core.d.ts +68 -0
  170. package/lib/core/helpers/core.js +285 -0
  171. package/lib/core/helpers/explorer-link.d.ts +16 -0
  172. package/lib/core/helpers/explorer-link.js +26 -0
  173. package/lib/core/helpers/multicall.d.ts +68 -0
  174. package/lib/core/helpers/multicall.js +103 -0
  175. package/lib/core/helpers/revert-decode.d.ts +248 -0
  176. package/lib/core/helpers/revert-decode.js +515 -0
  177. package/lib/core/helpers/signer.d.ts +52 -0
  178. package/lib/core/helpers/signer.js +145 -0
  179. package/lib/core/helpers/swap-router.d.ts +211 -0
  180. package/lib/core/helpers/swap-router.js +480 -0
  181. package/lib/core/helpers/vault-version.d.ts +23 -0
  182. package/lib/core/helpers/vault-version.js +75 -0
  183. package/lib/core/helpers/vaults.d.ts +89 -0
  184. package/lib/core/helpers/vaults.js +235 -0
  185. package/lib/core/helpers/web3.d.ts +353 -0
  186. package/lib/core/helpers/web3.js +992 -0
  187. package/lib/core/index.d.ts +23 -0
  188. package/lib/core/index.js +40 -0
  189. package/lib/core/logger/index.d.ts +98 -0
  190. package/lib/core/logger/index.js +144 -0
  191. package/lib/core/logger/slack.d.ts +16 -0
  192. package/lib/core/logger/slack.js +57 -0
  193. package/lib/core/vault-metadata.d.ts +12 -0
  194. package/lib/core/vault-metadata.js +42 -0
  195. package/lib/core/version-check.d.ts +58 -0
  196. package/lib/core/version-check.js +182 -0
  197. package/lib/evm/index.d.ts +2 -0
  198. package/lib/evm/index.js +19 -0
  199. package/lib/evm/methods/crossChainVault.d.ts +128 -0
  200. package/lib/evm/methods/crossChainVault.js +853 -0
  201. package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
  202. package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
  203. package/lib/evm/methods/index.d.ts +2 -0
  204. package/lib/evm/methods/index.js +19 -0
  205. package/lib/evm/types/crossChain.d.ts +363 -0
  206. package/lib/evm/types/crossChain.js +20 -0
  207. package/lib/evm/types/index.d.ts +1 -0
  208. package/lib/evm/types/index.js +18 -0
  209. package/lib/index.d.ts +30 -0
  210. package/lib/index.js +52 -0
  211. package/lib/main.d.ts +527 -0
  212. package/lib/main.js +601 -0
  213. package/lib/modules/api/fetcher.d.ts +82 -0
  214. package/lib/modules/api/fetcher.js +150 -0
  215. package/lib/modules/api/index.d.ts +1 -0
  216. package/lib/modules/api/index.js +6 -0
  217. package/lib/modules/api/main.d.ts +313 -0
  218. package/lib/modules/api/main.js +479 -0
  219. package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
  220. package/lib/modules/sub-accounts/fetcher.js +120 -0
  221. package/lib/modules/sub-accounts/index.d.ts +2 -0
  222. package/lib/modules/sub-accounts/index.js +19 -0
  223. package/lib/modules/sub-accounts/main.d.ts +243 -0
  224. package/lib/modules/sub-accounts/main.js +205 -0
  225. package/lib/modules/sub-accounts/utils.d.ts +106 -0
  226. package/lib/modules/sub-accounts/utils.js +112 -0
  227. package/lib/modules/vaults/adapter.helpers.d.ts +64 -0
  228. package/lib/modules/vaults/adapter.helpers.js +184 -0
  229. package/lib/modules/vaults/fetcher.d.ts +147 -0
  230. package/lib/modules/vaults/fetcher.js +368 -0
  231. package/lib/modules/vaults/getters.d.ts +570 -0
  232. package/lib/modules/vaults/getters.js +3051 -0
  233. package/lib/modules/vaults/index.d.ts +20 -0
  234. package/lib/modules/vaults/index.js +44 -0
  235. package/lib/modules/vaults/main.d.ts +601 -0
  236. package/lib/modules/vaults/main.js +1623 -0
  237. package/lib/modules/vaults/prefetch.d.ts +65 -0
  238. package/lib/modules/vaults/prefetch.js +120 -0
  239. package/lib/modules/vaults/read.actions.d.ts +225 -0
  240. package/lib/modules/vaults/read.actions.js +596 -0
  241. package/lib/modules/vaults/types.d.ts +71 -0
  242. package/lib/modules/vaults/types.js +3 -0
  243. package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
  244. package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
  245. package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
  246. package/lib/modules/vaults/utils/date-utils.js +84 -0
  247. package/lib/modules/vaults/utils.d.ts +140 -0
  248. package/lib/modules/vaults/utils.js +799 -0
  249. package/lib/modules/vaults/write.actions.d.ts +529 -0
  250. package/lib/modules/vaults/write.actions.js +1749 -0
  251. package/lib/polyfills.d.ts +1 -0
  252. package/lib/polyfills.js +12 -0
  253. package/lib/sdk.d.ts +26721 -0
  254. package/lib/services/coingecko/fetcher.d.ts +15 -0
  255. package/lib/services/coingecko/fetcher.js +67 -0
  256. package/lib/services/coingecko/index.d.ts +2 -0
  257. package/lib/services/coingecko/index.js +19 -0
  258. package/lib/services/coingecko/utils.d.ts +1 -0
  259. package/lib/services/coingecko/utils.js +24 -0
  260. package/lib/services/debank/fetcher.d.ts +126 -0
  261. package/lib/services/debank/fetcher.js +47 -0
  262. package/lib/services/debank/index.d.ts +2 -0
  263. package/lib/services/debank/index.js +19 -0
  264. package/lib/services/debank/utils.d.ts +38 -0
  265. package/lib/services/debank/utils.js +297 -0
  266. package/lib/services/layerzero/deposits.d.ts +49 -0
  267. package/lib/services/layerzero/deposits.js +166 -0
  268. package/lib/services/layerzero/redeems.d.ts +20 -0
  269. package/lib/services/layerzero/redeems.js +92 -0
  270. package/lib/services/layerzero/utils.d.ts +9 -0
  271. package/lib/services/layerzero/utils.js +22 -0
  272. package/lib/services/octavfi/fetcher.d.ts +9 -0
  273. package/lib/services/octavfi/fetcher.js +103 -0
  274. package/lib/services/octavfi/index.d.ts +3 -0
  275. package/lib/services/octavfi/index.js +20 -0
  276. package/lib/services/octavfi/types.d.ts +34 -0
  277. package/lib/services/octavfi/types.js +3 -0
  278. package/lib/services/octavfi/utils.d.ts +16 -0
  279. package/lib/services/octavfi/utils.js +212 -0
  280. package/lib/services/subgraph/fetcher.d.ts +2 -0
  281. package/lib/services/subgraph/fetcher.js +61 -0
  282. package/lib/services/subgraph/index.d.ts +2 -0
  283. package/lib/services/subgraph/index.js +19 -0
  284. package/lib/services/subgraph/schema.d.ts +45 -0
  285. package/lib/services/subgraph/schema.js +75 -0
  286. package/lib/services/subgraph/vaults.d.ts +25 -0
  287. package/lib/services/subgraph/vaults.js +1106 -0
  288. package/lib/services/swap-quotes/index.d.ts +105 -0
  289. package/lib/services/swap-quotes/index.js +77 -0
  290. package/lib/services/swap-quotes/paraswap.d.ts +51 -0
  291. package/lib/services/swap-quotes/paraswap.js +138 -0
  292. package/lib/types/api.d.ts +280 -0
  293. package/lib/types/api.js +3 -0
  294. package/lib/types/index.d.ts +12 -0
  295. package/lib/types/index.js +28 -0
  296. package/lib/types/points.d.ts +28 -0
  297. package/lib/types/points.js +3 -0
  298. package/lib/types/pools.d.ts +144 -0
  299. package/lib/types/pools.js +3 -0
  300. package/lib/types/staking.d.ts +28 -0
  301. package/lib/types/staking.js +3 -0
  302. package/lib/types/sub-accounts.d.ts +140 -0
  303. package/lib/types/sub-accounts.js +3 -0
  304. package/lib/types/subgraph.d.ts +74 -0
  305. package/lib/types/subgraph.js +3 -0
  306. package/lib/types/typed-contract.d.ts +102 -0
  307. package/lib/types/typed-contract.js +3 -0
  308. package/lib/types/user.d.ts +1 -0
  309. package/lib/types/user.js +3 -0
  310. package/lib/types/vaults.d.ts +714 -0
  311. package/lib/types/vaults.js +24 -0
  312. package/lib/types/web3.d.ts +51 -0
  313. package/lib/types/web3.js +14 -0
  314. package/lib/types/webserver.d.ts +698 -0
  315. package/lib/types/webserver.js +3 -0
  316. package/package.json +78 -0
@@ -0,0 +1,290 @@
1
+ "use strict";
2
+ /**
3
+ * Stellar Vault Getters
4
+ *
5
+ * Data fetching for Stellar vaults. Enriches backend metadata with on-chain
6
+ * total assets, total supply, and share decimals from Soroban RPC. Also
7
+ * provides user position queries and deposit preview (convertToShares).
8
+ * Falls back to backend TVL for total assets, zero for total supply, and
9
+ * STELLAR_FALLBACK_DECIMALS for share decimals when on-chain queries fail.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.convertToShares = exports.getStellarUserPosition = exports.getStellarVault = void 0;
13
+ const stellar_sdk_1 = require("@stellar/stellar-sdk");
14
+ const core_1 = require("../../core");
15
+ const utils_1 = require("../../modules/vaults/utils");
16
+ const constants_1 = require("./constants");
17
+ const soroban_1 = require("./soroban");
18
+ /**
19
+ * Parse an ScVal into a share-decimals value, reporting whether the
20
+ * authoritative on-chain value was available.
21
+ *
22
+ * Returns `{ decimals, fromFallback }`. When the `decimals()` retval is missing
23
+ * or unparseable, `decimals` is STELLAR_FALLBACK_DECIMALS (7) and `fromFallback`
24
+ * is `true` — the signal callers need to avoid trusting a fabricated scale (a
25
+ * silent 7 under-redeems ERC4626 offset vaults; see AUGUST-6381). A successful
26
+ * parse returns the on-chain value with `fromFallback: false`.
27
+ */
28
+ function parseDecimals(scVal, context, vaultAddress) {
29
+ if (!scVal) {
30
+ core_1.Logger.log.error(context, 'Decimals not available — using fallback (financial values may be incorrect)', {
31
+ vault: vaultAddress,
32
+ fallbackDecimals: constants_1.STELLAR_FALLBACK_DECIMALS,
33
+ });
34
+ return { decimals: constants_1.STELLAR_FALLBACK_DECIMALS, fromFallback: true };
35
+ }
36
+ try {
37
+ return { decimals: Number((0, stellar_sdk_1.scValToBigInt)(scVal)), fromFallback: false };
38
+ }
39
+ catch (parseErr) {
40
+ core_1.Logger.log.error(context, 'Failed to parse decimals from Soroban — using fallback (financial values may be incorrect)', {
41
+ vault: vaultAddress,
42
+ fallbackDecimals: constants_1.STELLAR_FALLBACK_DECIMALS,
43
+ error: String(parseErr),
44
+ });
45
+ return { decimals: constants_1.STELLAR_FALLBACK_DECIMALS, fromFallback: true };
46
+ }
47
+ }
48
+ /**
49
+ * Parse an ScVal into a decimals number, returning the fallback on failure.
50
+ * Thin wrapper over {@link parseDecimals} for callers that only need the value
51
+ * (the fallback is already surfaced via logs). Prefer `parseDecimals` when the
52
+ * caller must distinguish a fallback from an authoritative read.
53
+ */
54
+ function parseDecimalsOrFallback(scVal, context, vaultAddress) {
55
+ return parseDecimals(scVal, context, vaultAddress).decimals;
56
+ }
57
+ /**
58
+ * Resolve the Stellar network for a vault from its backend metadata.
59
+ * Logs a warning when falling back to mainnet.
60
+ */
61
+ function resolveNetwork(tokenizedVault) {
62
+ const meta = tokenizedVault.stellar_vault_metadata;
63
+ const networkName = meta?.network_name;
64
+ if (networkName === 'testnet' || networkName === 'mainnet') {
65
+ return networkName;
66
+ }
67
+ if (networkName) {
68
+ core_1.Logger.log.warn('resolveNetwork', `Unrecognized network "${networkName}", falling back to mainnet`, { vault: tokenizedVault.address });
69
+ }
70
+ else {
71
+ core_1.Logger.log.warn('resolveNetwork', 'No network_name in vault metadata — defaulting to mainnet', { vault: tokenizedVault.address });
72
+ }
73
+ return 'mainnet';
74
+ }
75
+ /**
76
+ * Build a unified IVault from backend + on-chain data for Stellar vaults.
77
+ * Reads total assets and total supply from the Soroban contract via RPC.
78
+ * Falls back to backend `latest_reported_tvl` for total assets, or zero
79
+ * for total supply, when on-chain queries fail.
80
+ */
81
+ const getStellarVault = async (tokenizedVault, options) => {
82
+ const stellarMetadata = tokenizedVault.stellar_vault_metadata;
83
+ const depositDecimals = stellarMetadata?.deposit_token_decimals ?? constants_1.STELLAR_FALLBACK_DECIMALS;
84
+ if (stellarMetadata?.deposit_token_decimals == null) {
85
+ core_1.Logger.log.warn('getStellarVault', 'Using fallback decimals — TVL may be incorrect if deposit token is not 7 decimals', {
86
+ vault: tokenizedVault.address,
87
+ depositToken: stellarMetadata?.deposit_token_address ?? 'UNKNOWN',
88
+ STELLAR_FALLBACK_DECIMALS: constants_1.STELLAR_FALLBACK_DECIMALS,
89
+ });
90
+ }
91
+ // Attempt on-chain queries for total assets, total supply, and share decimals
92
+ const network = resolveNetwork(tokenizedVault);
93
+ // Only apply the configured RPC override when it matches this vault's network
94
+ // (a testnet override must not be used for a mainnet read). `options` may be
95
+ // omitted by JS callers, so guard it.
96
+ const overrideRpcUrl = options?.stellarRpc?.network === network
97
+ ? options.stellarRpc.rpcUrl
98
+ : undefined;
99
+ const config = (0, soroban_1.resolveNetworkConfig)(network, overrideRpcUrl);
100
+ const [assetsResult, supplyResult, decimalsResult] = await Promise.all([
101
+ (0, soroban_1.queryContract)(config, tokenizedVault.address, 'total_assets'),
102
+ (0, soroban_1.queryContract)(config, tokenizedVault.address, 'total_supply'),
103
+ (0, soroban_1.queryContract)(config, tokenizedVault.address, 'decimals'),
104
+ ]);
105
+ // Share token decimals may differ from deposit token decimals
106
+ const shareDecimals = parseDecimalsOrFallback(decimalsResult, 'getStellarVault', tokenizedVault.address);
107
+ let totalAssets;
108
+ if (assetsResult) {
109
+ try {
110
+ const rawAssets = (0, stellar_sdk_1.scValToBigInt)(assetsResult);
111
+ totalAssets = (0, core_1.toNormalizedBn)(rawAssets, depositDecimals);
112
+ }
113
+ catch (parseErr) {
114
+ core_1.Logger.log.warn('getStellarVault', 'Failed to parse total_assets from Soroban — falling back to backend TVL', { vault: tokenizedVault.address, error: String(parseErr) });
115
+ totalAssets = (0, utils_1.backendTvlToNormalizedBn)(tokenizedVault.latest_reported_tvl, depositDecimals);
116
+ }
117
+ }
118
+ else {
119
+ core_1.Logger.log.warn('getStellarVault', 'Could not fetch total_assets from Soroban — falling back to backend TVL', { vault: tokenizedVault.address });
120
+ totalAssets = (0, utils_1.backendTvlToNormalizedBn)(tokenizedVault.latest_reported_tvl, depositDecimals);
121
+ }
122
+ let totalSupply = (0, core_1.toNormalizedBn)(0, shareDecimals);
123
+ if (supplyResult) {
124
+ try {
125
+ const rawSupply = (0, stellar_sdk_1.scValToBigInt)(supplyResult);
126
+ totalSupply = (0, core_1.toNormalizedBn)(rawSupply, shareDecimals);
127
+ }
128
+ catch (parseErr) {
129
+ core_1.Logger.log.warn('getStellarVault', 'Failed to parse total_supply from Soroban', { vault: tokenizedVault.address, error: String(parseErr) });
130
+ }
131
+ }
132
+ else {
133
+ core_1.Logger.log.warn('getStellarVault', 'Could not fetch total_supply from Soroban — falling back to 0', { vault: tokenizedVault.address });
134
+ }
135
+ const depositAsset = {
136
+ address: stellarMetadata?.deposit_token_address ?? '',
137
+ symbol: stellarMetadata?.deposit_token_symbol ?? 'UNKNOWN',
138
+ decimals: depositDecimals,
139
+ };
140
+ const isDepositPaused = !depositAsset.address;
141
+ if (isDepositPaused) {
142
+ core_1.Logger.log.warn('getStellarVault', 'Missing deposit asset address — vault will be marked as deposit-paused', { vault: tokenizedVault.address });
143
+ }
144
+ return (0, utils_1.buildBackendVault)(tokenizedVault, {
145
+ isDepositPaused,
146
+ chainId: constants_1.STELLAR_CHAIN_ID,
147
+ version: 'stellar-0',
148
+ name: tokenizedVault.vault_name || 'Stellar Vault',
149
+ totalAssets,
150
+ totalSupply,
151
+ depositAssets: [depositAsset],
152
+ receipt: {
153
+ address: tokenizedVault.address,
154
+ symbol: tokenizedVault.receipt_token_symbol || 'UNKNOWN',
155
+ decimals: shareDecimals,
156
+ },
157
+ });
158
+ };
159
+ exports.getStellarVault = getStellarVault;
160
+ /**
161
+ * Get user position for a Stellar vault.
162
+ * Queries the vault contract's balance(address) and decimals() functions via Soroban RPC.
163
+ *
164
+ * Returns `{ shares, decimals, decimalsFromFallback }` on success (shares may be
165
+ * '0' for zero balance), or null when the balance query fails. The two reads are
166
+ * independent: a `decimals()` failure does NOT null the result — instead
167
+ * `decimals` falls back to STELLAR_FALLBACK_DECIMALS (7) and
168
+ * `decimalsFromFallback` is set to `true` so callers can tell a fabricated 7
169
+ * apart from a genuine 7-decimal vault.
170
+ *
171
+ * Why this matters: an ERC4626 offset vault has share decimals = asset + offset
172
+ * (e.g. 13). A consumer that sizes a redeem trusting a silent fallback 7 would
173
+ * under-redeem by `10^offset`. Callers that settle a redeem from this position
174
+ * MUST refuse (surface an error) when `decimalsFromFallback` is `true` rather
175
+ * than trusting `decimals`. See AUGUST-6381 (follow-up to AUGUST-6380).
176
+ *
177
+ * @param vaultAddress - Stellar vault contract ID (C… address)
178
+ * @param walletAddress - User's Stellar account (G… address); validated upfront
179
+ * @param network - 'mainnet' | 'testnet' (defaults to 'mainnet')
180
+ * @param sorobanRpcUrl - Optional override Soroban RPC endpoint (e.g. a keyed
181
+ * Alchemy URL); becomes the primary with the SDK's public endpoints kept as
182
+ * failover. Omit to use the public endpoints.
183
+ * @returns The position, or `null` if the balance read failed or was unparseable.
184
+ * @throws AugustValidationError on an invalid `walletAddress`.
185
+ * @example
186
+ * ```ts
187
+ * const pos = await getStellarUserPosition(vault, wallet, 'mainnet');
188
+ * if (!pos || pos.decimalsFromFallback) {
189
+ * // Refuse to size a redeem — share scale is not authoritatively known.
190
+ * throw new Error('Stellar share decimals unresolved');
191
+ * }
192
+ * const human = Number(pos.shares) / 10 ** pos.decimals;
193
+ * ```
194
+ */
195
+ const getStellarUserPosition = async (vaultAddress, walletAddress, network = 'mainnet', sorobanRpcUrl) => {
196
+ const config = (0, soroban_1.resolveNetworkConfig)(network, sorobanRpcUrl);
197
+ // Validate address upfront — invalid input is a caller bug, not an RPC issue
198
+ let userAddress;
199
+ try {
200
+ userAddress = new stellar_sdk_1.Address(walletAddress);
201
+ }
202
+ catch (addrErr) {
203
+ throw new core_1.AugustValidationError('INVALID_ADDRESS', `getStellarUserPosition: invalid walletAddress "${walletAddress}": ${String(addrErr)}`, { cause: addrErr });
204
+ }
205
+ try {
206
+ // Fetch balance and decimals in parallel — they're independent queries
207
+ const [balanceResult, decimalsResult] = await Promise.all([
208
+ (0, soroban_1.queryContract)(config, vaultAddress, 'balance', [userAddress.toScVal()]),
209
+ (0, soroban_1.queryContract)(config, vaultAddress, 'decimals'),
210
+ ]);
211
+ const { decimals, fromFallback: decimalsFromFallback } = parseDecimals(decimalsResult, 'getStellarUserPosition', vaultAddress);
212
+ if (!balanceResult) {
213
+ core_1.Logger.log.warn('getStellarUserPosition', 'Balance query returned null', {
214
+ vault: vaultAddress,
215
+ wallet: walletAddress,
216
+ });
217
+ return null;
218
+ }
219
+ let rawBalance;
220
+ try {
221
+ rawBalance = (0, stellar_sdk_1.scValToBigInt)(balanceResult);
222
+ }
223
+ catch (parseErr) {
224
+ core_1.Logger.log.error('getStellarUserPosition', 'Failed to parse balance ScVal — possible contract incompatibility', {
225
+ vault: vaultAddress,
226
+ wallet: walletAddress,
227
+ error: String(parseErr),
228
+ });
229
+ return null;
230
+ }
231
+ return {
232
+ shares: rawBalance.toString(),
233
+ decimals,
234
+ decimalsFromFallback,
235
+ };
236
+ }
237
+ catch (err) {
238
+ core_1.Logger.log.error('getStellarUserPosition', 'Unexpected error querying Stellar user position', {
239
+ vault: vaultAddress,
240
+ wallet: walletAddress,
241
+ error: String(err),
242
+ });
243
+ return null;
244
+ }
245
+ };
246
+ exports.getStellarUserPosition = getStellarUserPosition;
247
+ /**
248
+ * Query the vault's `convert_to_shares` to preview how many shares a deposit
249
+ * amount would yield. Returns the raw share amount as a string, or null on
250
+ * failure.
251
+ *
252
+ * @param vaultAddress Stellar contract ID (C… address)
253
+ * @param rawAmount Deposit amount in the deposit token's smallest unit
254
+ * @param network 'mainnet' | 'testnet'
255
+ * @param sorobanRpcUrl - Optional override Soroban RPC endpoint (e.g. a keyed
256
+ * Alchemy URL); becomes the primary with the SDK's public endpoints kept as
257
+ * failover. Omit to use the public endpoints.
258
+ */
259
+ const convertToShares = async (vaultAddress, rawAmount, network = 'mainnet', sorobanRpcUrl) => {
260
+ // Validate address upfront — invalid input is a caller bug, not an RPC issue
261
+ try {
262
+ new stellar_sdk_1.Address(vaultAddress);
263
+ }
264
+ catch (addrErr) {
265
+ throw new core_1.AugustValidationError('INVALID_ADDRESS', `convertToShares: invalid vaultAddress "${vaultAddress}": ${String(addrErr)}`, { cause: addrErr });
266
+ }
267
+ const config = (0, soroban_1.resolveNetworkConfig)(network, sorobanRpcUrl);
268
+ const amountBigInt = (0, soroban_1.toBigIntAmount)(rawAmount, 'rawAmount');
269
+ const amountScVal = (0, stellar_sdk_1.nativeToScVal)(amountBigInt, { type: 'i128' });
270
+ const result = await (0, soroban_1.queryContract)(config, vaultAddress, 'convert_to_shares', [amountScVal]);
271
+ if (!result) {
272
+ core_1.Logger.log.warn('convertToShares', 'Soroban query returned no result', {
273
+ vault: vaultAddress,
274
+ rawAmount,
275
+ });
276
+ return null;
277
+ }
278
+ try {
279
+ return (0, stellar_sdk_1.scValToBigInt)(result).toString();
280
+ }
281
+ catch (err) {
282
+ core_1.Logger.log.error('convertToShares', 'Failed to parse result — possible contract incompatibility', {
283
+ vault: vaultAddress,
284
+ error: String(err),
285
+ });
286
+ return null;
287
+ }
288
+ };
289
+ exports.convertToShares = convertToShares;
290
+ //# sourceMappingURL=getters.js.map
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Stellar Adapter for August SDK
3
+ *
4
+ * Provides Stellar vault operations: deposit, redeem, position queries,
5
+ * and on-chain data fetching via Soroban RPC.
6
+ *
7
+ * @module StellarAdapter
8
+ */
9
+ import * as StellarConstants from './constants';
10
+ import * as StellarGetters from './getters';
11
+ import * as StellarActions from './actions';
12
+ import * as StellarSubmit from './submit';
13
+ import type { IStellarNetwork, IStellarDepositParams, IStellarRedeemParams, IStellarUserPosition } from './types';
14
+ export declare const Stellar: {
15
+ utils: {
16
+ isStellarAddress: typeof import("./utils").isStellarAddress;
17
+ getExplorerLink: typeof import("./utils").getExplorerLink;
18
+ assertNotStellar: typeof import("./utils").assertNotStellar;
19
+ };
20
+ constants: typeof StellarConstants;
21
+ actions: typeof StellarActions;
22
+ submit: typeof StellarSubmit;
23
+ getters: typeof StellarGetters;
24
+ };
25
+ /**
26
+ * Stellar Adapter for August SDK
27
+ *
28
+ * @example
29
+ * ```
30
+ * const adapter = new StellarAdapter('testnet');
31
+ * const xdr = await adapter.vaultDeposit({
32
+ * contractId: 'CBGWW5...',
33
+ * amount: '1000000',
34
+ * senderAddress: 'GDLZ...',
35
+ * });
36
+ * // Sign xdr with wallet (e.g. Freighter), then submit via adapter.submitTransaction()
37
+ * ```
38
+ */
39
+ export declare class StellarAdapter {
40
+ private _network;
41
+ /**
42
+ * Optional consumer-supplied Soroban RPC endpoint (e.g. a keyed Alchemy URL).
43
+ * When set it is the primary, with the SDK's public endpoints as failover.
44
+ */
45
+ private _sorobanRpcUrl?;
46
+ /**
47
+ * @param network - Stellar network to operate on; defaults to `'mainnet'`.
48
+ * @param options - Optional adapter configuration. Its `sorobanRpcUrl` field
49
+ * overrides the Soroban RPC endpoint (e.g. a keyed Alchemy URL): it becomes
50
+ * the primary with the SDK's built-in public endpoints kept behind it as
51
+ * failover, and a per-call `sorobanRpcUrl` (on the deposit/redeem params)
52
+ * takes precedence over this adapter-level one.
53
+ */
54
+ constructor(network?: IStellarNetwork, options?: {
55
+ sorobanRpcUrl?: string;
56
+ });
57
+ get network(): IStellarNetwork;
58
+ isStellarAddress(address: string): boolean;
59
+ getExplorerLink(id: string, type?: 'contract' | 'account' | 'tx'): string;
60
+ /**
61
+ * Build an unsigned deposit transaction for a Stellar vault.
62
+ * @returns Base64-encoded XDR of the unsigned transaction.
63
+ */
64
+ vaultDeposit(params: Omit<IStellarDepositParams, 'network'>): Promise<string>;
65
+ /**
66
+ * Build an unsigned redeem transaction for a Stellar vault.
67
+ * @returns Base64-encoded XDR of the unsigned transaction.
68
+ */
69
+ vaultRedeem(params: Omit<IStellarRedeemParams, 'network'>): Promise<string>;
70
+ /**
71
+ * Submit a signed Soroban transaction and poll until the network confirms it.
72
+ *
73
+ * Submits on the network this adapter was constructed with, so `signedXdr`
74
+ * must be signed for that same network.
75
+ *
76
+ * @param signedXdr - Base64-encoded XDR of the signed transaction.
77
+ * @returns The transaction hash once the network confirms it as successful.
78
+ * @throws {@link AugustTimeoutError} when the transaction is not confirmed
79
+ * within the poll budget (`MAX_POLL_ATTEMPTS`).
80
+ * @throws {@link AugustSDKError} when the RPC rejects the submission or the
81
+ * transaction confirms as failed. Its `context` carries `{ network, status }`
82
+ * plus, when the result XDR decodes, a `resultCode` string holding the
83
+ * transaction-level reason (e.g. `"txBadSeq"`, `"txTooLate"`); `resultCode`
84
+ * is `undefined` when the code cannot be decoded.
85
+ * @example
86
+ * ```ts
87
+ * try {
88
+ * const hash = await adapter.submitTransaction(signedXdr);
89
+ * } catch (err) {
90
+ * if (err instanceof AugustSDKError && err.context?.resultCode === 'txBadSeq') {
91
+ * // stale sequence number — rebuild the transaction and resubmit
92
+ * }
93
+ * }
94
+ * ```
95
+ */
96
+ submitTransaction(signedXdr: string): Promise<string>;
97
+ /**
98
+ * Get user's vault share balance.
99
+ *
100
+ * @returns The position `{ shares, decimals, decimalsFromFallback }`, or null
101
+ * if the balance read fails. When `decimalsFromFallback` is `true` the
102
+ * `decimals()` read failed and `decimals` is the fallback (7) — callers sizing
103
+ * a redeem MUST refuse rather than trust it (see AUGUST-6381).
104
+ */
105
+ getUserPosition(vaultAddress: string, walletAddress: string): Promise<IStellarUserPosition | null>;
106
+ /**
107
+ * Preview how many vault shares a deposit amount would yield.
108
+ * @param vaultAddress Stellar contract ID (C… address)
109
+ * @param rawAmount Deposit amount in the deposit token's smallest unit
110
+ * @returns Raw share amount as a string, or null if query fails.
111
+ */
112
+ convertToShares(vaultAddress: string, rawAmount: string): Promise<string | null>;
113
+ }
114
+ export default StellarAdapter;
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ /**
3
+ * Stellar Adapter for August 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 August 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
+ * @returns Base64-encoded XDR of the unsigned transaction.
114
+ */
115
+ async vaultRedeem(params) {
116
+ return StellarActions.handleStellarRedeem({
117
+ ...params,
118
+ network: this._network,
119
+ // A per-call override (params.sorobanRpcUrl) wins over the adapter-level one.
120
+ sorobanRpcUrl: params.sorobanRpcUrl ?? this._sorobanRpcUrl,
121
+ });
122
+ }
123
+ /**
124
+ * Submit a signed Soroban transaction and poll until the network confirms it.
125
+ *
126
+ * Submits on the network this adapter was constructed with, so `signedXdr`
127
+ * must be signed for that same network.
128
+ *
129
+ * @param signedXdr - Base64-encoded XDR of the signed transaction.
130
+ * @returns The transaction hash once the network confirms it as successful.
131
+ * @throws {@link AugustTimeoutError} when the transaction is not confirmed
132
+ * within the poll budget (`MAX_POLL_ATTEMPTS`).
133
+ * @throws {@link AugustSDKError} when the RPC rejects the submission or the
134
+ * transaction confirms as failed. Its `context` carries `{ network, status }`
135
+ * plus, when the result XDR decodes, a `resultCode` string holding the
136
+ * transaction-level reason (e.g. `"txBadSeq"`, `"txTooLate"`); `resultCode`
137
+ * is `undefined` when the code cannot be decoded.
138
+ * @example
139
+ * ```ts
140
+ * try {
141
+ * const hash = await adapter.submitTransaction(signedXdr);
142
+ * } catch (err) {
143
+ * if (err instanceof AugustSDKError && err.context?.resultCode === 'txBadSeq') {
144
+ * // stale sequence number — rebuild the transaction and resubmit
145
+ * }
146
+ * }
147
+ * ```
148
+ */
149
+ async submitTransaction(signedXdr) {
150
+ return StellarSubmit.submitStellarTransaction(signedXdr, this._network, this._sorobanRpcUrl);
151
+ }
152
+ /**
153
+ * Get user's vault share balance.
154
+ *
155
+ * @returns The position `{ shares, decimals, decimalsFromFallback }`, or null
156
+ * if the balance read fails. When `decimalsFromFallback` is `true` the
157
+ * `decimals()` read failed and `decimals` is the fallback (7) — callers sizing
158
+ * a redeem MUST refuse rather than trust it (see AUGUST-6381).
159
+ */
160
+ async getUserPosition(vaultAddress, walletAddress) {
161
+ return StellarGetters.getStellarUserPosition(vaultAddress, walletAddress, this._network, this._sorobanRpcUrl);
162
+ }
163
+ /**
164
+ * Preview how many vault shares a deposit amount would yield.
165
+ * @param vaultAddress Stellar contract ID (C… address)
166
+ * @param rawAmount Deposit amount in the deposit token's smallest unit
167
+ * @returns Raw share amount as a string, or null if query fails.
168
+ */
169
+ async convertToShares(vaultAddress, rawAmount) {
170
+ return StellarGetters.convertToShares(vaultAddress, rawAmount, this._network, this._sorobanRpcUrl);
171
+ }
172
+ }
173
+ exports.StellarAdapter = StellarAdapter;
174
+ exports.default = StellarAdapter;
175
+ //# sourceMappingURL=index.js.map