@wireio/stake 0.1.2 → 0.1.69

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 (526) hide show
  1. package/README.md +185 -243
  2. package/lib/stake.browser.js +64499 -6547
  3. package/lib/stake.browser.js.map +1 -1
  4. package/lib/stake.d.ts +18865 -349
  5. package/lib/stake.js +64886 -6551
  6. package/lib/stake.js.map +1 -1
  7. package/lib/stake.m.js +64499 -6547
  8. package/lib/stake.m.js.map +1 -1
  9. package/package.json +6 -3
  10. package/src/assets/ethereum/hoodi/common/Base58.sol/Base58.dbg.json +4 -0
  11. package/src/assets/ethereum/hoodi/common/Base58.sol/Base58.json +164 -0
  12. package/src/assets/ethereum/hoodi/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.dbg.json +4 -0
  13. package/src/assets/ethereum/hoodi/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.json +76 -0
  14. package/src/assets/ethereum/hoodi/common/RestrictedCallers.sol/RestrictedCallers.dbg.json +4 -0
  15. package/src/assets/ethereum/hoodi/common/RestrictedCallers.sol/RestrictedCallers.json +10 -0
  16. package/src/assets/ethereum/hoodi/common/iodata.sol/iodata.dbg.json +4 -0
  17. package/src/assets/ethereum/hoodi/common/iodata.sol/iodata.json +618 -0
  18. package/src/assets/ethereum/hoodi/common/iodata_util.sol/iodata_util.dbg.json +4 -0
  19. package/src/assets/ethereum/hoodi/common/iodata_util.sol/iodata_util.json +40 -0
  20. package/src/assets/ethereum/hoodi/common/sysio_data.sol/sysio_data.dbg.json +4 -0
  21. package/src/assets/ethereum/hoodi/common/sysio_data.sol/sysio_data.json +10 -0
  22. package/src/assets/ethereum/hoodi/common/sysio_errors.sol/sysio_errors.dbg.json +4 -0
  23. package/src/assets/ethereum/hoodi/common/sysio_errors.sol/sysio_errors.json +10 -0
  24. package/src/assets/ethereum/hoodi/common/sysio_merkle.sol/sysio_merkle.dbg.json +4 -0
  25. package/src/assets/ethereum/hoodi/common/sysio_merkle.sol/sysio_merkle.json +233 -0
  26. package/src/assets/ethereum/hoodi/common/sysio_name.sol/sysio_name.dbg.json +4 -0
  27. package/src/assets/ethereum/hoodi/common/sysio_name.sol/sysio_name.json +49 -0
  28. package/src/assets/ethereum/hoodi/common/sysio_pubkey.sol/sysio_pubkey.dbg.json +4 -0
  29. package/src/assets/ethereum/hoodi/common/sysio_pubkey.sol/sysio_pubkey.json +64 -0
  30. package/src/assets/ethereum/hoodi/common/sysio_read.sol/sysio_read.dbg.json +4 -0
  31. package/src/assets/ethereum/hoodi/common/sysio_read.sol/sysio_read.json +1458 -0
  32. package/src/assets/ethereum/hoodi/common/sysio_tester.sol/SysioTester.dbg.json +4 -0
  33. package/src/assets/ethereum/hoodi/common/sysio_tester.sol/SysioTester.json +1532 -0
  34. package/src/assets/ethereum/hoodi/common/sysio_verify.sol/sysio_verify.dbg.json +4 -0
  35. package/src/assets/ethereum/hoodi/common/sysio_verify.sol/sysio_verify.json +1525 -0
  36. package/src/assets/ethereum/hoodi/common/sysio_write.sol/sysio_write.dbg.json +4 -0
  37. package/src/assets/ethereum/hoodi/common/sysio_write.sol/sysio_write.json +1076 -0
  38. package/src/assets/ethereum/hoodi/liqEth/BeaconState.sol/BeaconState.dbg.json +4 -0
  39. package/src/assets/ethereum/hoodi/liqEth/BeaconState.sol/BeaconState.json +807 -0
  40. package/src/assets/ethereum/hoodi/liqEth/DepositManager.sol/DepositManagerV2.dbg.json +4 -0
  41. package/src/assets/ethereum/hoodi/liqEth/DepositManager.sol/DepositManagerV2.json +985 -0
  42. package/src/assets/ethereum/hoodi/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +4 -0
  43. package/src/assets/ethereum/hoodi/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +1289 -0
  44. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +4 -0
  45. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IAccounting.json +182 -0
  46. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
  47. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
  48. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
  49. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
  50. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
  51. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20.json +319 -0
  52. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
  53. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +333 -0
  54. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
  55. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IStakingModule.json +344 -0
  56. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
  57. package/src/assets/ethereum/{ABI → hoodi}/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +59 -0
  58. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
  59. package/src/assets/ethereum/{ABI → hoodi}/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +14 -12
  60. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
  61. package/src/assets/ethereum/{ABI → hoodi}/liqEth/LiqEthCommon.sol/LiqEthCommon.json +2 -2
  62. package/src/assets/ethereum/hoodi/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.dbg.json +4 -0
  63. package/src/assets/ethereum/hoodi/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.json +236 -0
  64. package/src/assets/ethereum/hoodi/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +4 -0
  65. package/src/assets/ethereum/hoodi/liqEth/LiqEthManaged.sol/LiqEthManaged.json +229 -0
  66. package/src/assets/ethereum/hoodi/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.dbg.json +4 -0
  67. package/src/assets/ethereum/hoodi/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.json +957 -0
  68. package/src/assets/ethereum/hoodi/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.dbg.json +4 -0
  69. package/src/assets/ethereum/hoodi/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.json +1020 -0
  70. package/src/assets/ethereum/hoodi/liqEth/Yield.sol/YieldOracle.dbg.json +4 -0
  71. package/src/assets/ethereum/hoodi/liqEth/Yield.sol/YieldOracle.json +1376 -0
  72. package/src/assets/ethereum/hoodi/liqEth/accounting.sol/AccountingV2.dbg.json +4 -0
  73. package/src/assets/ethereum/hoodi/liqEth/accounting.sol/AccountingV2.json +629 -0
  74. package/src/assets/ethereum/hoodi/liqEth/liqEth.sol/LiqEthTokenV2.dbg.json +4 -0
  75. package/src/assets/ethereum/hoodi/liqEth/liqEth.sol/LiqEthTokenV2.json +1323 -0
  76. package/src/assets/ethereum/hoodi/liqEth/stakingModule.sol/StakingModuleV2.dbg.json +4 -0
  77. package/src/assets/ethereum/hoodi/liqEth/stakingModule.sol/StakingModuleV2.json +1779 -0
  78. package/src/assets/ethereum/hoodi/liqEth/v1/DepositManager.sol/DepositManager.dbg.json +4 -0
  79. package/src/assets/ethereum/hoodi/liqEth/v1/DepositManager.sol/DepositManager.json +978 -0
  80. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IAccounting.dbg.json +4 -0
  81. package/src/assets/ethereum/{ABI/liqEth → hoodi/liqEth/v1}/LiqEthCommon.sol/IAccounting.json +25 -21
  82. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
  83. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositContract.json +39 -0
  84. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
  85. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositManager.json +64 -0
  86. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
  87. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
  88. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
  89. package/src/assets/ethereum/{ABI/liqEth → hoodi/liqEth/v1}/LiqEthCommon.sol/IRewardsERC20.json +37 -1
  90. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
  91. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.json +263 -0
  92. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
  93. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IStakingModule.json +344 -0
  94. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
  95. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.json +129 -0
  96. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
  97. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.json +66 -0
  98. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
  99. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.json +10 -0
  100. package/src/assets/ethereum/hoodi/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +4 -0
  101. package/src/assets/ethereum/{ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20Pausable.json → hoodi/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.json} +140 -78
  102. package/src/assets/ethereum/hoodi/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +4 -0
  103. package/src/assets/ethereum/hoodi/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json +937 -0
  104. package/src/assets/ethereum/hoodi/liqEth/v1/accounting.sol/Accounting.dbg.json +4 -0
  105. package/src/assets/ethereum/hoodi/liqEth/v1/accounting.sol/Accounting.json +548 -0
  106. package/src/assets/ethereum/hoodi/liqEth/v1/liqEth.sol/LiqEthToken.dbg.json +4 -0
  107. package/src/assets/ethereum/hoodi/liqEth/v1/liqEth.sol/LiqEthToken.json +1233 -0
  108. package/src/assets/ethereum/hoodi/liqEth/v1/stakingModule.sol/StakingModule.dbg.json +4 -0
  109. package/src/assets/ethereum/hoodi/liqEth/v1/stakingModule.sol/StakingModule.json +1772 -0
  110. package/src/assets/ethereum/hoodi/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +4 -0
  111. package/src/assets/ethereum/hoodi/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +973 -0
  112. package/src/assets/ethereum/hoodi/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +4 -0
  113. package/src/assets/ethereum/{ABI → hoodi}/liqEth/withdrawalVault.sol/Uint64BE.json +2 -2
  114. package/src/assets/ethereum/hoodi/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +4 -0
  115. package/src/assets/ethereum/hoodi/liqEth/withdrawalVault.sol/WithdrawalVault.json +441 -0
  116. package/src/assets/ethereum/hoodi/outpost/BAR.sol/BAR.dbg.json +4 -0
  117. package/src/assets/ethereum/hoodi/outpost/BAR.sol/BAR.json +1111 -0
  118. package/src/assets/ethereum/hoodi/outpost/Depositor.sol/Depositor.dbg.json +4 -0
  119. package/src/assets/ethereum/hoodi/outpost/Depositor.sol/Depositor.json +1696 -0
  120. package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +4 -0
  121. package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +122 -0
  122. package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +4 -0
  123. package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +274 -0
  124. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeDepositCodec.dbg.json +4 -0
  125. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeDepositCodec.json +10 -0
  126. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawCodec.dbg.json +4 -0
  127. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawCodec.json +10 -0
  128. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawConfirmCodec.dbg.json +4 -0
  129. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawConfirmCodec.json +10 -0
  130. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/InstaswapBridgeAttestationTypeLib.dbg.json +4 -0
  131. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/InstaswapBridgeAttestationTypeLib.json +10 -0
  132. package/src/assets/ethereum/hoodi/outpost/LiqEthBridge.sol/LiqEthBridge.dbg.json +4 -0
  133. package/src/assets/ethereum/hoodi/outpost/LiqEthBridge.sol/LiqEthBridge.json +1044 -0
  134. package/src/assets/ethereum/hoodi/outpost/OPP.sol/OPP.dbg.json +4 -0
  135. package/src/assets/ethereum/hoodi/outpost/OPP.sol/OPP.json +1055 -0
  136. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPP.dbg.json +4 -0
  137. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPP.json +81 -0
  138. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +4 -0
  139. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPEndpoint.json +29 -0
  140. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPInbound.dbg.json +4 -0
  141. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPInbound.json +330 -0
  142. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +4 -0
  143. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPReceiver.json +29 -0
  144. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPSender.dbg.json +4 -0
  145. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPSender.json +41 -0
  146. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/OPPCommon.dbg.json +4 -0
  147. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/OPPCommon.json +287 -0
  148. package/src/assets/ethereum/hoodi/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +4 -0
  149. package/src/assets/ethereum/hoodi/outpost/OPPEndpoint.sol/OPPEndpoint.json +294 -0
  150. package/src/assets/ethereum/hoodi/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +4 -0
  151. package/src/assets/ethereum/hoodi/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.json +415 -0
  152. package/src/assets/ethereum/hoodi/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +4 -0
  153. package/src/assets/ethereum/hoodi/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.json +399 -0
  154. package/src/assets/ethereum/hoodi/outpost/OPPErrors.sol/OPPErrors.dbg.json +4 -0
  155. package/src/assets/ethereum/hoodi/outpost/OPPErrors.sol/OPPErrors.json +245 -0
  156. package/src/assets/ethereum/hoodi/outpost/OPPInbound.sol/OPPInbound.dbg.json +4 -0
  157. package/src/assets/ethereum/hoodi/outpost/OPPInbound.sol/OPPInbound.json +1204 -0
  158. package/src/assets/ethereum/hoodi/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +4 -0
  159. package/src/assets/ethereum/hoodi/outpost/OPPReceiver.sol/OPPReceiver.json +312 -0
  160. package/src/assets/ethereum/hoodi/outpost/OPPSender.sol/OPPSender.dbg.json +4 -0
  161. package/src/assets/ethereum/hoodi/outpost/OPPSender.sol/OPPSender.json +324 -0
  162. package/src/assets/ethereum/hoodi/outpost/OperatorRegistry.sol/OperatorRegistry.dbg.json +4 -0
  163. package/src/assets/ethereum/hoodi/outpost/OperatorRegistry.sol/OperatorRegistry.json +1068 -0
  164. package/src/assets/ethereum/hoodi/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +4 -0
  165. package/src/assets/ethereum/hoodi/outpost/OutpostErrors.sol/OutpostErrors.json +211 -0
  166. package/src/assets/ethereum/hoodi/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +4 -0
  167. package/src/assets/ethereum/hoodi/outpost/OutpostManaged.sol/OutpostManaged.json +229 -0
  168. package/src/assets/ethereum/hoodi/outpost/OutpostManager.sol/OutpostManager.dbg.json +4 -0
  169. package/src/assets/ethereum/hoodi/outpost/OutpostManager.sol/OutpostManager.json +751 -0
  170. package/src/assets/ethereum/hoodi/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +4 -0
  171. package/src/assets/ethereum/hoodi/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json +1432 -0
  172. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +4 -0
  173. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostManager.json +130 -0
  174. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +4 -0
  175. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +29 -0
  176. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +4 -0
  177. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.json +141 -0
  178. package/src/assets/ethereum/hoodi/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +4 -0
  179. package/src/assets/ethereum/hoodi/outpost/OutpostOwnable.sol/OutpostOwnable.json +213 -0
  180. package/src/assets/ethereum/hoodi/outpost/OutpostReserve.sol/OutpostReserve.dbg.json +4 -0
  181. package/src/assets/ethereum/hoodi/outpost/OutpostReserve.sol/OutpostReserve.json +888 -0
  182. package/src/assets/ethereum/hoodi/outpost/Pool.sol/Pool.dbg.json +4 -0
  183. package/src/assets/ethereum/hoodi/outpost/Pool.sol/Pool.json +659 -0
  184. package/src/assets/ethereum/hoodi/outpost/Pretoken.sol/Pretoken.dbg.json +4 -0
  185. package/src/assets/ethereum/hoodi/outpost/Pretoken.sol/Pretoken.json +1393 -0
  186. package/src/assets/ethereum/hoodi/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +4 -0
  187. package/src/assets/ethereum/hoodi/outpost/ReceiptNFT.sol/ReceiptNFT.json +1738 -0
  188. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapConfirmCodec.dbg.json +4 -0
  189. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapConfirmCodec.json +10 -0
  190. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapFailedCodec.dbg.json +4 -0
  191. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapFailedCodec.json +10 -0
  192. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapRequestCodec.dbg.json +4 -0
  193. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapRequestCodec.json +10 -0
  194. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapSettlementCodec.dbg.json +4 -0
  195. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapSettlementCodec.json +10 -0
  196. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitConfirmCodec.dbg.json +4 -0
  197. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitConfirmCodec.json +10 -0
  198. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitFailedCodec.dbg.json +4 -0
  199. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitFailedCodec.json +10 -0
  200. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitRequestCodec.dbg.json +4 -0
  201. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitRequestCodec.json +10 -0
  202. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalStakeDeltaCodec.dbg.json +4 -0
  203. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalStakeDeltaCodec.json +10 -0
  204. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAssetCodec.dbg.json +4 -0
  205. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAssetCodec.json +10 -0
  206. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestationTypeLib.dbg.json +4 -0
  207. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestationTypeLib.json +10 -0
  208. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestations.dbg.json +4 -0
  209. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestations.json +1437 -0
  210. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/YieldDepositCodec.dbg.json +4 -0
  211. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/YieldDepositCodec.json +10 -0
  212. package/src/assets/ethereum/hoodi/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +4 -0
  213. package/src/assets/ethereum/{ABI/liqEth/LiqEthCommon.sol/ILiqEthMint.json → hoodi/outpost/interfaces/IPretoken.sol/IPretoken.json} +6 -12
  214. package/src/assets/ethereum/hoodi/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +4 -0
  215. package/src/assets/ethereum/{ABI/liqEth/LiqEthCommon.sol/ILiqEthBurn.json → hoodi/outpost/interfaces/IWarrant.sol/IWarrant.json} +9 -4
  216. package/src/assets/ethereum/hoodi/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +4 -0
  217. package/src/assets/ethereum/hoodi/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +858 -0
  218. package/src/assets/ethereum/hoodi/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +4 -0
  219. package/src/assets/ethereum/hoodi/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.json +30 -0
  220. package/src/assets/ethereum/hoodi/token/ERC1155Token.sol/ERC1155Token.dbg.json +4 -0
  221. package/src/assets/ethereum/hoodi/token/ERC1155Token.sol/ERC1155Token.json +472 -0
  222. package/src/assets/ethereum/hoodi/token/ERC20Token.sol/ERC20Token.dbg.json +4 -0
  223. package/src/assets/ethereum/hoodi/token/ERC20Token.sol/ERC20Token.json +330 -0
  224. package/src/assets/ethereum/hoodi/token/ERC721Token.sol/ERC721Token.dbg.json +4 -0
  225. package/src/assets/ethereum/hoodi/token/ERC721Token.sol/ERC721Token.json +449 -0
  226. package/src/assets/ethereum/hoodi/token/Eman1155.sol/Eman1155.dbg.json +4 -0
  227. package/src/assets/ethereum/hoodi/token/Eman1155.sol/Eman1155.json +560 -0
  228. package/src/assets/ethereum/hoodi/token/Eman20.sol/Eman20.dbg.json +4 -0
  229. package/src/assets/ethereum/hoodi/token/Eman20.sol/Eman20.json +460 -0
  230. package/src/assets/ethereum/hoodi/token/Eman721.sol/Eman721.dbg.json +4 -0
  231. package/src/assets/ethereum/hoodi/token/Eman721.sol/Eman721.json +624 -0
  232. package/src/assets/ethereum/mainnet/common/Base58.sol/Base58.dbg.json +4 -0
  233. package/src/assets/ethereum/mainnet/common/Base58.sol/Base58.json +164 -0
  234. package/src/assets/ethereum/mainnet/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.dbg.json +4 -0
  235. package/src/assets/ethereum/mainnet/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.json +76 -0
  236. package/src/assets/ethereum/mainnet/common/RestrictedCallers.sol/RestrictedCallers.dbg.json +4 -0
  237. package/src/assets/ethereum/mainnet/common/RestrictedCallers.sol/RestrictedCallers.json +10 -0
  238. package/src/assets/ethereum/mainnet/common/iodata.sol/iodata.dbg.json +4 -0
  239. package/src/assets/ethereum/mainnet/common/iodata.sol/iodata.json +618 -0
  240. package/src/assets/ethereum/mainnet/common/iodata_util.sol/iodata_util.dbg.json +4 -0
  241. package/src/assets/ethereum/mainnet/common/iodata_util.sol/iodata_util.json +40 -0
  242. package/src/assets/ethereum/mainnet/common/sysio_data.sol/sysio_data.dbg.json +4 -0
  243. package/src/assets/ethereum/mainnet/common/sysio_data.sol/sysio_data.json +10 -0
  244. package/src/assets/ethereum/mainnet/common/sysio_errors.sol/sysio_errors.dbg.json +4 -0
  245. package/src/assets/ethereum/mainnet/common/sysio_errors.sol/sysio_errors.json +10 -0
  246. package/src/assets/ethereum/mainnet/common/sysio_merkle.sol/sysio_merkle.dbg.json +4 -0
  247. package/src/assets/ethereum/mainnet/common/sysio_merkle.sol/sysio_merkle.json +233 -0
  248. package/src/assets/ethereum/mainnet/common/sysio_name.sol/sysio_name.dbg.json +4 -0
  249. package/src/assets/ethereum/mainnet/common/sysio_name.sol/sysio_name.json +49 -0
  250. package/src/assets/ethereum/mainnet/common/sysio_pubkey.sol/sysio_pubkey.dbg.json +4 -0
  251. package/src/assets/ethereum/mainnet/common/sysio_pubkey.sol/sysio_pubkey.json +64 -0
  252. package/src/assets/ethereum/mainnet/common/sysio_read.sol/sysio_read.dbg.json +4 -0
  253. package/src/assets/ethereum/mainnet/common/sysio_read.sol/sysio_read.json +1458 -0
  254. package/src/assets/ethereum/mainnet/common/sysio_tester.sol/SysioTester.dbg.json +4 -0
  255. package/src/assets/ethereum/mainnet/common/sysio_tester.sol/SysioTester.json +1532 -0
  256. package/src/assets/ethereum/mainnet/common/sysio_verify.sol/sysio_verify.dbg.json +4 -0
  257. package/src/assets/ethereum/mainnet/common/sysio_verify.sol/sysio_verify.json +1525 -0
  258. package/src/assets/ethereum/mainnet/common/sysio_write.sol/sysio_write.dbg.json +4 -0
  259. package/src/assets/ethereum/mainnet/common/sysio_write.sol/sysio_write.json +1076 -0
  260. package/src/assets/ethereum/mainnet/liqEth/BeaconState.sol/BeaconState.dbg.json +4 -0
  261. package/src/assets/ethereum/mainnet/liqEth/BeaconState.sol/BeaconState.json +807 -0
  262. package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/DepositManagerV2.dbg.json +4 -0
  263. package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/DepositManagerV2.json +1004 -0
  264. package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/IStakingModuleBondLocker.dbg.json +4 -0
  265. package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/IStakingModuleBondLocker.json +29 -0
  266. package/src/assets/ethereum/mainnet/liqEth/KeyBondManager.sol/KeyBondManager.dbg.json +4 -0
  267. package/src/assets/ethereum/mainnet/liqEth/KeyBondManager.sol/KeyBondManager.json +897 -0
  268. package/src/assets/ethereum/mainnet/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +4 -0
  269. package/src/assets/ethereum/mainnet/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +1289 -0
  270. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
  271. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositContract.json +39 -0
  272. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
  273. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositManager.json +64 -0
  274. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IKeyBondManager.dbg.json +4 -0
  275. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IKeyBondManager.json +189 -0
  276. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
  277. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
  278. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
  279. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20.json +319 -0
  280. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
  281. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +333 -0
  282. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
  283. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IStakingModule.json +279 -0
  284. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
  285. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +129 -0
  286. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
  287. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +66 -0
  288. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
  289. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/LiqEthCommon.json +10 -0
  290. package/src/assets/ethereum/mainnet/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.dbg.json +4 -0
  291. package/src/assets/ethereum/mainnet/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.json +236 -0
  292. package/src/assets/ethereum/mainnet/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +4 -0
  293. package/src/assets/ethereum/mainnet/liqEth/LiqEthManaged.sol/LiqEthManaged.json +229 -0
  294. package/src/assets/ethereum/mainnet/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.dbg.json +4 -0
  295. package/src/assets/ethereum/mainnet/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.json +957 -0
  296. package/src/assets/ethereum/mainnet/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.dbg.json +4 -0
  297. package/src/assets/ethereum/mainnet/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.json +1020 -0
  298. package/src/assets/ethereum/mainnet/liqEth/StakingLib.sol/StakingLib.dbg.json +4 -0
  299. package/src/assets/ethereum/mainnet/liqEth/StakingLib.sol/StakingLib.json +89 -0
  300. package/src/assets/ethereum/mainnet/liqEth/Yield.sol/YieldOracle.dbg.json +4 -0
  301. package/src/assets/ethereum/mainnet/liqEth/Yield.sol/YieldOracle.json +1376 -0
  302. package/src/assets/ethereum/mainnet/liqEth/liqEth.sol/LiqEthTokenV2.dbg.json +4 -0
  303. package/src/assets/ethereum/mainnet/liqEth/liqEth.sol/LiqEthTokenV2.json +1323 -0
  304. package/src/assets/ethereum/mainnet/liqEth/stakingModule.sol/StakingModuleV2.dbg.json +4 -0
  305. package/src/assets/ethereum/mainnet/liqEth/stakingModule.sol/StakingModuleV2.json +1896 -0
  306. package/src/assets/ethereum/mainnet/liqEth/v1/DepositManager.sol/DepositManager.dbg.json +4 -0
  307. package/src/assets/ethereum/mainnet/liqEth/v1/DepositManager.sol/DepositManager.json +978 -0
  308. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IAccounting.dbg.json +4 -0
  309. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IAccounting.json +176 -0
  310. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
  311. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositContract.json +39 -0
  312. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
  313. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositManager.json +64 -0
  314. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
  315. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
  316. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
  317. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20.json +249 -0
  318. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
  319. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.json +263 -0
  320. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
  321. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IStakingModule.json +344 -0
  322. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
  323. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.json +129 -0
  324. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
  325. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.json +66 -0
  326. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
  327. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.json +10 -0
  328. package/src/assets/ethereum/mainnet/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +4 -0
  329. package/src/assets/ethereum/{ABI/liqEth/RewardsERC20.sol/RewardsERC20.json → mainnet/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.json} +159 -34
  330. package/src/assets/ethereum/mainnet/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +4 -0
  331. package/src/assets/ethereum/mainnet/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json +937 -0
  332. package/src/assets/ethereum/mainnet/liqEth/v1/accounting.sol/Accounting.dbg.json +4 -0
  333. package/src/assets/ethereum/mainnet/liqEth/v1/accounting.sol/Accounting.json +542 -0
  334. package/src/assets/ethereum/mainnet/liqEth/v1/liqEth.sol/LiqEthToken.dbg.json +4 -0
  335. package/src/assets/ethereum/mainnet/liqEth/v1/liqEth.sol/LiqEthToken.json +1233 -0
  336. package/src/assets/ethereum/mainnet/liqEth/v1/stakingModule.sol/StakingModule.dbg.json +4 -0
  337. package/src/assets/ethereum/mainnet/liqEth/v1/stakingModule.sol/StakingModule.json +1772 -0
  338. package/src/assets/ethereum/mainnet/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +4 -0
  339. package/src/assets/ethereum/mainnet/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +973 -0
  340. package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +4 -0
  341. package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/Uint64BE.json +10 -0
  342. package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +4 -0
  343. package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/WithdrawalVault.json +441 -0
  344. package/src/assets/ethereum/mainnet/outpost/BAR.sol/BARV2.dbg.json +4 -0
  345. package/src/assets/ethereum/mainnet/outpost/BAR.sol/BARV2.json +1915 -0
  346. package/src/assets/ethereum/mainnet/outpost/Depositor.sol/DepositorV2.dbg.json +4 -0
  347. package/src/assets/ethereum/mainnet/outpost/Depositor.sol/DepositorV2.json +1845 -0
  348. package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +4 -0
  349. package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +122 -0
  350. package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +4 -0
  351. package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +551 -0
  352. package/src/assets/ethereum/mainnet/outpost/OPP.sol/OPP.dbg.json +4 -0
  353. package/src/assets/ethereum/mainnet/outpost/OPP.sol/OPP.json +948 -0
  354. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPP.dbg.json +4 -0
  355. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPP.json +88 -0
  356. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +4 -0
  357. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPEndpoint.json +29 -0
  358. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPInbound.dbg.json +4 -0
  359. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPInbound.json +194 -0
  360. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +4 -0
  361. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPReceiver.json +29 -0
  362. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPSender.dbg.json +4 -0
  363. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPSender.json +36 -0
  364. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/OPPCommon.dbg.json +4 -0
  365. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/OPPCommon.json +199 -0
  366. package/src/assets/ethereum/mainnet/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +4 -0
  367. package/src/assets/ethereum/mainnet/outpost/OPPEndpoint.sol/OPPEndpoint.json +273 -0
  368. package/src/assets/ethereum/mainnet/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +4 -0
  369. package/src/assets/ethereum/mainnet/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.json +394 -0
  370. package/src/assets/ethereum/mainnet/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +4 -0
  371. package/src/assets/ethereum/mainnet/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.json +378 -0
  372. package/src/assets/ethereum/mainnet/outpost/OPPErrors.sol/OPPErrors.dbg.json +4 -0
  373. package/src/assets/ethereum/mainnet/outpost/OPPErrors.sol/OPPErrors.json +224 -0
  374. package/src/assets/ethereum/mainnet/outpost/OPPInbound.sol/OPPInbound.dbg.json +4 -0
  375. package/src/assets/ethereum/mainnet/outpost/OPPInbound.sol/OPPInbound.json +1010 -0
  376. package/src/assets/ethereum/mainnet/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +4 -0
  377. package/src/assets/ethereum/mainnet/outpost/OPPReceiver.sol/OPPReceiver.json +291 -0
  378. package/src/assets/ethereum/mainnet/outpost/OPPSender.sol/OPPSender.dbg.json +4 -0
  379. package/src/assets/ethereum/mainnet/outpost/OPPSender.sol/OPPSender.json +298 -0
  380. package/src/assets/ethereum/mainnet/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +4 -0
  381. package/src/assets/ethereum/mainnet/outpost/OutpostErrors.sol/OutpostErrors.json +488 -0
  382. package/src/assets/ethereum/mainnet/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +4 -0
  383. package/src/assets/ethereum/mainnet/outpost/OutpostManaged.sol/OutpostManaged.json +229 -0
  384. package/src/assets/ethereum/mainnet/outpost/OutpostManager.sol/OutpostManagerV2.dbg.json +4 -0
  385. package/src/assets/ethereum/mainnet/outpost/OutpostManager.sol/OutpostManagerV2.json +737 -0
  386. package/src/assets/ethereum/mainnet/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +4 -0
  387. package/src/assets/ethereum/mainnet/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json +1432 -0
  388. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +4 -0
  389. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostManager.json +130 -0
  390. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +4 -0
  391. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +29 -0
  392. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +4 -0
  393. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.json +141 -0
  394. package/src/assets/ethereum/mainnet/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +4 -0
  395. package/src/assets/ethereum/mainnet/outpost/OutpostOwnable.sol/OutpostOwnable.json +213 -0
  396. package/src/assets/ethereum/mainnet/outpost/Pool.sol/PoolV2.dbg.json +4 -0
  397. package/src/assets/ethereum/mainnet/outpost/Pool.sol/PoolV2.json +943 -0
  398. package/src/assets/ethereum/mainnet/outpost/Pretoken.sol/PretokenV2.dbg.json +4 -0
  399. package/src/assets/ethereum/mainnet/outpost/Pretoken.sol/PretokenV2.json +1703 -0
  400. package/src/assets/ethereum/mainnet/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +4 -0
  401. package/src/assets/ethereum/mainnet/outpost/ReceiptNFT.sol/ReceiptNFT.json +2015 -0
  402. package/src/assets/ethereum/mainnet/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +4 -0
  403. package/src/assets/ethereum/mainnet/outpost/interfaces/IPretoken.sol/IPretoken.json +29 -0
  404. package/src/assets/ethereum/mainnet/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +4 -0
  405. package/src/assets/ethereum/mainnet/outpost/interfaces/IWarrant.sol/IWarrant.json +29 -0
  406. package/src/assets/ethereum/mainnet/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +4 -0
  407. package/src/assets/ethereum/mainnet/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +858 -0
  408. package/src/assets/ethereum/mainnet/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +4 -0
  409. package/src/assets/ethereum/mainnet/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.json +30 -0
  410. package/src/assets/ethereum/mainnet/outpost/v1/BAR.sol/BAR.dbg.json +4 -0
  411. package/src/assets/ethereum/mainnet/outpost/v1/BAR.sol/BAR.json +1871 -0
  412. package/src/assets/ethereum/mainnet/outpost/v1/Depositor.sol/Depositor.dbg.json +4 -0
  413. package/src/assets/ethereum/mainnet/outpost/v1/Depositor.sol/Depositor.json +1653 -0
  414. package/src/assets/ethereum/mainnet/outpost/v1/OutpostManager.sol/OutpostManager.dbg.json +4 -0
  415. package/src/assets/ethereum/mainnet/outpost/v1/OutpostManager.sol/OutpostManager.json +730 -0
  416. package/src/assets/ethereum/mainnet/outpost/v1/Pool.sol/Pool.dbg.json +4 -0
  417. package/src/assets/ethereum/mainnet/outpost/v1/Pool.sol/Pool.json +936 -0
  418. package/src/assets/ethereum/mainnet/outpost/v1/Pretoken.sol/Pretoken.dbg.json +4 -0
  419. package/src/assets/ethereum/mainnet/outpost/v1/Pretoken.sol/Pretoken.json +1665 -0
  420. package/src/assets/ethereum/mainnet/token/ERC1155Token.sol/ERC1155Token.dbg.json +4 -0
  421. package/src/assets/ethereum/mainnet/token/ERC1155Token.sol/ERC1155Token.json +472 -0
  422. package/src/assets/ethereum/mainnet/token/ERC20Token.sol/ERC20Token.dbg.json +4 -0
  423. package/src/assets/ethereum/mainnet/token/ERC20Token.sol/ERC20Token.json +330 -0
  424. package/src/assets/ethereum/mainnet/token/ERC721Token.sol/ERC721Token.dbg.json +4 -0
  425. package/src/assets/ethereum/mainnet/token/ERC721Token.sol/ERC721Token.json +449 -0
  426. package/src/assets/solana/devnet/idl/liqsol_core.json +8566 -0
  427. package/src/assets/solana/{idl → devnet/idl}/liqsol_token.json +35 -1
  428. package/src/assets/solana/devnet/idl/transfer_hook.json +490 -0
  429. package/src/assets/solana/devnet/idl/validator_leaderboard.json +735 -0
  430. package/src/assets/solana/devnet/types/liqsol_core.ts +8572 -0
  431. package/src/assets/solana/{types → devnet/types}/liqsol_token.ts +35 -1
  432. package/src/assets/solana/devnet/types/transfer_hook.ts +496 -0
  433. package/src/assets/solana/devnet/types/validator_leaderboard.ts +741 -0
  434. package/src/assets/solana/mainnet/idl/liqsol_core.json +6678 -0
  435. package/src/assets/solana/mainnet/idl/liqsol_token.json +217 -0
  436. package/src/assets/solana/mainnet/idl/transfer_hook.json +479 -0
  437. package/src/assets/solana/{idl → mainnet/idl}/validator_leaderboard.json +4 -4
  438. package/src/assets/solana/mainnet/types/liqsol_core.ts +6684 -0
  439. package/src/assets/solana/mainnet/types/liqsol_token.ts +223 -0
  440. package/src/assets/solana/mainnet/types/transfer_hook.ts +485 -0
  441. package/src/assets/solana/{types → mainnet/types}/validator_leaderboard.ts +4 -4
  442. package/src/assets/solana/realdevnet/idl/liqsol_core.json +7112 -0
  443. package/src/assets/solana/realdevnet/idl/liqsol_token.json +217 -0
  444. package/src/assets/solana/realdevnet/idl/transfer_hook.json +479 -0
  445. package/src/assets/solana/realdevnet/idl/validator_leaderboard.json +735 -0
  446. package/src/assets/solana/realdevnet/types/liqsol_core.ts +7118 -0
  447. package/src/assets/solana/realdevnet/types/liqsol_token.ts +223 -0
  448. package/src/assets/solana/realdevnet/types/transfer_hook.ts +485 -0
  449. package/src/assets/solana/realdevnet/types/validator_leaderboard.ts +741 -0
  450. package/src/index.ts +5 -3
  451. package/src/networks/ethereum/clients/convert.client.ts +221 -0
  452. package/src/networks/ethereum/clients/opp.client.ts +389 -0
  453. package/src/networks/ethereum/clients/pretoken.client.ts +165 -0
  454. package/src/networks/ethereum/clients/receipt.client.ts +199 -0
  455. package/src/networks/ethereum/clients/stake.client.ts +203 -0
  456. package/src/networks/ethereum/clients/validator.client.ts +61 -0
  457. package/src/networks/ethereum/contract.ts +424 -109
  458. package/src/networks/ethereum/ethereum.ts +548 -104
  459. package/src/networks/ethereum/types.ts +125 -17
  460. package/src/networks/ethereum/utils.ts +340 -0
  461. package/src/networks/solana/clients/convert.client.ts +341 -0
  462. package/src/networks/solana/clients/distribution.client.ts +266 -262
  463. package/src/networks/solana/clients/leaderboard.client.ts +68 -26
  464. package/src/networks/solana/clients/outpost.client.ts +342 -0
  465. package/src/networks/solana/clients/token.client.ts +214 -0
  466. package/src/networks/solana/constants.ts +100 -181
  467. package/src/networks/solana/program.ts +432 -28
  468. package/src/networks/solana/solana.ts +1137 -149
  469. package/src/networks/solana/types.ts +743 -33
  470. package/src/networks/solana/utils.ts +368 -304
  471. package/src/{staker/staker.ts → staker.ts} +26 -5
  472. package/src/types.ts +364 -0
  473. package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.dbg.json +0 -4
  474. package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json +0 -1153
  475. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +0 -4
  476. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +0 -4
  477. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +0 -4
  478. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthBurn.dbg.json +0 -4
  479. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthMint.dbg.json +0 -4
  480. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +0 -4
  481. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +0 -4
  482. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.json +0 -138
  483. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +0 -4
  484. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +0 -4
  485. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +0 -4
  486. package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.dbg.json +0 -4
  487. package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20Pausable.dbg.json +0 -4
  488. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.dbg.json +0 -4
  489. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.json +0 -10
  490. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.dbg.json +0 -4
  491. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.json +0 -10
  492. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.dbg.json +0 -4
  493. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json +0 -225
  494. package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.dbg.json +0 -4
  495. package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.json +0 -10
  496. package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.dbg.json +0 -4
  497. package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.json +0 -10
  498. package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.dbg.json +0 -4
  499. package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json +0 -813
  500. package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.dbg.json +0 -4
  501. package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json +0 -651
  502. package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.dbg.json +0 -4
  503. package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json +0 -1110
  504. package/src/assets/ethereum/ABI/liqEth/liqEthBurn.sol/LiqEthBurn.dbg.json +0 -4
  505. package/src/assets/ethereum/ABI/liqEth/liqEthBurn.sol/LiqEthBurn.json +0 -391
  506. package/src/assets/ethereum/ABI/liqEth/liqEthMint.sol/LiqEthMint.dbg.json +0 -4
  507. package/src/assets/ethereum/ABI/liqEth/liqEthMint.sol/LiqEthMint.json +0 -402
  508. package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.dbg.json +0 -4
  509. package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json +0 -1225
  510. package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +0 -4
  511. package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +0 -927
  512. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +0 -4
  513. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +0 -4
  514. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.json +0 -447
  515. package/src/assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.dbg.json +0 -4
  516. package/src/assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.json +0 -472
  517. package/src/assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.dbg.json +0 -4
  518. package/src/assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.json +0 -330
  519. package/src/assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.dbg.json +0 -4
  520. package/src/assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.json +0 -449
  521. package/src/assets/solana/idl/liqsol_core.json +0 -4239
  522. package/src/assets/solana/types/liqsol_core.ts +0 -4245
  523. package/src/networks/solana/clients/deposit.client.ts +0 -131
  524. package/src/staker/types.ts +0 -49
  525. /package/src/assets/ethereum/{ABI → hoodi}/liqEth/LiqEthCommon.sol/IDepositContract.json +0 -0
  526. /package/src/assets/ethereum/{ABI → hoodi}/liqEth/LiqEthCommon.sol/IDepositManager.json +0 -0
