@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,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.functionsToCallReduction = exports.functionsToCallMapping = void 0;
4
+ const core_1 = require("../../core");
5
+ /**
6
+ * @todo
7
+ */
8
+ const functionsToCallMapping = (provider, contract, functionCalls) => {
9
+ return functionCalls.map((f) => {
10
+ if (f === 'symbol') {
11
+ return (0, core_1.getSymbol)(provider, contract);
12
+ }
13
+ if (f === 'decimals') {
14
+ return (0, core_1.getDecimals)(provider, contract);
15
+ }
16
+ return contract[f]();
17
+ });
18
+ };
19
+ exports.functionsToCallMapping = functionsToCallMapping;
20
+ /**
21
+ * @todo
22
+ */
23
+ const functionsToCallReduction = (acc, curr, i, functionCalls, contractCalls) => {
24
+ let val;
25
+ if (functionCalls[i] === 'totalSupply' ||
26
+ functionCalls[i] === 'totalAssets' ||
27
+ functionCalls[i] === 'globalLoansAmount' ||
28
+ functionCalls[i] === 'maxSupply' ||
29
+ functionCalls[i] === 'depositCap') {
30
+ val = (0, core_1.toNormalizedBn)(curr, contractCalls[0]);
31
+ }
32
+ else if (functionCalls[i] === 'getTotalLoansDeployed') {
33
+ val = (0, core_1.toNormalizedBn)(curr, 0);
34
+ }
35
+ else if (functionCalls[i] === 'withdrawalFee') {
36
+ val = (0, core_1.toNormalizedBn)(curr, 2);
37
+ }
38
+ else if (functionCalls[i] === 'decimals') {
39
+ val = Number(curr.toString());
40
+ }
41
+ else if (functionCalls[i] === 'loansOperator') {
42
+ // TODO: hardcoded as we cannot pull the real strategist
43
+ val = '0x4DCb388488622e47683EAd1a147947140a31e485';
44
+ }
45
+ else {
46
+ val = curr;
47
+ }
48
+ return { ...acc, [functionCalls[i]]: val };
49
+ };
50
+ exports.functionsToCallReduction = functionsToCallReduction;
51
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,88 @@
1
+ import { AnchorProvider } from '@coral-xyz/anchor';
2
+ import { type Commitment, type ConfirmOptions, type Connection, type Signer, type Transaction, type TransactionSignature, type VersionedTransaction } from '@solana/web3.js';
3
+ /** Delay between signature-status polls. */
4
+ export declare const CONFIRM_POLL_INTERVAL_MS = 2000;
5
+ /**
6
+ * Wall-clock backstop, also bounding every in-flight RPC read (web3.js sets no
7
+ * request timeout). Expiry is normally seen first: a blockhash lasts ~150
8
+ * blocks (~60s, longer when slots are skipped), and the finalized height it is checked against lags ~13s.
9
+ */
10
+ export declare const CONFIRM_TIMEOUT_MS = 120000;
11
+ /** Cap on a single RPC read, so a hung request counts as a failed read rather than eating the backstop. */
12
+ export declare const CONFIRM_READ_TIMEOUT_MS = 10000;
13
+ /** Ceiling for the doubling wait after polls whose reads failed. */
14
+ export declare const CONFIRM_MAX_BACKOFF_MS = 16000;
15
+ /**
16
+ * Wait for a sent transaction to reach `commitment`, over HTTP only.
17
+ *
18
+ * Anchor's `.rpc()` confirms by signature alone: a WebSocket
19
+ * `signatureSubscribe` raced against a fixed 30s (`confirmed`) or 60s
20
+ * (`finalized`) timer, so a transaction that landed is reported as failed
21
+ * whenever the notification is missed. This polls `getSignatureStatuses`, and
22
+ * ends on the blockhash's real expiry rather than a timer.
23
+ *
24
+ * It never reports that resubmitting is safe. An expired transaction that no
25
+ * lookup can find very likely never landed, but an RPC node with incomplete
26
+ * history cannot prove it, and a wrong "safe" duplicates a deposit or redeem.
27
+ *
28
+ * @param connection - Connection the transaction was sent through.
29
+ * @param signature - Signature returned by `sendRawTransaction`.
30
+ * @param lastValidBlockHeight - Expiry of the blockhash the signed
31
+ * transaction carries, checked against the finalized block height. Omit
32
+ * when unknown (or for a durable-nonce transaction): the wait then ends only
33
+ * on confirmation, failure or `timeoutMs`.
34
+ * @param commitment - Level the transaction must reach.
35
+ * @param pollIntervalMs - Delay between polls; must be positive. Defaults to {@link CONFIRM_POLL_INTERVAL_MS}.
36
+ * @param timeoutMs - Wall-clock backstop; must be positive. Defaults to {@link CONFIRM_TIMEOUT_MS}.
37
+ * @param readTimeoutMs - Cap on each RPC read; must be positive. Defaults to {@link CONFIRM_READ_TIMEOUT_MS}.
38
+ * @returns `signature`, once its status reaches `commitment` with no error.
39
+ * @throws {@link SendTransactionError} when the transaction failed at
40
+ * `commitment`, with logs attached for Anchor's `translateError`.
41
+ * @throws {@link UpshiftTransactionError} `TRANSACTION_UNCONFIRMED` when no
42
+ * outcome was established: the blockhash expired with the transaction
43
+ * nowhere to be found, or `timeoutMs` passed. `context.reason` is
44
+ * `expired_not_found` (very likely never landed — still check before
45
+ * resubmitting), `below_commitment` (seen landing without error),
46
+ * `failed_below_commitment` (seen failing, not yet final), `rpc_failing`
47
+ * (reads failed) or `not_visible`; `context` also carries the last status
48
+ * seen and read counts, and `cause` the last failed read.
49
+ * @throws {@link UpshiftValidationError} for a non-positive or non-finite interval or timeout.
50
+ * @remarks **RPC cost.** The first poll runs right after sending. Per poll: one `getSignatureStatuses`, plus one
51
+ * finalized `getBlockHeight` while the transaction is not visible (and, past
52
+ * expiry, one history lookup). Typically 1–3 calls at `confirmed`, ~7–10 at
53
+ * `finalized`, ~60 for an expiring transaction; the `timeoutMs` backstop
54
+ * allows ~60 polls of 1–3 calls, fewer while reads fail: the wait doubles
55
+ * after each poll with a failed read, up to {@link CONFIRM_MAX_BACKOFF_MS}. Failed reads are tolerated, so a transient RPC
56
+ * error never misreports a landed transaction.
57
+ */
58
+ export declare function confirmByBlockhash({ connection, signature, lastValidBlockHeight, commitment, pollIntervalMs, timeoutMs, readTimeoutMs, }: {
59
+ connection: Connection;
60
+ signature: TransactionSignature;
61
+ lastValidBlockHeight?: number;
62
+ commitment: Commitment;
63
+ pollIntervalMs?: number;
64
+ timeoutMs?: number;
65
+ readTimeoutMs?: number;
66
+ }): Promise<TransactionSignature>;
67
+ /**
68
+ * `AnchorProvider` whose `sendAndConfirm` — what `program.methods…rpc()` calls —
69
+ * confirms with {@link confirmByBlockhash} instead of Anchor's signature-only
70
+ * WebSocket wait. Signing and Anchor's error translation are unchanged.
71
+ */
72
+ export declare class BlockhashConfirmingProvider extends AnchorProvider {
73
+ /**
74
+ * Sign, send and confirm a transaction.
75
+ *
76
+ * @param tx - Transaction to send. Its blockhash (and fee payer, if unset)
77
+ * are set here. A `VersionedTransaction` already carries a blockhash this
78
+ * cannot learn the expiry of, so it takes Anchor's default path.
79
+ * @param signers - Extra signers besides the wallet.
80
+ * @param opts - Defaults to the provider's options.
81
+ * @returns The transaction signature.
82
+ * @throws See {@link confirmByBlockhash}; also whatever the wallet or
83
+ * `sendRawTransaction` throws (user rejection, preflight failure).
84
+ * @remarks **RPC cost.** `getLatestBlockhash` + `sendRawTransaction`, then
85
+ * the confirmation polls described on {@link confirmByBlockhash}.
86
+ */
87
+ sendAndConfirm(tx: Transaction | VersionedTransaction, signers?: Signer[], opts?: ConfirmOptions): Promise<TransactionSignature>;
88
+ }
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BlockhashConfirmingProvider = exports.CONFIRM_MAX_BACKOFF_MS = exports.CONFIRM_READ_TIMEOUT_MS = exports.CONFIRM_TIMEOUT_MS = exports.CONFIRM_POLL_INTERVAL_MS = void 0;
4
+ exports.confirmByBlockhash = confirmByBlockhash;
5
+ const anchor_1 = require("@coral-xyz/anchor");
6
+ const web3_js_1 = require("@solana/web3.js");
7
+ const core_1 = require("../../core");
8
+ const concurrency_1 = require("../../core/helpers/concurrency");
9
+ /** Delay between signature-status polls. */
10
+ exports.CONFIRM_POLL_INTERVAL_MS = 2_000;
11
+ /**
12
+ * Wall-clock backstop, also bounding every in-flight RPC read (web3.js sets no
13
+ * request timeout). Expiry is normally seen first: a blockhash lasts ~150
14
+ * blocks (~60s, longer when slots are skipped), and the finalized height it is checked against lags ~13s.
15
+ */
16
+ exports.CONFIRM_TIMEOUT_MS = 120_000;
17
+ /** Cap on a single RPC read, so a hung request counts as a failed read rather than eating the backstop. */
18
+ exports.CONFIRM_READ_TIMEOUT_MS = 10_000;
19
+ /** Ceiling for the doubling wait after polls whose reads failed. */
20
+ exports.CONFIRM_MAX_BACKOFF_MS = 16_000;
21
+ const COMMITMENT_RANK = {
22
+ processed: 0,
23
+ recent: 0,
24
+ confirmed: 1,
25
+ single: 1,
26
+ singleGossip: 1,
27
+ finalized: 2,
28
+ max: 2,
29
+ root: 2,
30
+ };
31
+ /**
32
+ * The level a status has reached. Older RPCs omit `confirmationStatus`; the
33
+ * level is then inferred from `confirmations` as Agave's
34
+ * `TransactionStatus::satisfies_commitment` does: `null` is rooted, more than
35
+ * one confirmation is `confirmed`, anything else `processed`.
36
+ */
37
+ function levelOf(status) {
38
+ if (status.confirmationStatus)
39
+ return status.confirmationStatus;
40
+ if (status.confirmations === null)
41
+ return 'finalized';
42
+ return status.confirmations > 1 ? 'confirmed' : 'processed';
43
+ }
44
+ function reaches(status, commitment) {
45
+ return COMMITMENT_RANK[levelOf(status)] >= COMMITMENT_RANK[commitment];
46
+ }
47
+ /**
48
+ * Wait for a sent transaction to reach `commitment`, over HTTP only.
49
+ *
50
+ * Anchor's `.rpc()` confirms by signature alone: a WebSocket
51
+ * `signatureSubscribe` raced against a fixed 30s (`confirmed`) or 60s
52
+ * (`finalized`) timer, so a transaction that landed is reported as failed
53
+ * whenever the notification is missed. This polls `getSignatureStatuses`, and
54
+ * ends on the blockhash's real expiry rather than a timer.
55
+ *
56
+ * It never reports that resubmitting is safe. An expired transaction that no
57
+ * lookup can find very likely never landed, but an RPC node with incomplete
58
+ * history cannot prove it, and a wrong "safe" duplicates a deposit or redeem.
59
+ *
60
+ * @param connection - Connection the transaction was sent through.
61
+ * @param signature - Signature returned by `sendRawTransaction`.
62
+ * @param lastValidBlockHeight - Expiry of the blockhash the signed
63
+ * transaction carries, checked against the finalized block height. Omit
64
+ * when unknown (or for a durable-nonce transaction): the wait then ends only
65
+ * on confirmation, failure or `timeoutMs`.
66
+ * @param commitment - Level the transaction must reach.
67
+ * @param pollIntervalMs - Delay between polls; must be positive. Defaults to {@link CONFIRM_POLL_INTERVAL_MS}.
68
+ * @param timeoutMs - Wall-clock backstop; must be positive. Defaults to {@link CONFIRM_TIMEOUT_MS}.
69
+ * @param readTimeoutMs - Cap on each RPC read; must be positive. Defaults to {@link CONFIRM_READ_TIMEOUT_MS}.
70
+ * @returns `signature`, once its status reaches `commitment` with no error.
71
+ * @throws {@link SendTransactionError} when the transaction failed at
72
+ * `commitment`, with logs attached for Anchor's `translateError`.
73
+ * @throws {@link UpshiftTransactionError} `TRANSACTION_UNCONFIRMED` when no
74
+ * outcome was established: the blockhash expired with the transaction
75
+ * nowhere to be found, or `timeoutMs` passed. `context.reason` is
76
+ * `expired_not_found` (very likely never landed — still check before
77
+ * resubmitting), `below_commitment` (seen landing without error),
78
+ * `failed_below_commitment` (seen failing, not yet final), `rpc_failing`
79
+ * (reads failed) or `not_visible`; `context` also carries the last status
80
+ * seen and read counts, and `cause` the last failed read.
81
+ * @throws {@link UpshiftValidationError} for a non-positive or non-finite interval or timeout.
82
+ * @remarks **RPC cost.** The first poll runs right after sending. Per poll: one `getSignatureStatuses`, plus one
83
+ * finalized `getBlockHeight` while the transaction is not visible (and, past
84
+ * expiry, one history lookup). Typically 1–3 calls at `confirmed`, ~7–10 at
85
+ * `finalized`, ~60 for an expiring transaction; the `timeoutMs` backstop
86
+ * allows ~60 polls of 1–3 calls, fewer while reads fail: the wait doubles
87
+ * after each poll with a failed read, up to {@link CONFIRM_MAX_BACKOFF_MS}. Failed reads are tolerated, so a transient RPC
88
+ * error never misreports a landed transaction.
89
+ */
90
+ async function confirmByBlockhash({ connection, signature, lastValidBlockHeight, commitment, pollIntervalMs = exports.CONFIRM_POLL_INTERVAL_MS, timeoutMs = exports.CONFIRM_TIMEOUT_MS, readTimeoutMs = exports.CONFIRM_READ_TIMEOUT_MS, }) {
91
+ for (const [name, value] of [
92
+ ['pollIntervalMs', pollIntervalMs],
93
+ ['timeoutMs', timeoutMs],
94
+ ['readTimeoutMs', readTimeoutMs],
95
+ ]) {
96
+ if (!Number.isFinite(value) || value <= 0)
97
+ throw new core_1.UpshiftValidationError('INVALID_INPUT', `confirmByBlockhash: ${name} must be a positive finite number, got ${value}.`);
98
+ }
99
+ const deadline = Date.now() + timeoutMs;
100
+ let reads = 0;
101
+ let failedReads = 0;
102
+ let lastReadError;
103
+ let lastSeen;
104
+ /** Finalized block height at which the transaction was found expired and absent. */
105
+ let expiredAt;
106
+ /** One RPC read; `undefined` when it failed or hung (outcome unknown). */
107
+ const read = async (call) => {
108
+ reads += 1;
109
+ const remaining = deadline - Date.now();
110
+ // Records whether the RPC itself rejected, so a timeout is told apart from
111
+ // a failure by which promise lost, not by reading the clock.
112
+ let rpcFailure;
113
+ const pending = call().catch((error) => {
114
+ rpcFailure = { error };
115
+ throw error;
116
+ });
117
+ try {
118
+ return await (0, concurrency_1.withTimeout)(pending, Math.min(readTimeoutMs, remaining), 'Solana RPC read');
119
+ }
120
+ catch (timeout) {
121
+ // The timer was the backstop's, not the per-read cap: not an RPC failure.
122
+ if (!rpcFailure && remaining < readTimeoutMs)
123
+ return undefined;
124
+ failedReads += 1;
125
+ lastReadError = rpcFailure ? rpcFailure.error : timeout;
126
+ return undefined;
127
+ }
128
+ };
129
+ const statusOf = (searchTransactionHistory = false) => read(() => connection
130
+ .getSignatureStatuses([signature], { searchTransactionHistory })
131
+ .then((r) => r.value[0]));
132
+ /**
133
+ * `true` once `status` is final at `commitment`; throws if it failed there.
134
+ * A failure seen below `commitment` is not final yet, as in Anchor.
135
+ */
136
+ const settled = async (status) => {
137
+ lastSeen = status;
138
+ if (!reaches(status, commitment))
139
+ return false;
140
+ if (!status.err)
141
+ return true;
142
+ const tx = await read(() => connection.getTransaction(signature, {
143
+ commitment: 'confirmed',
144
+ maxSupportedTransactionVersion: 0,
145
+ }));
146
+ // Keep `JSON.stringify(status.err)` in the message: without logs, Anchor's
147
+ // `ProgramError.parse` recovers the program error code from its
148
+ // `"Custom":N}`.
149
+ throw new web3_js_1.SendTransactionError({
150
+ action: 'send',
151
+ signature,
152
+ transactionMessage: `Transaction failed: ${JSON.stringify(status.err)}`,
153
+ logs: tx?.meta?.logMessages ?? undefined,
154
+ });
155
+ };
156
+ /** One poll: `true` once confirmed; throws on a definitive failure. */
157
+ const pollOnce = async () => {
158
+ // `undefined` = read failed (unknown); `null` = not visible to the RPC.
159
+ const status = await statusOf();
160
+ if (status)
161
+ return settled(status);
162
+ // Seen before but gone now (dropped fork): no longer evidence it landed.
163
+ if (status === null)
164
+ lastSeen = undefined;
165
+ if (status === undefined || lastValidBlockHeight === undefined)
166
+ return false;
167
+ // Finalized, whatever `commitment` is: a `processed`/`confirmed` height can
168
+ // belong to a fork that is later dropped while the transaction still lands
169
+ // on the surviving one. Past the finalized height, every fork is expired.
170
+ const height = await read(() => connection.getBlockHeight('finalized'));
171
+ if (height === undefined || height <= lastValidBlockHeight)
172
+ return false;
173
+ // Past expiry. Last look, including history, in case it landed between polls.
174
+ const final = await statusOf(true);
175
+ if (final)
176
+ return settled(final);
177
+ if (final === null)
178
+ expiredAt = height;
179
+ return false;
180
+ };
181
+ // Poll first: a transaction often lands within a second of sending. After a
182
+ // poll with a failed read, the wait doubles (up to the ceiling) so a failing
183
+ // RPC is not hit at full cadence; a clean poll restores the normal interval.
184
+ let backoff = 0;
185
+ for (;;) {
186
+ const failedBefore = failedReads;
187
+ if (await pollOnce())
188
+ return signature;
189
+ if (expiredAt !== undefined)
190
+ break;
191
+ backoff = failedReads > failedBefore ? backoff + 1 : 0;
192
+ const interval = Math.min(pollIntervalMs * 2 ** backoff, Math.max(pollIntervalMs, exports.CONFIRM_MAX_BACKOFF_MS));
193
+ const wait = Math.min(interval, deadline - Date.now());
194
+ if (wait <= 0)
195
+ break;
196
+ await new Promise((r) => setTimeout(r, wait));
197
+ }
198
+ const seconds = timeoutMs / 1000;
199
+ const seenAt = lastSeen ? levelOf(lastSeen) : null;
200
+ const reason = expiredAt !== undefined
201
+ ? 'expired_not_found'
202
+ : !lastSeen
203
+ ? failedReads > 0
204
+ ? 'rpc_failing'
205
+ : 'not_visible'
206
+ : lastSeen.err
207
+ ? 'failed_below_commitment'
208
+ : 'below_commitment';
209
+ const message = {
210
+ expired_not_found: `Transaction ${signature} was not found and its blockhash has expired (block height exceeded), ` +
211
+ 'so it very likely never landed. This cannot be proven from the RPC; check the signature before resubmitting.',
212
+ below_commitment: `Transaction ${signature} landed without error (${seenAt}) but was not confirmed in ${seconds} seconds ` +
213
+ `at '${commitment}'. Do not resubmit; it is most likely to finalize.`,
214
+ failed_below_commitment: `Transaction ${signature} was seen failing (${seenAt}) but was not confirmed in ${seconds} seconds ` +
215
+ `at '${commitment}', so the failure is not final yet. Check the signature before resubmitting.`,
216
+ rpc_failing: undefined,
217
+ not_visible: undefined,
218
+ }[reason];
219
+ throw new core_1.UpshiftTransactionError(message ??
220
+ `Transaction ${signature} was not confirmed in ${seconds} seconds. ` +
221
+ 'It is unknown if it succeeded or failed; check the signature before resubmitting.', signature, {
222
+ cause: expiredAt !== undefined
223
+ ? new web3_js_1.TransactionExpiredBlockheightExceededError(signature)
224
+ : lastReadError,
225
+ context: {
226
+ signature,
227
+ commitment,
228
+ reason,
229
+ ...(expiredAt !== undefined && {
230
+ lastValidBlockHeight,
231
+ blockHeight: expiredAt,
232
+ }),
233
+ lastSeenStatus: seenAt,
234
+ lastSeenErr: lastSeen?.err ?? null,
235
+ reads,
236
+ failedReads,
237
+ },
238
+ });
239
+ }
240
+ /**
241
+ * `AnchorProvider` whose `sendAndConfirm` — what `program.methods…rpc()` calls —
242
+ * confirms with {@link confirmByBlockhash} instead of Anchor's signature-only
243
+ * WebSocket wait. Signing and Anchor's error translation are unchanged.
244
+ */
245
+ class BlockhashConfirmingProvider extends anchor_1.AnchorProvider {
246
+ /**
247
+ * Sign, send and confirm a transaction.
248
+ *
249
+ * @param tx - Transaction to send. Its blockhash (and fee payer, if unset)
250
+ * are set here. A `VersionedTransaction` already carries a blockhash this
251
+ * cannot learn the expiry of, so it takes Anchor's default path.
252
+ * @param signers - Extra signers besides the wallet.
253
+ * @param opts - Defaults to the provider's options.
254
+ * @returns The transaction signature.
255
+ * @throws See {@link confirmByBlockhash}; also whatever the wallet or
256
+ * `sendRawTransaction` throws (user rejection, preflight failure).
257
+ * @remarks **RPC cost.** `getLatestBlockhash` + `sendRawTransaction`, then
258
+ * the confirmation polls described on {@link confirmByBlockhash}.
259
+ */
260
+ async sendAndConfirm(tx, signers, opts = this.opts) {
261
+ if ('version' in tx)
262
+ return super.sendAndConfirm(tx, signers, opts);
263
+ const commitment = opts.commitment ?? this.connection.commitment ?? 'finalized';
264
+ const preflightCommitment = opts.preflightCommitment ?? commitment;
265
+ const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash(preflightCommitment);
266
+ tx.feePayer = tx.feePayer ?? this.wallet.publicKey;
267
+ tx.recentBlockhash = blockhash;
268
+ for (const signer of signers ?? [])
269
+ tx.partialSign(signer);
270
+ const signed = await this.wallet.signTransaction(tx);
271
+ const signature = await this.connection.sendRawTransaction(signed.serialize(), {
272
+ skipPreflight: opts.skipPreflight,
273
+ preflightCommitment,
274
+ maxRetries: opts.maxRetries,
275
+ minContextSlot: opts.minContextSlot,
276
+ });
277
+ return confirmByBlockhash({
278
+ connection: this.connection,
279
+ signature,
280
+ // The expiry fetched here only bounds a tx that carries this blockhash.
281
+ // A wallet may re-stamp it when signing, and a durable-nonce tx
282
+ // serializes its nonce instead; either way it could still land.
283
+ lastValidBlockHeight: !signed.nonceInfo && signed.recentBlockhash === blockhash
284
+ ? lastValidBlockHeight
285
+ : undefined,
286
+ commitment,
287
+ });
288
+ }
289
+ }
290
+ exports.BlockhashConfirmingProvider = BlockhashConfirmingProvider;
291
+ //# sourceMappingURL=confirm.js.map
@@ -0,0 +1,42 @@
1
+ import type { ISolanaNetwork } from '../../types';
2
+ import { vaultIdl } from './idl/vault-idl';
3
+ declare const fallbackDecimals = 8;
4
+ declare const fallbackNetwork: ISolanaNetwork;
5
+ /**
6
+ * Program ids deployed on one Solana network. `withdrawalQueue` is absent where
7
+ * the queue program is not deployed.
8
+ */
9
+ type ISolanaProgramIds = {
10
+ vault: string;
11
+ withdrawalQueue?: string;
12
+ };
13
+ declare const fallbackRpcEndpoints: {
14
+ readonly devnet: "https://api.devnet.solana.com";
15
+ readonly mainnet: "https://api.mainnet-beta.solana.com";
16
+ readonly testnet: "https://api.testnet.solana.com";
17
+ readonly localnet: "http://127.0.0.1:8899";
18
+ };
19
+ declare const programIds: {
20
+ devnet: {
21
+ vault: string;
22
+ withdrawalQueue: string;
23
+ };
24
+ "mainnet-beta": {
25
+ vault: string;
26
+ withdrawalQueue: string;
27
+ };
28
+ localnet: {
29
+ vault: string;
30
+ withdrawalQueue: string;
31
+ };
32
+ };
33
+ /** Solana networks the canonical august_vault program is actually deployed on. */
34
+ type ISolanaDeployedNetwork = keyof typeof programIds;
35
+ /**
36
+ * Program ids for `network`, or `undefined` when the canonical program has no
37
+ * deployment there (currently `testnet`). Callers must handle `undefined` —
38
+ * silently substituting a default would hand back a dead address.
39
+ */
40
+ declare function getDeployedProgramIds(network: ISolanaNetwork): ISolanaProgramIds | undefined;
41
+ export { fallbackDecimals, fallbackNetwork, fallbackRpcEndpoints, getDeployedProgramIds, programIds, vaultIdl, };
42
+ export type { ISolanaDeployedNetwork, ISolanaProgramIds };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vaultIdl = exports.programIds = exports.fallbackRpcEndpoints = exports.fallbackNetwork = exports.fallbackDecimals = void 0;
4
+ exports.getDeployedProgramIds = getDeployedProgramIds;
5
+ const vault_idl_1 = require("./idl/vault-idl");
6
+ Object.defineProperty(exports, "vaultIdl", { enumerable: true, get: function () { return vault_idl_1.vaultIdl; } });
7
+ const fallbackDecimals = 8;
8
+ exports.fallbackDecimals = fallbackDecimals;
9
+ const fallbackNetwork = 'mainnet-beta';
10
+ exports.fallbackNetwork = fallbackNetwork;
11
+ const fallbackRpcEndpoints = {
12
+ devnet: 'https://api.devnet.solana.com',
13
+ mainnet: 'https://api.mainnet-beta.solana.com',
14
+ testnet: 'https://api.testnet.solana.com',
15
+ localnet: 'http://127.0.0.1:8899',
16
+ };
17
+ exports.fallbackRpcEndpoints = fallbackRpcEndpoints;
18
+ // The shared, canonical august_vault program (multi-vault), deployed under the
19
+ // same id (`up12…`) on devnet and mainnet-beta. Per-vault program deploys (e.g.
20
+ // the legacy SyrupBTC `7B8n…`, and the interim devnet `C8B1…`) are retired. At
21
+ // runtime the program id is resolved from backend vault metadata; this map is
22
+ // the default/fallback.
23
+ //
24
+ // Deliberately partial: no `testnet` entry — the program isn't deployed there,
25
+ // and mapping it would hand callers a dead address that only fails deep inside a
26
+ // transaction. Unmapped networks throw from `getProgram`/`getProgramId` instead.
27
+ // `satisfies` keeps the literal ids in the generated docs while checking keys
28
+ // against ISolanaNetwork, so `testnet` is absent from the type, not optional.
29
+ //
30
+ // `withdrawalQueue` is the august_withdrawal_queue program. Its id is fixed (the
31
+ // vault binary hardcodes it as `WITHDRAWAL_QUEUE_PROGRAM_ID`), and it is mapped
32
+ // where deployed: mainnet-beta since release v0.3.0 (14 Oct 2026), devnet and
33
+ // localnet. Mapping the program says nothing about any one vault: whether a
34
+ // vault redeems through a queue is read per vault, from its
35
+ // `withdrawalQueueAuthority`, and a vault without one keeps direct redemption.
36
+ const programIds = {
37
+ devnet: {
38
+ vault: 'up12bytoZBmwofqsySf2uqKQ7zpfeKiAWwfvqzJjtRt',
39
+ withdrawalQueue: 'upQhC7mgYwmHLVaatRWoGAu394piLT9th9FiQZHnPrW',
40
+ },
41
+ ['mainnet-beta']: {
42
+ vault: 'up12bytoZBmwofqsySf2uqKQ7zpfeKiAWwfvqzJjtRt',
43
+ withdrawalQueue: 'upQhC7mgYwmHLVaatRWoGAu394piLT9th9FiQZHnPrW',
44
+ },
45
+ localnet: {
46
+ vault: 'up12bytoZBmwofqsySf2uqKQ7zpfeKiAWwfvqzJjtRt',
47
+ withdrawalQueue: 'upQhC7mgYwmHLVaatRWoGAu394piLT9th9FiQZHnPrW',
48
+ },
49
+ };
50
+ exports.programIds = programIds;
51
+ /**
52
+ * Program ids for `network`, or `undefined` when the canonical program has no
53
+ * deployment there (currently `testnet`). Callers must handle `undefined` —
54
+ * silently substituting a default would hand back a dead address.
55
+ */
56
+ function getDeployedProgramIds(network) {
57
+ return programIds[network];
58
+ }
59
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,42 @@
1
+ import type { ITokenizedVault } from '../../types';
2
+ import type { IVaultBaseOptions } from '../../modules/vaults/types';
3
+ /**
4
+ * Fetch Solana vault data from on-chain program state.
5
+ * Falls back to backend-only data when Solana RPC is unavailable,
6
+ * ensuring vaults always appear in the list even without on-chain access.
7
+ *
8
+ * When the vault has a withdrawal queue, `withdrawalQueue` carries its live
9
+ * summary, at the cost of one extra `getMultipleAccountsInfo` (the queue and a
10
+ * fresh read of the vault state, for `enabled`). A failed queue read is
11
+ * logged and leaves the field out rather than failing the vault.
12
+ * @param tokenizedVault Vault metadata from backend
13
+ * @param options RPC configuration with Solana service
14
+ * @returns Formatted vault object with Solana-specific fields
15
+ */
16
+ export declare const getSolanaVault: (tokenizedVault: ITokenizedVault, options: IVaultBaseOptions) => Promise<import("../../types").IVault>;
17
+ /**
18
+ * A Solana vault's AUM in USD, split the way its program stores it.
19
+ */
20
+ export interface ISolanaVaultAumUsd {
21
+ /** `deployed_aum`: what the operator has marked as deployed. */
22
+ deployedUsd: number;
23
+ /** `local_aum`: what the vault program itself holds. */
24
+ idleUsd: number;
25
+ }
26
+ /**
27
+ * Read a Solana vault's AUM in USD fresh from its state account.
28
+ *
29
+ * For comparing the vault with live portfolio data: the state cache behind
30
+ * {@link getSolanaVault} can be up to 24h old, which would show yield accrued
31
+ * since as unattributed. Costs one uncached vault-state read (plus the deposit
32
+ * mint's decimals), then one cached price lookup.
33
+ *
34
+ * Never rejects. A failed read, a missing state account or symbol, or a
35
+ * non-positive price returns `null`, so the caller can drop the comparison
36
+ * without losing the rest of its result.
37
+ *
38
+ * @param tokenizedVault - Backend row of the Solana vault
39
+ * @param options - Must carry `solanaService` for the RPC connection
40
+ * @returns The vault's deployed and idle AUM in USD, or `null`
41
+ */
42
+ export declare function getSolanaVaultAumUsd(tokenizedVault: ITokenizedVault, options: IVaultBaseOptions): Promise<ISolanaVaultAumUsd | null>;