@@ -1,259 +1,1247 @@
1
1
  import {
2
+ AddressLookupTableAccount,
2
3
  Commitment,
4
+ ComputeBudgetProgram,
3
5
  Connection,
4
6
  ConnectionConfig,
7
+ PerfSample,
8
+ SendTransactionError,
5
9
  PublicKey as SolPubKey,
10
+ SystemProgram,
6
11
  Transaction,
12
+ TransactionInstruction,
13
+ TransactionMessage,
7
14
  TransactionSignature,
15
+ VersionedTransaction,
8
16
  } from '@solana/web3.js';
9
- import { AnchorProvider } from '@coral-xyz/anchor';
17
+ import { AnchorProvider, BN } from '@coral-xyz/anchor';
10
18
  import { BaseSignerWalletAdapter } from '@solana/wallet-adapter-base';
11
- import { getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID } from '@solana/spl-token';
19
+ import {
20
+ ASSOCIATED_TOKEN_PROGRAM_ID,
21
+ createAssociatedTokenAccountInstruction,
22
+ getAssociatedTokenAddressSync,
23
+ TOKEN_2022_PROGRAM_ID,
24
+ } from '@solana/spl-token';
25
+
26
+ import * as multisig from "@sqds/multisig";
27
+
28
+ import {
29
+ Base58,
30
+ ChainID,
31
+ ExternalNetwork,
32
+ KeyType,
33
+ PublicKey,
34
+ SolChainID,
35
+ } from '@wireio/core';
12
36
 
13
- import { ChainID, ExternalNetwork, KeyType, PublicKey } from '@wireio/core';
14
- import { IStakingClient, Portfolio, StakerConfig } from '../../staker/types';
37
+ import {
38
+ IStakingClient,
39
+ Portfolio,
40
+ SquadsXConfig,
41
+ StakerConfig,
42
+ TrancheSnapshot,
43
+ } from '../../types';
15
44
 
16
- import { DepositClient } from './clients/deposit.client';
45
+ import { ConvertClient } from './clients/convert.client';
17
46
  import { DistributionClient } from './clients/distribution.client';
47
+ import { LeaderboardClient } from './clients/leaderboard.client';
48
+ import { OutpostClient } from './clients/outpost.client';
49
+ import { TokenClient } from './clients/token.client';
50
+
18
51
  import {
19
- deriveLiqsolMintPda,
20
- deriveReservePoolPda,
21
- deriveVaultPda,
52
+ DEFAULT_AVERAGE_PAY_RATE,
53
+ INDEX_SCALE,
54
+ PAY_RATE_SCALE_FACTOR,
22
55
  } from './constants';
23
- import { SolanaTransaction, UserRecord } from './types';
24
- import { LeaderboardClient } from './clients/leaderboard.client';
56
+
57
+ import { buildSolanaTrancheSnapshot, ceilDiv } from './utils';
58
+ import { GlobalConfig, PayRateEntry, SolanaTransaction } from './types';
59
+ import { WithdrawReceipt } from '../../types';
60
+ import { SolanaProgramService } from './program';
61
+ import bs58 from 'bs58';
25
62
 
26
63
  const commitment: Commitment = 'confirmed';
27
64
 
65
+ export const SCALE = new BN('1000000000000');
66
+
67
+ /**
68
+ * Solana implementation of IStakingClient.
69
+ *
70
+ * Responsibilities:
71
+ * - liqSOL deposit (SOL -> liqSOL)
72
+ * - withdraw requests (liqSOL -> NFT receipt / encumbered SOL)
73
+ * - Pretoken (WIRE) buys via liqSOL
74
+ * - Unified portfolio + tranche snapshot + balance correction (later)
75
+ *
76
+ * This composes lower-level clients; it does not know about UI.
77
+ */
28
78
  export class SolanaStakingClient implements IStakingClient {
29
- public pubKey: PublicKey;
79
+ public pubKey?: PublicKey; // Wire ED key (optional → read-only)
30
80
  public connection: Connection;
31
81
  public anchor: AnchorProvider;
32
82
 
33
- private depositClient: DepositClient;
34
- private distributionClient: DistributionClient;
35
- private leaderboardClient: LeaderboardClient;
83
+ public convertClient: ConvertClient;
84
+ public distributionClient: DistributionClient;
85
+ public leaderboardClient: LeaderboardClient;
86
+ public outpostClient: OutpostClient;
87
+ public tokenClient: TokenClient;
88
+ public program: SolanaProgramService
36
89
 
37
- get solPubKey(): SolPubKey { return new SolPubKey(this.pubKey.data.array); }
38
- get network() { return this.config.network; }
90
+ private smartAccount?: SolPubKey; // PDA (off-curve)
91
+ private signer?: SolPubKey; // on-curve signer
92
+
93
+ get solPubKey(): SolPubKey {
94
+ if (!this.pubKey) throw new Error('pubKey is undefined');
95
+ return new SolPubKey(this.pubKey.data.array);
96
+ }
97
+
98
+ get network(): ExternalNetwork {
99
+ return this.config.network;
100
+ }
101
+
102
+ get feePayer(): SolPubKey {
103
+ if (this.signer) return this.signer;
104
+ // fallback for normal wallets
105
+ if (this.anchor.wallet.publicKey) return this.anchor.wallet.publicKey;
106
+ throw new Error('No signing authority available');
107
+ }
108
+
109
+ get squadsX(): SquadsXConfig | null {
110
+ const config = this.config.extras?.squadsX;
111
+ return config ?? null;
112
+ }
39
113
 
40
114
  constructor(private config: StakerConfig) {
41
- const adapter = config.provider as BaseSignerWalletAdapter;
42
- if (!adapter.publicKey) {
43
- throw new Error('Solana wallet adapter not connected');
44
- }
115
+ const adapter = config.provider as BaseSignerWalletAdapter | undefined;
116
+
45
117
  if (!config.network.rpcUrls.length) {
46
118
  throw new Error('No RPC URLs provided');
47
119
  }
48
120
 
49
- const publicKey = adapter.publicKey;
50
- const wirePub = new PublicKey(KeyType.ED, publicKey.toBytes());
51
- if (!wirePub.equals(config.pubKey)) {
52
- throw new Error("Passed-in pubKey doesn't match adapter.publicKey");
121
+ // -------------------------------------------------------------
122
+ // Resolve Solana wallet pubkey (or dummy in read-only mode)
123
+ // -------------------------------------------------------------
124
+ let solWalletPubkey: SolPubKey;
125
+ if (adapter?.publicKey) {
126
+ solWalletPubkey = adapter.publicKey;
127
+ } else {
128
+ // Zeroed pubkey when no wallet (read-only usage)
129
+ solWalletPubkey = new SolPubKey(new Uint8Array(32));
53
130
  }
54
131
 
132
+ // -------------------------------------------------------------
133
+ // Resolve Wire pubKey
134
+ // -------------------------------------------------------------
135
+ if (config.pubKey) {
136
+ const wirePub = config.pubKey;
137
+
138
+ if (adapter?.publicKey) {
139
+ const derived = new PublicKey(
140
+ KeyType.ED,
141
+ adapter.publicKey.toBytes(),
142
+ );
143
+ if (!derived.equals(wirePub)) {
144
+ throw new Error(
145
+ "Passed-in pubKey doesn't match adapter.publicKey",
146
+ );
147
+ }
148
+ }
149
+
150
+ this.pubKey = wirePub;
151
+ } else if (adapter?.publicKey) {
152
+ // Derive Wire pubKey from adapter when not explicitly passed
153
+ this.pubKey = new PublicKey(
154
+ KeyType.ED,
155
+ adapter.publicKey.toBytes(),
156
+ );
157
+ }
158
+
159
+ // -------------------------------------------------------------
160
+ // Connection + AnchorProvider
161
+ // -------------------------------------------------------------
55
162
  const opts: ConnectionConfig = { commitment };
56
- if (config.network.rpcUrls.length > 1 && config.network.rpcUrls[1].startsWith('ws')) {
163
+ if (
164
+ config.network.rpcUrls.length > 1 &&
165
+ config.network.rpcUrls[1].startsWith('ws')
166
+ ) {
57
167
  opts.wsEndpoint = config.network.rpcUrls[1];
58
168
  }
59
169
 
60
- this.pubKey = wirePub;
170
+ const anchorWallet = adapter
171
+ ? {
172
+ publicKey: solWalletPubkey,
173
+ async signTransaction<T extends SolanaTransaction>(
174
+ tx: T,
175
+ ): Promise<T> {
176
+ return adapter.signTransaction(tx);
177
+ },
178
+ async signAllTransactions<T extends SolanaTransaction>(
179
+ txs: T[],
180
+ ): Promise<T[]> {
181
+ if (adapter.signAllTransactions) {
182
+ return adapter.signAllTransactions(txs);
183
+ }
184
+ return Promise.all(
185
+ txs.map((tx) => adapter.signTransaction(tx)),
186
+ );
187
+ },
188
+ }
189
+ : {
190
+ publicKey: solWalletPubkey,
191
+ async signTransaction<T extends SolanaTransaction>(
192
+ _tx: T,
193
+ ): Promise<T> {
194
+ throw new Error(
195
+ 'Wallet not connected: signTransaction not available',
196
+ );
197
+ },
198
+ async signAllTransactions<T extends SolanaTransaction>(
199
+ _txs: T[],
200
+ ): Promise<T[]> {
201
+ throw new Error(
202
+ 'Wallet not connected: signAllTransactions not available',
203
+ );
204
+ },
205
+ };
206
+
61
207
  this.connection = new Connection(config.network.rpcUrls[0], opts);
208
+ this.anchor = new AnchorProvider(this.connection, anchorWallet, {
209
+ commitment,
210
+ });
62
211
 
63
- const anchorWallet = {
64
- publicKey,
65
- async signTransaction<T extends SolanaTransaction>(tx: T): Promise<T> {
66
- return adapter.signTransaction(tx);
67
- },
68
- async signAllTransactions<T extends SolanaTransaction>(txs: T[]): Promise<T[]> {
69
- return Promise.all(txs.map((tx) => adapter.signTransaction(tx)));
70
- },
71
- };
212
+ this.program = new SolanaProgramService(this.anchor, config.network.chainId as SolChainID);
72
213
 
73
- this.anchor = new AnchorProvider(this.connection, anchorWallet, { commitment });
214
+ this.convertClient = new ConvertClient(this.anchor, this.program);
215
+ this.distributionClient = new DistributionClient(this.anchor, this.program);
216
+ this.leaderboardClient = new LeaderboardClient(this.anchor, this.program);
217
+ this.outpostClient = new OutpostClient(this.anchor, this.program);
218
+ this.tokenClient = new TokenClient(this.anchor, this.program);
219
+ }
220
+
221
+ // ---------------------------------------------------------------------
222
+ // IStakingClient core methods
223
+ // ---------------------------------------------------------------------
224
+
225
+ /**
226
+ * Deposit native SOL into liqSOL (liqsol_core::deposit).
227
+ * Handles tx build, sign, send, and confirmation.
228
+ */
229
+ async deposit(amountLamports: bigint): Promise<string> {
230
+ this.ensureUser();
231
+ if (amountLamports <= BigInt(0))
232
+ throw new Error('Deposit amount must be greater than zero.');
74
233
 
75
- this.depositClient = new DepositClient(this.anchor);
76
- this.distributionClient = new DistributionClient(this.anchor);
77
- this.leaderboardClient = new LeaderboardClient(this.anchor);
234
+ try {
235
+ const ix = await this.convertClient.buildDepositTx(amountLamports, this.squadsVaultPDA)
236
+ return !!this.squadsX
237
+ ? await this.sendSquadsIxs(ix)
238
+ : await this.buildAndSendIx(ix)
239
+
240
+ } catch (err) {
241
+ console.log(`Failed to deposit Solana: ${err}`);
242
+ throw err;
243
+ }
244
+ }
245
+
246
+ /**
247
+ * Request a withdraw from liqSOL to SOL (liqsol_core::requestWithdraw).
248
+ *
249
+ * This:
250
+ * - burns liqSOL from the user ATA
251
+ * - mints an NFT withdrawal receipt
252
+ * - increases totalEncumberedFunds in global state
253
+ *
254
+ * Actual SOL payout happens later via the operator-side flow.
255
+ */
256
+ async withdraw(amountLamports: bigint): Promise<string> {
257
+ this.ensureUser();
258
+ if (amountLamports <= BigInt(0))
259
+ throw new Error('Withdraw amount must be greater than zero.');
260
+
261
+ try {
262
+ const ix = await this.convertClient.buildWithdrawTx(amountLamports, this.squadsVaultPDA)
263
+ return !!this.squadsX
264
+ ? await this.sendSquadsIxs(ix)
265
+ : await this.buildAndSendIx(ix)
266
+
267
+ } catch (err) {
268
+ console.log(`Failed to withdraw Solana: ${err}`);
269
+ throw err;
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Enumerate withdrawal receipt NFTs held by the user (queued/ready/claimed).
275
+ * Mirrors the ETH getPendingWithdraws helper for UI parity.
276
+ */
277
+ async getPendingWithdraws(address?: string): Promise<WithdrawReceipt[]> {
278
+ this.ensureUser();
279
+ const owner = address ? new SolPubKey(address) :
280
+ this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
281
+ return await this.convertClient.fetchWithdrawReceipts(owner);
282
+ }
283
+
284
+ /**
285
+ * Claim a withdrawal receipt (burn NFT + receive SOL) via claim_withdraw.
286
+ */
287
+ async claimWithdraw(tokenId: bigint): Promise<string> {
288
+ this.ensureUser();
289
+ const owner = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
290
+
291
+ try {
292
+ const ix = await this.convertClient.buildClaimWithdrawTx(tokenId, owner);
293
+ return !!this.squadsX
294
+ ? await this.sendSquadsIxs(ix)
295
+ : await this.buildAndSendIx(ix);
296
+ } catch (err) {
297
+ console.log(`Failed to claim withdraw on Solana: ${err}`);
298
+ throw err;
299
+ }
300
+ }
301
+
302
+ /**
303
+ * Claim accrued liqSOL distribution rewards (liqsol_core::claim_rewards).
304
+ */
305
+ async claimLiqsolRewards(): Promise<string> {
306
+ this.ensureUser();
307
+ const owner = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
308
+
309
+ try {
310
+ const ix = await this.distributionClient.buildClaimRewardsIx(owner);
311
+ return !!this.squadsX
312
+ ? await this.sendSquadsIxs(ix)
313
+ : await this.buildAndSendIx(ix);
314
+ } catch (err) {
315
+ console.log(`Failed to claim liqSOL rewards on Solana: ${err}`);
316
+ throw err;
317
+ }
318
+ }
319
+
320
+ /**
321
+ * Stake liqSOL into Outpost (liqSOL → pool) via liqsol_core::synd.
322
+ */
323
+ async stake(amountLamports: bigint): Promise<string> {
324
+ this.ensureUser();
325
+ if (!amountLamports || amountLamports <= BigInt(0))
326
+ throw new Error('Stake amount must be greater than zero.');
327
+
328
+ try {
329
+ const ix = await this.outpostClient.buildStakeIx(amountLamports, this.squadsVaultPDA)
330
+ return !!this.squadsX
331
+ ? await this.sendSquadsIxs(ix)
332
+ : await this.buildAndSendIx(ix)
333
+
334
+ } catch (err) {
335
+ console.log(`Failed to stake Solana: ${err}`);
336
+ throw err;
337
+ }
78
338
  }
79
339
 
80
340
  /**
81
- * Resolve the user's liqSOL ATA and balances + key protocol balances.
82
- * native = SOL in wallet
83
- * actual = liqSOL token balance (from ATA)
84
- * tracked = liqSOL tracked balance (from Distribution.userRecord)
341
+ * Unstake liqSOL from Outpost (pool liqSOL) via liqsol_core::desynd.
85
342
  */
86
- async getPortfolio(): Promise<Portfolio> {
343
+ async unstake(amountLamports: bigint): Promise<string> {
344
+ this.ensureUser();
345
+ if (!amountLamports || amountLamports <= BigInt(0))
346
+ throw new Error('Unstake amount must be greater than zero.');
347
+
87
348
  try {
88
- const user = this.solPubKey;
89
- const reservePoolPDA = deriveReservePoolPda();
90
- const vaultPDA = deriveVaultPda();
91
- const liqsolMint = deriveLiqsolMintPda();
349
+ const ix = await this.outpostClient.buildUnstakeIx(amountLamports, this.squadsVaultPDA)
350
+ return !!this.squadsX
351
+ ? await this.sendSquadsIxs(ix)
352
+ : await this.buildAndSendIx(ix)
353
+ }
354
+ catch (err) {
355
+ console.log(`Failed to unstake Solana: ${err}`);
356
+ throw err;
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Buy prelaunch WIRE “pretokens” using liqSOL.
362
+ *
363
+ * This delegates to TokenClient, which uses the `purchase`-style
364
+ * instruction under the new IDL (no more native-SOL purchase).
365
+ */
366
+ async buy(amountLamports: bigint): Promise<string> {
367
+ this.ensureUser();
368
+ if (!amountLamports || amountLamports <= BigInt(0))
369
+ throw new Error('liqSOL pretoken purchase requires a positive amount.');
370
+
371
+ try {
372
+ const ix = await this.tokenClient.buildPurchaseIx(amountLamports, this.squadsVaultPDA)
373
+ return !!this.squadsX
374
+ ? await this.sendSquadsIxs(ix)
375
+ : await this.buildAndSendIx(ix)
376
+ }
377
+ catch (err) {
378
+ console.log(`Failed to buy liqSOL pretokens: ${err}`);
379
+ throw err;
380
+ }
381
+ }
382
+
383
+ /** Deposit SOL to liqSOL, then syndicate that liqSOL in one transaction. Requires enough SOL for the deposit fee. */
384
+ async depositAndStake(amountLamports: bigint): Promise<string> {
385
+ this.ensureUser();
386
+ if (!amountLamports || amountLamports <= BigInt(0))
387
+ throw new Error('Amount must be greater than zero.');
388
+
389
+ try {
390
+ const user = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
391
+ const depositIx = await this.convertClient.buildDepositTx(amountLamports, user);
392
+ const stakeIx = await this.outpostClient.buildStakeIx(amountLamports, user);
393
+
394
+ return !!this.squadsX
395
+ ? await this.sendSquadsIxs([depositIx, stakeIx])
396
+ : await this.buildAndSendIx([depositIx, stakeIx]);
397
+ } catch (err) {
398
+ console.log(`Failed to deposit and stake: ${err}`);
399
+ throw err;
400
+ }
401
+ }
402
+
403
+ /** Deposit SOL to liqSOL, then buy pretokens with that liqSOL in one transaction. Requires enough SOL for the deposit fee. */
404
+ async depositAndBuy(amountLamports: bigint): Promise<string> {
405
+ this.ensureUser();
406
+ if (!amountLamports || amountLamports <= BigInt(0))
407
+ throw new Error('Amount must be greater than zero.');
408
+
409
+ try {
410
+ const user = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
411
+ const depositIx = await this.convertClient.buildDepositTx(amountLamports, user);
412
+ const purchaseIx = await this.tokenClient.buildPurchaseIx(amountLamports, user);
413
+
414
+ return !!this.squadsX
415
+ ? await this.sendSquadsIxs([depositIx, purchaseIx])
416
+ : await this.buildAndSendIx([depositIx, purchaseIx]);
417
+ } catch (err) {
418
+ console.log(`Failed to deposit and buy: ${err}`);
419
+ throw err;
420
+ }
421
+ }
422
+
423
+ /** Desyndicate liqSOL, then request withdraw in one transaction. */
424
+ async unstakeAndWithdraw(amountLamports: bigint): Promise<string> {
425
+ this.ensureUser();
426
+ if (!amountLamports || amountLamports <= BigInt(0))
427
+ throw new Error('Amount must be greater than zero.');
428
+
429
+ try {
430
+ const user = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
431
+ const unstakeIx = await this.outpostClient.buildUnstakeIx(amountLamports, user);
432
+ const withdrawIx = await this.convertClient.buildWithdrawTx(amountLamports, user);
433
+
434
+ return !!this.squadsX
435
+ ? await this.sendSquadsIxs([unstakeIx, withdrawIx])
436
+ : await this.buildAndSendIx([unstakeIx, withdrawIx]);
437
+ } catch (err) {
438
+ console.log(`Failed to unstake and withdraw: ${err}`);
439
+ throw err;
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Aggregate view of the user’s balances on Solana:
445
+ * - native: SOL wallet balance
446
+ * - liq: liqSOL token balance (Token-2022 ATA)
447
+ * - staked: liqSOL staked in Outpost (synd/desynd) → outpostAccount.stakedLiqsol
448
+ * - wire: total WIRE pretokens purchased (1e8 scale)
449
+ * - yield: on-chain index/shares plus an estimated accrued liqSOL yield
450
+ * - extras: useful internal addresses and raw state for debugging/UX
451
+ */
452
+ async getPortfolio(address?: string): Promise<Portfolio> {
453
+ // if (!this.pubKey) throw new Error('User pubKey is undefined');
454
+ try {
455
+ const user = address ? new SolPubKey(address) :
456
+ !!this.squadsX ? this.squadsVaultPDA! : this.solPubKey;
457
+
458
+ const reservePoolPDA = this.program.deriveReservePoolPda();
459
+ const vaultPDA = this.program.deriveVaultPda();
460
+ const liqsolMint = this.program.deriveLiqsolMintPda();
461
+
92
462
  const userLiqsolAta = getAssociatedTokenAddressSync(
93
463
  liqsolMint,
94
464
  user,
95
- false,
465
+ true,
96
466
  TOKEN_2022_PROGRAM_ID,
467
+ ASSOCIATED_TOKEN_PROGRAM_ID,
97
468
  );
98
469
 
99
- // Fetch balances and user record in parallel
100
- const [nativeLamports, actualBalResp, userRecord] = await Promise.all([
101
- this.connection.getBalance(user),
102
- this.connection.getTokenAccountBalance(userLiqsolAta).catch(() => null),
103
- this.distributionClient.getUserRecord(user).catch(() => null),
470
+ // NOTE:
471
+ // - nativeLamports: wallet SOL
472
+ // - actualBalResp: liqSOL balance in user ATA
473
+ // - snapshot: Outpost + pretokens + global index/shares
474
+ const [nativeLamports, actualBalResp, snapshot, claimableLamports] = await Promise.all([
475
+ this.connection.getBalance(user, 'confirmed'),
476
+ this.connection
477
+ .getTokenAccountBalance(userLiqsolAta, 'confirmed')
478
+ .catch(() => null),
479
+ this.outpostClient.fetchWireState(user).catch(() => null),
480
+ this.distributionClient.getClaimableLiqsol(user).catch(() => new BN(0)),
104
481
  ]);
105
482
 
483
+ const LIQSOL_DECIMALS = 9;
484
+
106
485
  const actualAmountStr = actualBalResp?.value?.amount ?? '0';
107
- const actualDecimals = actualBalResp?.value?.decimals ?? 9;
108
486
 
109
- const trackedAmountStr = userRecord?.trackedBalance ? userRecord.trackedBalance.toString() : '0';
110
- const trackedDecimals = actualDecimals;
487
+ const globalState = snapshot?.globalState ?? null;
488
+ const outpostAccount = snapshot?.outpostAccount ?? null;
489
+ const trancheState = snapshot?.trancheState ?? null;
490
+ const userPretokenRecord = snapshot?.userPretokenRecord ?? null;
491
+
492
+ // -----------------------------
493
+ // Staked liqSOL (Outpost)
494
+ // -----------------------------
495
+ // This is the liqSOL that has been syndicated into Outpost via `synd`.
496
+ // It lives on the outpost account as `stakedLiqsol`.
497
+ const stakedLiqsolStr =
498
+ outpostAccount?.stakedLiqsol?.toString?.() ?? '0';
499
+
500
+ // -----------------------------
501
+ // WIRE pretokens (1e8 scale)
502
+ // -----------------------------
503
+ // This is NOT stake — it’s the prelaunch WIRE position.
504
+ const wirePretokensStr =
505
+ userPretokenRecord?.totalPretokensPurchased?.toString?.() ??
506
+ '0';
507
+
508
+ // -----------------------------
509
+ // Yield view (index + shares)
510
+ // -----------------------------
511
+ // We expose:
512
+ // - currentIndex: globalState.currentIndex (1e12 scale)
513
+ // - totalShares: globalState.totalShares
514
+ // - userShares: outpostAccount.stakedShares
515
+ // - estimatedClaimLiqsol: floor(userShares * index / INDEX_SCALE)
516
+ // - estimatedYield: max(0, estimatedClaim - stakedLiqsol)
517
+ //
518
+ // This matches the capital-staking math:
519
+ // sharesToTokens(shares, index) = shares * index / INDEX_SCALE
520
+ const currentIndexStr =
521
+ globalState?.currentIndex?.toString?.() ?? '0';
522
+ const totalSharesStr =
523
+ globalState?.totalShares?.toString?.() ?? '0';
524
+ const userSharesStr =
525
+ outpostAccount?.stakedShares?.toString?.() ?? '0';
111
526
 
112
- const nativeSymbol = 'SOL';
113
- const liqSymbol = 'LiqSOL';
527
+ const stakedLiqsol = BigInt(stakedLiqsolStr);
528
+ const currentIndex = BigInt(currentIndexStr);
529
+ const totalShares = BigInt(totalSharesStr);
530
+ const userShares = BigInt(userSharesStr);
114
531
 
115
- const portfolio: Portfolio = {
532
+ let estimatedClaim = BigInt(0);
533
+ let estimatedYield = BigInt(0);
534
+
535
+ if (userShares > BigInt(0) && currentIndex > BigInt(0)) {
536
+ // sharesToTokens(userShares, currentIndex)
537
+ estimatedClaim = (userShares * currentIndex) / INDEX_SCALE;
538
+
539
+ if (estimatedClaim > stakedLiqsol) {
540
+ estimatedYield = estimatedClaim - stakedLiqsol;
541
+ }
542
+ }
543
+
544
+ return {
116
545
  native: {
117
546
  amount: BigInt(nativeLamports),
118
- symbol: nativeSymbol,
547
+ symbol: 'SOL',
119
548
  decimals: 9,
120
549
  },
121
550
  liq: {
122
551
  amount: BigInt(actualAmountStr),
123
- symbol: liqSymbol,
124
- decimals: actualDecimals,
552
+ symbol: 'LiqSOL',
553
+ decimals: LIQSOL_DECIMALS,
554
+ ata: userLiqsolAta,
555
+ },
556
+ claimable: {
557
+ amount: BigInt(claimableLamports.toString()),
558
+ symbol: 'LiqSOL',
559
+ decimals: LIQSOL_DECIMALS,
560
+ ata: userLiqsolAta,
125
561
  },
126
- staked: { // TODO: fetch staked balance from outpost
127
- amount: BigInt(0),
128
- symbol: liqSymbol,
129
- decimals: actualDecimals,
562
+ staked: {
563
+ // liqSOL staked in Outpost via `synd`
564
+ amount: stakedLiqsol,
565
+ symbol: 'LiqSOL',
566
+ decimals: LIQSOL_DECIMALS,
130
567
  },
131
- tracked: { // SOL ONLY
132
- amount: BigInt(trackedAmountStr),
133
- symbol: liqSymbol,
134
- decimals: trackedDecimals,
568
+ wire: {
569
+ // Prelaunch WIRE pretokens (1e8 scale)
570
+ amount: BigInt(wirePretokensStr),
571
+ symbol: '$WIRE',
572
+ decimals: 8,
573
+ },
574
+ yield: {
575
+ // Raw primitives so the frontend can display curves, charts, etc.
576
+ currentIndex,
577
+ indexScale: INDEX_SCALE,
578
+ totalShares,
579
+ userShares,
580
+ // liqSOL amounts (lamports) implied by index/shares
581
+ estimatedClaim,
582
+ estimatedYield,
135
583
  },
136
584
  extras: {
137
585
  userLiqsolAta: userLiqsolAta.toBase58(),
138
586
  reservePoolPDA: reservePoolPDA.toBase58(),
139
587
  vaultPDA: vaultPDA.toBase58(),
588
+ globalIndex: globalState?.currentIndex?.toString(),
589
+ totalShares: globalState?.totalShares?.toString(),
590
+ currentTrancheNumber:
591
+ trancheState?.currentTrancheNumber?.toString(),
592
+ currentTranchePriceUsd:
593
+ trancheState?.currentTranchePriceUsd?.toString(), // 1e8 USD
140
594
  },
141
- chainID: this.network.chainId
595
+ chainID: this.network.chainId,
142
596
  };
143
-
144
- // console.log('SOL PORTFOLIO', portfolio);
145
- return portfolio;
146
597
  }
147
- catch (error) {
148
- console.log('Error in getPortfolio:', error);
149
- throw error;
598
+ catch (err) {
599
+ console.log(`Failed to get Solana portfolio: ${err}`);
600
+ throw err;
150
601
  }
151
602
  }
152
603
 
153
604
  /**
154
- * Optional: fetch your Distribution program user record
155
- * (often contains per-user deposit/claim state).
156
- * @returns UserRecord or null
605
+ * Convenience helper to fetch the distribution userRecord for the current user.
606
+ * Used by balance-correction flows and debugging.
157
607
  */
158
608
  async getUserRecord() {
609
+ if (!this.pubKey) throw new Error('User pubKey is undefined');
159
610
  return this.distributionClient.getUserRecord(this.solPubKey);
160
611
  }
161
612
 
162
- getProtocolFee() {
163
- // TODO: wire to pay-rate math once we finalize protocol fee API
613
+ // ---------------------------------------------------------------------
614
+ // SquadsX Helpers
615
+ // ---------------------------------------------------------------------
616
+
617
+ get squadsMultisigPDA(): SolPubKey | undefined {
618
+ if (!this.squadsX) return undefined;
619
+ return new SolPubKey(this.squadsX.multisigPDA);
620
+ }
621
+
622
+ get squadsVaultPDA(): SolPubKey | undefined {
623
+ if (!this.squadsX || !this.squadsMultisigPDA) return undefined;
624
+ const multisigPda = this.squadsMultisigPDA;
625
+ const index = this.squadsX.vaultIndex ?? 0;
626
+ const pda = multisig.getVaultPda({ multisigPda, index });
627
+ return pda[0];
628
+ }
629
+
630
+ /** Create a Squads vault transaction/proposal for one or more instructions. */
631
+ private async sendSquadsIxs(ix: TransactionInstruction | TransactionInstruction[]): Promise<string> {
632
+ if (!this.squadsX) throw new Error('Attempting to wrap Squads instruction without SquadsX config');
633
+
634
+ const ixs = Array.isArray(ix) ? ix : [ix];
635
+ const multisigPda = this.squadsMultisigPDA!;
636
+ const vaultPda = this.squadsVaultPDA!;
637
+ const vaultIndex = this.squadsX?.vaultIndex ?? 0;
638
+ const creator = this.solPubKey;
639
+
640
+ const ms = await multisig.accounts.Multisig.fromAccountAddress(this.connection, multisigPda);
641
+ const current = BigInt(ms.transactionIndex?.toString() ?? 0);
642
+ const transactionIndex = current + BigInt(1);
643
+
644
+ const altAddress = this.program.PROGRAM_IDS.ALT;
645
+ const altAccount = await this.connection.getAddressLookupTable(altAddress);
646
+ if (!altAccount.value) throw new Error("ALT not found on-chain or not yet active.");
647
+
648
+ const lookupTable: AddressLookupTableAccount = altAccount.value;
649
+ const computeLimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 });
650
+ const computePriceIx = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 2000 });
651
+
652
+ const { blockhash } = await this.connection.getLatestBlockhash("confirmed");
653
+ const transactionMessage = new TransactionMessage({
654
+ payerKey: vaultPda,
655
+ recentBlockhash: blockhash,
656
+ instructions: [computeLimitIx, computePriceIx, ...ixs],
657
+ });
658
+
659
+ const createVaultTxIx = await multisig.instructions.vaultTransactionCreate({
660
+ multisigPda,
661
+ transactionIndex,
662
+ creator,
663
+ vaultIndex,
664
+ transactionMessage,
665
+ ephemeralSigners: 0,
666
+ addressLookupTableAccounts: [lookupTable],
667
+ });
668
+
669
+ const vaultTransactionCreate = await this.buildAndSendIx(createVaultTxIx)
670
+ console.log('SQUADSX: vaultTransactionCreate', vaultTransactionCreate);
671
+
672
+ const createProposalIx = await multisig.instructions.proposalCreate({
673
+ multisigPda,
674
+ transactionIndex,
675
+ creator,
676
+ });
677
+
678
+ const proposalCreate = await this.buildAndSendIx(createProposalIx)
679
+ console.log('SQUADSX: proposalCreate', proposalCreate);
680
+
681
+ return proposalCreate;
682
+ }
683
+
684
+ // async finish(multisigPda: string, transactionIndex: number): Promise<void> {
685
+ // const vaultExecute = await multisig.instructions.vaultTransactionExecute({
686
+ // connection: this.connection,
687
+ // multisigPda: new SolPubKey(multisigPda),
688
+ // transactionIndex: BigInt(transactionIndex),
689
+ // member: this.solPubKey
690
+ // });
691
+
692
+ // const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 400_000 });
693
+ // const tx1 = new Transaction().add(cuIx, vaultExecute.instruction);
694
+ // const prepared1 = await this.prepareTx(tx1);
695
+ // const signed1 = await this.signTransaction(prepared1.tx);
696
+ // const sent1 = await this.sendAndConfirmHttp(signed1, prepared1);
697
+ // console.log('SENT FINISH', sent1);
698
+ // }
699
+
700
+ // ---------------------------------------------------------------------
701
+ // Tx helpers
702
+ // ---------------------------------------------------------------------
703
+
704
+ async buildAndSendIx(ix: TransactionInstruction | TransactionInstruction[]): Promise<string> {
705
+ const ixs = Array.isArray(ix) ? ix : [ix];
706
+ const computeLimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 });
707
+ const computePriceIx = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 2000 });
708
+ const { blockhash, lastValidBlockHeight } =
709
+ await this.connection.getLatestBlockhash('confirmed');
710
+
711
+ const altAddress = this.program.PROGRAM_IDS.ALT;
712
+ const altAccount = await this.connection.getAddressLookupTable(altAddress);
713
+ const lookupTable = altAccount.value;
714
+
715
+ const instructions = [computeLimitIx, computePriceIx, ...ixs];
716
+
717
+ const tx = lookupTable
718
+ ? new VersionedTransaction(
719
+ new TransactionMessage({
720
+ payerKey: this.feePayer,
721
+ recentBlockhash: blockhash,
722
+ instructions,
723
+ }).compileToV0Message([lookupTable]),
724
+ )
725
+ : new Transaction().add(...instructions);
726
+
727
+ const prepared =
728
+ tx instanceof Transaction
729
+ ? await this.prepareTx(tx)
730
+ : { tx, blockhash, lastValidBlockHeight };
731
+
732
+ const signed = await this.signTransaction(prepared.tx);
733
+
734
+ return this.sendAndConfirmHttp(signed, prepared);
735
+ }
736
+
737
+
738
+ /**
739
+ * Send a signed transaction over HTTP RPC.
740
+ *
741
+ * - Returns immediately on successful sendRawTransaction.
742
+ * - If sendRawTransaction throws a SendTransactionError with
743
+ * "already been processed", we treat it as success and
744
+ * just return a derived signature.
745
+ * - No confirmTransaction / polling / blockheight handling.
746
+ */
747
+ private async sendAndConfirmHttp(
748
+ signed: SolanaTransaction,
749
+ _ctx: { blockhash: string; lastValidBlockHeight: number },
750
+ ): Promise<string> {
751
+ this.ensureUser();
752
+
753
+ const rawTx = signed.serialize();
754
+
755
+ try {
756
+ // Normal happy path: RPC accepts the tx and returns a signature
757
+ const signature = await this.connection.sendRawTransaction(rawTx, {
758
+ skipPreflight: false,
759
+ preflightCommitment: commitment,
760
+ maxRetries: 3,
761
+ });
762
+ return signature;
763
+ } catch (e: any) {
764
+ const msg = e?.message ?? '';
765
+ const isSendTxError =
766
+ e instanceof SendTransactionError || e?.name === 'SendTransactionError';
767
+
768
+ // Benign duplicate case: tx is already in the ledger / cache
769
+ if (isSendTxError && msg.includes('already been processed')) {
770
+ console.warn(
771
+ 'sendRawTransaction reports "already been processed"; ' +
772
+ 'treating as success without further confirmation.',
773
+ );
774
+
775
+ // Try to derive a signature from the signed Transaction.
776
+ // If SolanaTransaction is a legacy Transaction, this works.
777
+ const legacy = signed as unknown as Transaction;
778
+ const first = legacy.signatures?.[0]?.signature;
779
+
780
+ if (first) {
781
+ return bs58.encode(first);
782
+ }
783
+
784
+ // Fallback: return a dummy string
785
+ return 'already-processed';
786
+ }
787
+
788
+ // Any other send error is a real failure
789
+ throw e;
790
+ }
791
+ }
792
+
793
+ /**
794
+ * Sign a single Solana transaction using the connected wallet adapter.
795
+ */
796
+ async signTransaction(
797
+ tx: SolanaTransaction,
798
+ ): Promise<SolanaTransaction> {
799
+ this.ensureUser();
800
+ return this.anchor.wallet.signTransaction(tx);
164
801
  }
165
802
 
166
803
  /**
167
- * Deposit funds into the staking pool.
168
- * @param lamports The amount to deposit (in lamports).
169
- * @returns The transaction signature.
804
+ * Generic "fire and forget" send helper if the caller already
805
+ * prepared and signed the transaction.
170
806
  */
171
- async deposit(lamports: number): Promise<string> {
172
- const { transaction } = await this.depositClient.buildDepositTx(this.solPubKey, lamports);
173
- const { tx, blockhash, lastValidBlockHeight } = await this.prepareTx(transaction);
174
- const signed = await this.signTransaction(tx);
175
- const result = await this.sendAndConfirmHttp(signed, { blockhash, lastValidBlockHeight });
176
- return result.signature;
807
+ async sendTransaction(
808
+ signed: SolanaTransaction,
809
+ ): Promise<TransactionSignature> {
810
+ this.ensureUser();
811
+ return this.anchor.sendAndConfirm(signed);
812
+ }
813
+
814
+ /**
815
+ * Attach recent blockhash + fee payer to a transaction.
816
+ * Required before signing and sending.
817
+ */
818
+ async prepareTx(
819
+ tx: Transaction,
820
+ ): Promise<{
821
+ tx: Transaction;
822
+ blockhash: string;
823
+ lastValidBlockHeight: number;
824
+ }> {
825
+ const { blockhash, lastValidBlockHeight } =
826
+ await this.connection.getLatestBlockhash('confirmed');
827
+ tx.recentBlockhash = blockhash;
828
+ tx.feePayer = this.feePayer;
829
+ return { tx, blockhash, lastValidBlockHeight };
830
+ }
831
+
832
+ /**
833
+ * Guard for all write operations (deposit/withdraw/stake/unstake/buy).
834
+ * Ensures we have a Wire pubKey and an Anchor wallet pubKey, and that they match.
835
+ */
836
+ ensureUser() {
837
+ if (!this.pubKey) throw new Error('User pubKey is undefined');
838
+
839
+ const wallet = this.anchor?.wallet as any;
840
+ const pk = wallet?.publicKey as SolPubKey | undefined;
841
+
842
+ if (!pk) throw new Error('Wallet not connected');
843
+ if (typeof wallet.signTransaction !== 'function') {
844
+ throw new Error('Wallet does not support signTransaction');
845
+ }
846
+
847
+ // if (!this.pubKey || !this.anchor.wallet.publicKey) {
848
+ // throw new Error('User Authorization required: pubKey is undefined');
849
+ // }
850
+ // if (
851
+ // this.solPubKey.toBase58() !==
852
+ // this.anchor.wallet.publicKey.toBase58()
853
+ // ) {
854
+ // throw new Error(
855
+ // 'Write access requires connected wallet to match pubKey',
856
+ // );
857
+ // }
177
858
  }
178
859
 
860
+ // ---------------------------------------------------------------------
861
+ // READ-ONLY Public Methods
862
+ // ---------------------------------------------------------------------
863
+
179
864
  /**
180
- * Build, sign, and submit a single transaction that:
181
- * - Corrects other users (if needed) to free available balance, then
182
- * - Registers the caller’s untracked liqSOL.
865
+ * Unified, chain-agnostic tranche snapshot for Solana.
183
866
  *
184
- * @param amount Optional: register a smaller amount than your full untracked balance.
185
- * @returns signature string
867
+ * Uses:
868
+ * - liqsol_core.globalState (currentIndex, totalShares, etc.)
869
+ * - liqsol_core.trancheState (price, supply, total sold, etc.)
870
+ * - PriceHistory/Chainlink SOL/USD via TokenClient.getSolPriceUsdSafe()
871
+ *
872
+ * This is READ-ONLY and works even with no connected wallet.
186
873
  */
187
- async correctBalance(amount?: bigint): Promise<string> {
874
+ async getTrancheSnapshot(chainID: ChainID): Promise<TrancheSnapshot> {
188
875
  try {
189
- const build = await this.distributionClient.buildCorrectRegisterTx({ amount });
190
- if (!build.canSucceed || !build.transaction) {
191
- throw new Error(build.reason ?? 'Unable to build Correct&Register transaction');
192
- }
876
+ const [globalState, trancheState] = await Promise.all([
877
+ this.tokenClient.fetchGlobalState(),
878
+ this.tokenClient.fetchTrancheState(),
879
+ ]);
880
+
881
+ const { price: solPriceUsd, timestamp } =
882
+ await this.tokenClient.getSolPriceUsdSafe();
193
883
 
194
- const { tx, blockhash, lastValidBlockHeight } = await this.prepareTx(build.transaction);
195
- const signed = await this.signTransaction(tx);
196
- const result = await this.sendAndConfirmHttp(signed, { blockhash, lastValidBlockHeight });
197
-
198
- console.log('Registered:', {
199
- needToRegister: build.needToRegister,
200
- freed: build.plan.willFree,
201
- corrected: build.plan.selected.map((c) => ({
202
- owner: c.owner?.toBase58(),
203
- delta: c.delta?.toString(),
204
- })),
884
+ return buildSolanaTrancheSnapshot({
885
+ chainID,
886
+ globalState,
887
+ trancheState,
888
+ solPriceUsd,
889
+ nativePriceTimestamp: timestamp,
205
890
  });
891
+ }
892
+ catch (err) {
893
+ console.log(`Failed to build Solana tranche snapshot: ${err}`);
894
+ throw err;
895
+ }
896
+ }
206
897
 
207
- return result.signature;
208
- } catch (error) {
209
- console.error('Error in register:', error);
210
- throw error;
898
+ /**
899
+ * Returns the system APY (percent) for Solana,
900
+ * using compound interest per epoch and a
901
+ * cluster-derived epochs-per-year.
902
+ */
903
+ async getSystemAPY(): Promise<number> {
904
+ try {
905
+ // 1) Per-epoch rate (decimal) from on-chain stakeMetrics
906
+ const ratePerEpoch = await this.getEpochRateDecimalFromProgram();
907
+ // 2) Live epochs-per-year estimate from cluster
908
+ const epochsPerYear = await this.getEpochsPerYearFromCluster();
909
+ // 3) Compound: (1 + r)^N - 1
910
+ const apyDecimal = Math.pow(1 + ratePerEpoch, epochsPerYear) - 1;
911
+ // 4) Convert to percent
912
+ const apyPercent = apyDecimal * 100;
913
+
914
+ return apyPercent;
915
+ } catch (err) {
916
+ console.log(`Failed to compute Solana system APY: ${err}`);
917
+ throw err;
211
918
  }
212
919
  }
213
920
 
214
- private async sendAndConfirmHttp(
215
- signed: SolanaTransaction,
216
- ctx: { blockhash: string; lastValidBlockHeight: number },
217
- ): Promise<TxResult> {
218
- const signature = await this.connection.sendRawTransaction(signed.serialize(), {
219
- skipPreflight: false,
220
- preflightCommitment: commitment,
221
- maxRetries: 3,
222
- });
921
+ /**
922
+ * Reads the liqsol_core stakeMetrics account and returns the
923
+ * Solana per-epoch system rate as a **decimal** (not BPS),
924
+ * de-scaled using PAY_RATE_SCALE_FACTOR (1e12).
925
+ */
926
+ private async getEpochRateDecimalFromProgram(): Promise<number> {
927
+ const liqSolCoreProgram = this.program.getProgram('liqsolCore');
928
+ const payRateHistoryPda = this.program.derivePayRateHistoryPda();
223
929
 
224
- const conf = await this.connection.confirmTransaction(
225
- { signature, blockhash: ctx.blockhash, lastValidBlockHeight: ctx.lastValidBlockHeight },
226
- commitment,
930
+ const payRateHistory =
931
+ await liqSolCoreProgram.account.payRateHistory.fetch(payRateHistoryPda);
932
+
933
+ const totalEntriesAdded = Number(payRateHistory.totalEntriesAdded);
934
+ const maxEntries = Number(payRateHistory.maxEntries);
935
+
936
+ if (totalEntriesAdded === 0) {
937
+ // No real entries yet, fall back to default
938
+ return Number(DEFAULT_AVERAGE_PAY_RATE) / Number(PAY_RATE_SCALE_FACTOR);
939
+ }
940
+
941
+ const currentIndex = Number(payRateHistory.currentIndex);
942
+
943
+ // Only average entries that have actually been processed (written by add_entry),
944
+ // not the default-initialized slots. After 10+ entries, processedCount === maxEntries.
945
+ const processedCount = Math.min(totalEntriesAdded, maxEntries);
946
+
947
+ let sum = BigInt(0);
948
+ let validCount = 0;
949
+ // Walk backward from most recent entry
950
+ let idx = (currentIndex - 1 + maxEntries) % maxEntries;
951
+
952
+ for (let i = 0; i < processedCount; i++) {
953
+ const entry = payRateHistory.entries[idx];
954
+ const scaledRate = BigInt(entry.scaledRate.toString());
955
+ if (scaledRate > BigInt(0)) {
956
+ sum += scaledRate;
957
+ validCount++;
958
+ }
959
+ idx = (idx - 1 + maxEntries) % maxEntries;
960
+ }
961
+
962
+ if (validCount === 0) {
963
+ return Number(DEFAULT_AVERAGE_PAY_RATE) / Number(PAY_RATE_SCALE_FACTOR);
964
+ }
965
+
966
+ // Average the processed entries
967
+ const average = Number(sum / BigInt(validCount));
968
+ return average / Number(PAY_RATE_SCALE_FACTOR);
969
+ }
970
+
971
+ // Simple cache so we don’t hammer RPC
972
+ private epochsPerYearCache?: { value: number; fetchedAt: number };
973
+ private static readonly EPOCHS_PER_YEAR_TTL_MS = 10 * 60 * 1000; // 10 minutes
974
+
975
+ /**
976
+ * Derive "epochs per year" from the live Solana cluster.
977
+ *
978
+ * Uses:
979
+ * - getRecentPerformanceSamples() to estimate slots/second
980
+ * - getEpochInfo() to read slotsInEpoch
981
+ */
982
+ private async getEpochsPerYearFromCluster(): Promise<number> {
983
+ const now = Date.now();
984
+
985
+ if (
986
+ this.epochsPerYearCache &&
987
+ now - this.epochsPerYearCache.fetchedAt <
988
+ SolanaStakingClient.EPOCHS_PER_YEAR_TTL_MS
989
+ ) {
990
+ return this.epochsPerYearCache.value;
991
+ }
992
+
993
+ const connection = this.anchor.connection;
994
+
995
+ // 1) Estimate slots/second from recent performance samples
996
+ const samples: PerfSample[] = await connection.getRecentPerformanceSamples(
997
+ 60,
227
998
  );
999
+ if (!samples.length) {
1000
+ throw new Error('No performance samples available from cluster');
1001
+ }
228
1002
 
229
- const ok = !conf.value.err;
230
- if (!ok) {
231
- throw new Error(`Transaction failed: ${JSON.stringify(conf.value.err)}`);
1003
+ const totalSlots = samples.reduce((acc, s) => acc + s.numSlots, 0);
1004
+ const totalSecs = samples.reduce((acc, s) => acc + s.samplePeriodSecs, 0);
1005
+
1006
+ if (totalSecs === 0) {
1007
+ throw new Error(
1008
+ 'Cluster returned zero samplePeriodSecs in performance samples',
1009
+ );
232
1010
  }
233
- return { signature, slot: conf.context.slot, confirmed: true };
1011
+
1012
+ const slotsPerSecond = totalSlots / totalSecs;
1013
+
1014
+ // 2) Slots per epoch from cluster
1015
+ const epochInfo = await connection.getEpochInfo(); // finalized commitment by default
1016
+ const slotsPerEpoch = epochInfo.slotsInEpoch;
1017
+
1018
+ const secondsPerEpoch = slotsPerEpoch / slotsPerSecond;
1019
+ const secondsPerYear = 365 * 24 * 60 * 60;
1020
+
1021
+ const epochsPerYear = secondsPerYear / secondsPerEpoch;
1022
+
1023
+ this.epochsPerYearCache = {
1024
+ value: epochsPerYear,
1025
+ fetchedAt: now,
1026
+ };
1027
+
1028
+ return epochsPerYear;
234
1029
  }
235
1030
 
236
- async signTransaction(tx: SolanaTransaction): Promise<SolanaTransaction> {
237
- return this.anchor.wallet.signTransaction(tx);
1031
+ // ---------------------------------------------
1032
+ // Deposit fee calculation (SOL -> liqSOL)
1033
+ // ---------------------------------------------
1034
+
1035
+ /**
1036
+ * Estimate the protocol deposit fee in lamports for a given SOL amount,
1037
+ * based on recent pay rates and globalConfig.depositFeeMultiplier.
1038
+ *
1039
+ * - amountLamports: deposit notional in lamports
1040
+ * - windowSize: how many recent payRate entries to average (default 5)
1041
+ *
1042
+ * Returns 0n if payRateHistory or globalConfig is missing, or if
1043
+ * there are no valid pay-rate entries yet.
1044
+ */
1045
+ async getDepositFee(
1046
+ amountLamports: bigint,
1047
+ windowSize = 5,
1048
+ ): Promise<bigint> {
1049
+ if (amountLamports <= BigInt(0)) {
1050
+ return BigInt(0);
1051
+ }
1052
+
1053
+ const [avgPayRate, globalConfig]: [BN, GlobalConfig | null] = await Promise.all([
1054
+ this.distributionClient.getAverageScaledPayRate(windowSize),
1055
+ this.distributionClient.getGlobalConfig(),
1056
+ ]);
1057
+
1058
+ if (!globalConfig || avgPayRate.isZero()) {
1059
+ return BigInt(0);
1060
+ }
1061
+
1062
+ // depositFeeMultiplier may be BN or number depending on your type
1063
+ const rawMultiplier = globalConfig.depositFeeMultiplier;
1064
+ const multiplier = new BN(
1065
+ rawMultiplier?.toString?.() ?? rawMultiplier ?? 0,
1066
+ );
1067
+ if (multiplier.isZero()) {
1068
+ return BigInt(0);
1069
+ }
1070
+
1071
+ const amountBn = new BN(amountLamports.toString());
1072
+
1073
+ // 10^12 scale (matches scaledRate / index scale)
1074
+
1075
+ const feeBn = ceilDiv(
1076
+ avgPayRate.mul(multiplier).mul(amountBn),
1077
+ SCALE,
1078
+ );
1079
+
1080
+ return BigInt(feeBn.toString());
238
1081
  }
239
1082
 
240
- async sendTransaction(signed: SolanaTransaction): Promise<TransactionSignature> {
241
- return this.anchor.sendAndConfirm(signed);
1083
+ /**
1084
+ * Compute a conservative "deposit buffer" in lamports that should be left
1085
+ * in the wallet so that a MAX deposit (balance - buffer) will succeed.
1086
+ *
1087
+ * It accounts for:
1088
+ * - Runtime tx fees (via cached dummy self-transfer fee)
1089
+ * - Protocol deposit fee (via getDepositFee(amount))
1090
+ *
1091
+ * Intended UI usage:
1092
+ * const buffer = await client.getDepositBuffer();
1093
+ * const balance = portfolio.native.amount;
1094
+ * const maxDeposit = balance > buffer ? balance - buffer : BigInt(0);
1095
+ */
1096
+ async getDepositBuffer(options?: {
1097
+ txCount?: number; // how many txs to cover in gas buffer (default 2)
1098
+ safetyMultiplier?: number; // safety multiplier on per-tx fee (default 3x)
1099
+ minBufferLamports?: bigint; // minimum gas buffer (default ~0.01 SOL)
1100
+ balanceOverrideLamports?: bigint; // for tests/custom callers
1101
+ }): Promise<bigint> {
1102
+ this.ensureUser();
1103
+
1104
+ // -------------------------------------------------------------
1105
+ // 1) Current wallet balance (prefer caller override)
1106
+ // -------------------------------------------------------------
1107
+ const balanceLamports: bigint =
1108
+ options?.balanceOverrideLamports ??
1109
+ BigInt(await this.connection.getBalance(this.feePayer, commitment));
1110
+
1111
+ if (balanceLamports <= BigInt(0)) {
1112
+ return BigInt(0);
1113
+ }
1114
+
1115
+ // -------------------------------------------------------------
1116
+ // 2) Estimate gas buffer (using cached single-tx fee)
1117
+ // -------------------------------------------------------------
1118
+ let gasBuffer = BigInt(0);
1119
+
1120
+ try {
1121
+ const singleTxFeeLamports = await this.getSingleTxFeeLamports();
1122
+
1123
+ const txCount = BigInt(options?.txCount ?? 2);
1124
+ const safetyMultiplier = options?.safetyMultiplier ?? 3;
1125
+ const safetyScaled = BigInt(Math.round(safetyMultiplier * 100)); // e.g. 300
1126
+
1127
+ let buf =
1128
+ (singleTxFeeLamports * txCount * safetyScaled) /
1129
+ BigInt(100);
1130
+
1131
+ const defaultMinBufferLamports = BigInt(10_000_000); // ~0.01 SOL
1132
+ const minBufferLamports =
1133
+ options?.minBufferLamports ?? defaultMinBufferLamports;
1134
+
1135
+ if (buf < minBufferLamports) {
1136
+ buf = minBufferLamports;
1137
+ }
1138
+
1139
+ gasBuffer = buf;
1140
+ } catch {
1141
+ // If fee estimation fails, just fall back to "no gas buffer".
1142
+ gasBuffer = BigInt(0);
1143
+ }
1144
+
1145
+ // If gas buffer alone eats the whole balance, we just keep everything.
1146
+ if (balanceLamports <= gasBuffer) {
1147
+ return balanceLamports;
1148
+ }
1149
+
1150
+ const spendable = balanceLamports - gasBuffer;
1151
+
1152
+ // -------------------------------------------------------------
1153
+ // 3) If we can't compute deposit fee, buffer == gasBuffer
1154
+ // -------------------------------------------------------------
1155
+ if (typeof this.getDepositFee !== 'function') {
1156
+ return gasBuffer;
1157
+ }
1158
+
1159
+ // -------------------------------------------------------------
1160
+ // 4) Approximate principal using linear fee model from ONE RPC call
1161
+ //
1162
+ // fee(a) ≈ k * a
1163
+ // want: a + k*a <= spendable → a <= spendable / (1 + k)
1164
+ //
1165
+ // We estimate k from fee(spendable) / spendable.
1166
+ // -------------------------------------------------------------
1167
+ let feeAtSpendable: bigint;
1168
+
1169
+ try {
1170
+ feeAtSpendable = await this.getDepositFee(spendable);
1171
+ } catch {
1172
+ // If protocol fee lookup fails, fall back to gas-only buffer
1173
+ return gasBuffer;
1174
+ }
1175
+
1176
+ // If there is effectively no protocol fee, keep only gas buffer.
1177
+ if (feeAtSpendable <= BigInt(0)) {
1178
+ return gasBuffer;
1179
+ }
1180
+
1181
+ const s = spendable;
1182
+ const f = feeAtSpendable;
1183
+
1184
+ // denom = s + f = s * (1 + k) (since f ≈ k*s)
1185
+ const denom = s + f;
1186
+ if (denom === BigInt(0)) {
1187
+ return gasBuffer;
1188
+ }
1189
+
1190
+ // a ≈ floor( s^2 / (s + f) )
1191
+ let a = (s * s) / denom;
1192
+
1193
+ // Tiny safety haircut to avoid edge off-by-one lamports
1194
+ const fudge = BigInt(10_000); // ≈ 0.00001 SOL
1195
+ let effectivePrincipal =
1196
+ a > fudge ? a - fudge : a;
1197
+
1198
+ if (effectivePrincipal < BigInt(0)) {
1199
+ effectivePrincipal = BigInt(0);
1200
+ }
1201
+
1202
+ const buffer = balanceLamports > effectivePrincipal
1203
+ ? balanceLamports - effectivePrincipal
1204
+ : balanceLamports;
1205
+
1206
+ // Ensure we never under-reserve gas.
1207
+ return buffer < gasBuffer ? gasBuffer : buffer;
242
1208
  }
243
1209
 
244
- async prepareTx(
245
- tx: Transaction,
246
- ): Promise<{ tx: Transaction; blockhash: string; lastValidBlockHeight: number }> {
247
- const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash('confirmed');
1210
+ private cachedTxFee?: { value: bigint; fetchedAt: number };
1211
+ private static readonly FEE_CACHE_TTL_MS = 60_000; // 60s
1212
+
1213
+ private async getSingleTxFeeLamports(): Promise<bigint> {
1214
+ const now = Date.now();
1215
+
1216
+ if (this.cachedTxFee && now - this.cachedTxFee.fetchedAt < SolanaStakingClient.FEE_CACHE_TTL_MS) {
1217
+ return this.cachedTxFee.value;
1218
+ }
1219
+
1220
+ const payer = this.feePayer;
1221
+
1222
+ const dummyIx = SystemProgram.transfer({
1223
+ fromPubkey: payer,
1224
+ toPubkey: payer,
1225
+ lamports: 0,
1226
+ });
1227
+
1228
+ const tx = new Transaction().add(dummyIx);
1229
+ const { blockhash } = await this.connection.getLatestBlockhash(commitment);
248
1230
  tx.recentBlockhash = blockhash;
249
- tx.feePayer = this.solPubKey;
1231
+ tx.feePayer = payer;
250
1232
 
251
- return { tx, blockhash, lastValidBlockHeight };
1233
+ const message = tx.compileMessage();
1234
+ const feeInfo = await this.connection.getFeeForMessage(message, commitment);
1235
+
1236
+ const singleTxFeeLamports = BigInt(feeInfo.value ?? 5000);
1237
+
1238
+ this.cachedTxFee = {
1239
+ value: singleTxFeeLamports,
1240
+ fetchedAt: now,
1241
+ };
1242
+
1243
+ return singleTxFeeLamports;
252
1244
  }
253
- }
254
1245
 
255
- export interface TxResult {
256
- signature: string;
257
- slot: number;
258
- confirmed: boolean;
259
- }
1246
+
1247
+ }