@wireio/stake 0.0.5 → 0.0.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 (504) hide show
  1. package/README.md +204 -15
  2. package/lib/stake.browser.js +69370 -4589
  3. package/lib/stake.browser.js.map +1 -1
  4. package/lib/stake.d.ts +17899 -5512
  5. package/lib/stake.js +70103 -4899
  6. package/lib/stake.js.map +1 -1
  7. package/lib/stake.m.js +69370 -4589
  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/IDepositContract.json +39 -0
  48. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
  49. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IDepositManager.json +64 -0
  50. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
  51. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
  52. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
  53. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20.json +319 -0
  54. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
  55. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +333 -0
  56. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
  57. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IStakingModule.json +344 -0
  58. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
  59. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +129 -0
  60. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
  61. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +66 -0
  62. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
  63. package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/LiqEthCommon.json +10 -0
  64. package/src/assets/ethereum/hoodi/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.dbg.json +4 -0
  65. package/src/assets/ethereum/hoodi/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.json +236 -0
  66. package/src/assets/ethereum/hoodi/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +4 -0
  67. package/src/assets/ethereum/hoodi/liqEth/LiqEthManaged.sol/LiqEthManaged.json +229 -0
  68. package/src/assets/ethereum/hoodi/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.dbg.json +4 -0
  69. package/src/assets/ethereum/hoodi/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.json +957 -0
  70. package/src/assets/ethereum/hoodi/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.dbg.json +4 -0
  71. package/src/assets/ethereum/hoodi/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.json +1020 -0
  72. package/src/assets/ethereum/hoodi/liqEth/Yield.sol/YieldOracle.dbg.json +4 -0
  73. package/src/assets/ethereum/hoodi/liqEth/Yield.sol/YieldOracle.json +1376 -0
  74. package/src/assets/ethereum/hoodi/liqEth/accounting.sol/AccountingV2.dbg.json +4 -0
  75. package/src/assets/ethereum/hoodi/liqEth/accounting.sol/AccountingV2.json +629 -0
  76. package/src/assets/ethereum/hoodi/liqEth/liqEth.sol/LiqEthTokenV2.dbg.json +4 -0
  77. package/src/assets/ethereum/hoodi/liqEth/liqEth.sol/LiqEthTokenV2.json +1323 -0
  78. package/src/assets/ethereum/hoodi/liqEth/stakingModule.sol/StakingModuleV2.dbg.json +4 -0
  79. package/src/assets/ethereum/hoodi/liqEth/stakingModule.sol/StakingModuleV2.json +1779 -0
  80. package/src/assets/ethereum/hoodi/liqEth/v1/DepositManager.sol/DepositManager.dbg.json +4 -0
  81. package/src/assets/ethereum/hoodi/liqEth/v1/DepositManager.sol/DepositManager.json +978 -0
  82. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IAccounting.dbg.json +4 -0
  83. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IAccounting.json +176 -0
  84. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
  85. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositContract.json +39 -0
  86. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
  87. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositManager.json +64 -0
  88. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
  89. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
  90. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
  91. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IRewardsERC20.json +249 -0
  92. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
  93. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.json +263 -0
  94. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
  95. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IStakingModule.json +344 -0
  96. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
  97. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.json +129 -0
  98. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
  99. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.json +66 -0
  100. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
  101. package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.json +10 -0
  102. package/src/assets/ethereum/hoodi/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +4 -0
  103. package/src/assets/ethereum/hoodi/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.json +874 -0
  104. package/src/assets/ethereum/hoodi/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +4 -0
  105. package/src/assets/ethereum/hoodi/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json +937 -0
  106. package/src/assets/ethereum/hoodi/liqEth/v1/accounting.sol/Accounting.dbg.json +4 -0
  107. package/src/assets/ethereum/hoodi/liqEth/v1/accounting.sol/Accounting.json +548 -0
  108. package/src/assets/ethereum/hoodi/liqEth/v1/liqEth.sol/LiqEthToken.dbg.json +4 -0
  109. package/src/assets/ethereum/hoodi/liqEth/v1/liqEth.sol/LiqEthToken.json +1233 -0
  110. package/src/assets/ethereum/hoodi/liqEth/v1/stakingModule.sol/StakingModule.dbg.json +4 -0
  111. package/src/assets/ethereum/hoodi/liqEth/v1/stakingModule.sol/StakingModule.json +1772 -0
  112. package/src/assets/ethereum/hoodi/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +4 -0
  113. package/src/assets/ethereum/hoodi/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +973 -0
  114. package/src/assets/ethereum/hoodi/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +4 -0
  115. package/src/assets/ethereum/hoodi/liqEth/withdrawalVault.sol/Uint64BE.json +10 -0
  116. package/src/assets/ethereum/hoodi/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +4 -0
  117. package/src/assets/ethereum/hoodi/liqEth/withdrawalVault.sol/WithdrawalVault.json +441 -0
  118. package/src/assets/ethereum/hoodi/outpost/BAR.sol/BAR.dbg.json +4 -0
  119. package/src/assets/ethereum/hoodi/outpost/BAR.sol/BAR.json +1111 -0
  120. package/src/assets/ethereum/hoodi/outpost/Depositor.sol/Depositor.dbg.json +4 -0
  121. package/src/assets/ethereum/hoodi/outpost/Depositor.sol/Depositor.json +1696 -0
  122. package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +4 -0
  123. package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +122 -0
  124. package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +4 -0
  125. package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +274 -0
  126. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeDepositCodec.dbg.json +4 -0
  127. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeDepositCodec.json +10 -0
  128. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawCodec.dbg.json +4 -0
  129. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawCodec.json +10 -0
  130. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawConfirmCodec.dbg.json +4 -0
  131. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawConfirmCodec.json +10 -0
  132. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/InstaswapBridgeAttestationTypeLib.dbg.json +4 -0
  133. package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/InstaswapBridgeAttestationTypeLib.json +10 -0
  134. package/src/assets/ethereum/hoodi/outpost/LiqEthBridge.sol/LiqEthBridge.dbg.json +4 -0
  135. package/src/assets/ethereum/hoodi/outpost/LiqEthBridge.sol/LiqEthBridge.json +1044 -0
  136. package/src/assets/ethereum/hoodi/outpost/OPP.sol/OPP.dbg.json +4 -0
  137. package/src/assets/ethereum/hoodi/outpost/OPP.sol/OPP.json +1055 -0
  138. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPP.dbg.json +4 -0
  139. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPP.json +81 -0
  140. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +4 -0
  141. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPEndpoint.json +29 -0
  142. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPInbound.dbg.json +4 -0
  143. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPInbound.json +330 -0
  144. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +4 -0
  145. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPReceiver.json +29 -0
  146. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPSender.dbg.json +4 -0
  147. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPSender.json +41 -0
  148. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/OPPCommon.dbg.json +4 -0
  149. package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/OPPCommon.json +287 -0
  150. package/src/assets/ethereum/hoodi/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +4 -0
  151. package/src/assets/ethereum/hoodi/outpost/OPPEndpoint.sol/OPPEndpoint.json +294 -0
  152. package/src/assets/ethereum/hoodi/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +4 -0
  153. package/src/assets/ethereum/hoodi/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.json +415 -0
  154. package/src/assets/ethereum/hoodi/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +4 -0
  155. package/src/assets/ethereum/hoodi/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.json +399 -0
  156. package/src/assets/ethereum/hoodi/outpost/OPPErrors.sol/OPPErrors.dbg.json +4 -0
  157. package/src/assets/ethereum/hoodi/outpost/OPPErrors.sol/OPPErrors.json +245 -0
  158. package/src/assets/ethereum/hoodi/outpost/OPPInbound.sol/OPPInbound.dbg.json +4 -0
  159. package/src/assets/ethereum/hoodi/outpost/OPPInbound.sol/OPPInbound.json +1204 -0
  160. package/src/assets/ethereum/hoodi/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +4 -0
  161. package/src/assets/ethereum/hoodi/outpost/OPPReceiver.sol/OPPReceiver.json +312 -0
  162. package/src/assets/ethereum/hoodi/outpost/OPPSender.sol/OPPSender.dbg.json +4 -0
  163. package/src/assets/ethereum/hoodi/outpost/OPPSender.sol/OPPSender.json +324 -0
  164. package/src/assets/ethereum/hoodi/outpost/OperatorRegistry.sol/OperatorRegistry.dbg.json +4 -0
  165. package/src/assets/ethereum/hoodi/outpost/OperatorRegistry.sol/OperatorRegistry.json +1068 -0
  166. package/src/assets/ethereum/hoodi/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +4 -0
  167. package/src/assets/ethereum/hoodi/outpost/OutpostErrors.sol/OutpostErrors.json +211 -0
  168. package/src/assets/ethereum/hoodi/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +4 -0
  169. package/src/assets/ethereum/hoodi/outpost/OutpostManaged.sol/OutpostManaged.json +229 -0
  170. package/src/assets/ethereum/hoodi/outpost/OutpostManager.sol/OutpostManager.dbg.json +4 -0
  171. package/src/assets/ethereum/hoodi/outpost/OutpostManager.sol/OutpostManager.json +751 -0
  172. package/src/assets/ethereum/hoodi/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +4 -0
  173. package/src/assets/ethereum/hoodi/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json +1432 -0
  174. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +4 -0
  175. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostManager.json +130 -0
  176. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +4 -0
  177. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +29 -0
  178. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +4 -0
  179. package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.json +141 -0
  180. package/src/assets/ethereum/hoodi/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +4 -0
  181. package/src/assets/ethereum/hoodi/outpost/OutpostOwnable.sol/OutpostOwnable.json +213 -0
  182. package/src/assets/ethereum/hoodi/outpost/OutpostReserve.sol/OutpostReserve.dbg.json +4 -0
  183. package/src/assets/ethereum/hoodi/outpost/OutpostReserve.sol/OutpostReserve.json +888 -0
  184. package/src/assets/ethereum/hoodi/outpost/Pool.sol/Pool.dbg.json +4 -0
  185. package/src/assets/ethereum/hoodi/outpost/Pool.sol/Pool.json +659 -0
  186. package/src/assets/ethereum/hoodi/outpost/Pretoken.sol/Pretoken.dbg.json +4 -0
  187. package/src/assets/ethereum/hoodi/outpost/Pretoken.sol/Pretoken.json +1393 -0
  188. package/src/assets/ethereum/hoodi/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +4 -0
  189. package/src/assets/ethereum/hoodi/outpost/ReceiptNFT.sol/ReceiptNFT.json +1738 -0
  190. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapConfirmCodec.dbg.json +4 -0
  191. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapConfirmCodec.json +10 -0
  192. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapFailedCodec.dbg.json +4 -0
  193. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapFailedCodec.json +10 -0
  194. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapRequestCodec.dbg.json +4 -0
  195. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapRequestCodec.json +10 -0
  196. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapSettlementCodec.dbg.json +4 -0
  197. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapSettlementCodec.json +10 -0
  198. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitConfirmCodec.dbg.json +4 -0
  199. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitConfirmCodec.json +10 -0
  200. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitFailedCodec.dbg.json +4 -0
  201. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitFailedCodec.json +10 -0
  202. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitRequestCodec.dbg.json +4 -0
  203. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitRequestCodec.json +10 -0
  204. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalStakeDeltaCodec.dbg.json +4 -0
  205. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalStakeDeltaCodec.json +10 -0
  206. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAssetCodec.dbg.json +4 -0
  207. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAssetCodec.json +10 -0
  208. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestationTypeLib.dbg.json +4 -0
  209. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestationTypeLib.json +10 -0
  210. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestations.dbg.json +4 -0
  211. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestations.json +1437 -0
  212. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/YieldDepositCodec.dbg.json +4 -0
  213. package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/YieldDepositCodec.json +10 -0
  214. package/src/assets/ethereum/hoodi/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +4 -0
  215. package/src/assets/ethereum/hoodi/outpost/interfaces/IPretoken.sol/IPretoken.json +29 -0
  216. package/src/assets/ethereum/hoodi/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +4 -0
  217. package/src/assets/ethereum/hoodi/outpost/interfaces/IWarrant.sol/IWarrant.json +29 -0
  218. package/src/assets/ethereum/hoodi/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +4 -0
  219. package/src/assets/ethereum/hoodi/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +858 -0
  220. package/src/assets/ethereum/hoodi/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +4 -0
  221. package/src/assets/ethereum/hoodi/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.json +30 -0
  222. package/src/assets/ethereum/hoodi/token/ERC1155Token.sol/ERC1155Token.dbg.json +4 -0
  223. package/src/assets/ethereum/hoodi/token/ERC1155Token.sol/ERC1155Token.json +472 -0
  224. package/src/assets/ethereum/hoodi/token/ERC20Token.sol/ERC20Token.dbg.json +4 -0
  225. package/src/assets/ethereum/hoodi/token/ERC20Token.sol/ERC20Token.json +330 -0
  226. package/src/assets/ethereum/hoodi/token/ERC721Token.sol/ERC721Token.dbg.json +4 -0
  227. package/src/assets/ethereum/hoodi/token/ERC721Token.sol/ERC721Token.json +449 -0
  228. package/src/assets/ethereum/hoodi/token/Eman1155.sol/Eman1155.dbg.json +4 -0
  229. package/src/assets/ethereum/hoodi/token/Eman1155.sol/Eman1155.json +560 -0
  230. package/src/assets/ethereum/hoodi/token/Eman20.sol/Eman20.dbg.json +4 -0
  231. package/src/assets/ethereum/hoodi/token/Eman20.sol/Eman20.json +460 -0
  232. package/src/assets/ethereum/hoodi/token/Eman721.sol/Eman721.dbg.json +4 -0
  233. package/src/assets/ethereum/hoodi/token/Eman721.sol/Eman721.json +624 -0
  234. package/src/assets/ethereum/mainnet/common/Base58.sol/Base58.dbg.json +4 -0
  235. package/src/assets/ethereum/mainnet/common/Base58.sol/Base58.json +164 -0
  236. package/src/assets/ethereum/mainnet/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.dbg.json +4 -0
  237. package/src/assets/ethereum/mainnet/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.json +76 -0
  238. package/src/assets/ethereum/mainnet/common/RestrictedCallers.sol/RestrictedCallers.dbg.json +4 -0
  239. package/src/assets/ethereum/mainnet/common/RestrictedCallers.sol/RestrictedCallers.json +10 -0
  240. package/src/assets/ethereum/mainnet/common/iodata.sol/iodata.dbg.json +4 -0
  241. package/src/assets/ethereum/mainnet/common/iodata.sol/iodata.json +618 -0
  242. package/src/assets/ethereum/mainnet/common/iodata_util.sol/iodata_util.dbg.json +4 -0
  243. package/src/assets/ethereum/mainnet/common/iodata_util.sol/iodata_util.json +40 -0
  244. package/src/assets/ethereum/mainnet/common/sysio_data.sol/sysio_data.dbg.json +4 -0
  245. package/src/assets/ethereum/mainnet/common/sysio_data.sol/sysio_data.json +10 -0
  246. package/src/assets/ethereum/mainnet/common/sysio_errors.sol/sysio_errors.dbg.json +4 -0
  247. package/src/assets/ethereum/mainnet/common/sysio_errors.sol/sysio_errors.json +10 -0
  248. package/src/assets/ethereum/mainnet/common/sysio_merkle.sol/sysio_merkle.dbg.json +4 -0
  249. package/src/assets/ethereum/mainnet/common/sysio_merkle.sol/sysio_merkle.json +233 -0
  250. package/src/assets/ethereum/mainnet/common/sysio_name.sol/sysio_name.dbg.json +4 -0
  251. package/src/assets/ethereum/mainnet/common/sysio_name.sol/sysio_name.json +49 -0
  252. package/src/assets/ethereum/mainnet/common/sysio_pubkey.sol/sysio_pubkey.dbg.json +4 -0
  253. package/src/assets/ethereum/mainnet/common/sysio_pubkey.sol/sysio_pubkey.json +64 -0
  254. package/src/assets/ethereum/mainnet/common/sysio_read.sol/sysio_read.dbg.json +4 -0
  255. package/src/assets/ethereum/mainnet/common/sysio_read.sol/sysio_read.json +1458 -0
  256. package/src/assets/ethereum/mainnet/common/sysio_tester.sol/SysioTester.dbg.json +4 -0
  257. package/src/assets/ethereum/mainnet/common/sysio_tester.sol/SysioTester.json +1532 -0
  258. package/src/assets/ethereum/mainnet/common/sysio_verify.sol/sysio_verify.dbg.json +4 -0
  259. package/src/assets/ethereum/mainnet/common/sysio_verify.sol/sysio_verify.json +1525 -0
  260. package/src/assets/ethereum/mainnet/common/sysio_write.sol/sysio_write.dbg.json +4 -0
  261. package/src/assets/ethereum/mainnet/common/sysio_write.sol/sysio_write.json +1076 -0
  262. package/src/assets/ethereum/mainnet/liqEth/BeaconState.sol/BeaconState.dbg.json +4 -0
  263. package/src/assets/ethereum/mainnet/liqEth/BeaconState.sol/BeaconState.json +807 -0
  264. package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/DepositManagerV2.dbg.json +4 -0
  265. package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/DepositManagerV2.json +1004 -0
  266. package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/IStakingModuleBondLocker.dbg.json +4 -0
  267. package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/IStakingModuleBondLocker.json +29 -0
  268. package/src/assets/ethereum/mainnet/liqEth/KeyBondManager.sol/KeyBondManager.dbg.json +4 -0
  269. package/src/assets/ethereum/mainnet/liqEth/KeyBondManager.sol/KeyBondManager.json +897 -0
  270. package/src/assets/ethereum/mainnet/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +4 -0
  271. package/src/assets/ethereum/mainnet/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +1289 -0
  272. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
  273. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositContract.json +39 -0
  274. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
  275. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositManager.json +64 -0
  276. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IKeyBondManager.dbg.json +4 -0
  277. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IKeyBondManager.json +189 -0
  278. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
  279. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
  280. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
  281. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20.json +319 -0
  282. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
  283. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +333 -0
  284. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
  285. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IStakingModule.json +279 -0
  286. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
  287. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +129 -0
  288. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
  289. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +66 -0
  290. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
  291. package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/LiqEthCommon.json +10 -0
  292. package/src/assets/ethereum/mainnet/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.dbg.json +4 -0
  293. package/src/assets/ethereum/mainnet/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.json +236 -0
  294. package/src/assets/ethereum/mainnet/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +4 -0
  295. package/src/assets/ethereum/mainnet/liqEth/LiqEthManaged.sol/LiqEthManaged.json +229 -0
  296. package/src/assets/ethereum/mainnet/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.dbg.json +4 -0
  297. package/src/assets/ethereum/mainnet/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.json +957 -0
  298. package/src/assets/ethereum/mainnet/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.dbg.json +4 -0
  299. package/src/assets/ethereum/mainnet/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.json +1020 -0
  300. package/src/assets/ethereum/mainnet/liqEth/StakingLib.sol/StakingLib.dbg.json +4 -0
  301. package/src/assets/ethereum/mainnet/liqEth/StakingLib.sol/StakingLib.json +89 -0
  302. package/src/assets/ethereum/mainnet/liqEth/Yield.sol/YieldOracle.dbg.json +4 -0
  303. package/src/assets/ethereum/mainnet/liqEth/Yield.sol/YieldOracle.json +1376 -0
  304. package/src/assets/ethereum/mainnet/liqEth/liqEth.sol/LiqEthTokenV2.dbg.json +4 -0
  305. package/src/assets/ethereum/mainnet/liqEth/liqEth.sol/LiqEthTokenV2.json +1323 -0
  306. package/src/assets/ethereum/mainnet/liqEth/stakingModule.sol/StakingModuleV2.dbg.json +4 -0
  307. package/src/assets/ethereum/mainnet/liqEth/stakingModule.sol/StakingModuleV2.json +1896 -0
  308. package/src/assets/ethereum/mainnet/liqEth/v1/DepositManager.sol/DepositManager.dbg.json +4 -0
  309. package/src/assets/ethereum/mainnet/liqEth/v1/DepositManager.sol/DepositManager.json +978 -0
  310. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IAccounting.dbg.json +4 -0
  311. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IAccounting.json +176 -0
  312. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
  313. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositContract.json +39 -0
  314. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
  315. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositManager.json +64 -0
  316. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
  317. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
  318. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
  319. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20.json +249 -0
  320. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
  321. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.json +263 -0
  322. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
  323. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IStakingModule.json +344 -0
  324. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
  325. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.json +129 -0
  326. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
  327. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.json +66 -0
  328. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
  329. package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.json +10 -0
  330. package/src/assets/ethereum/mainnet/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +4 -0
  331. package/src/assets/ethereum/mainnet/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.json +874 -0
  332. package/src/assets/ethereum/mainnet/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +4 -0
  333. package/src/assets/ethereum/mainnet/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json +937 -0
  334. package/src/assets/ethereum/mainnet/liqEth/v1/accounting.sol/Accounting.dbg.json +4 -0
  335. package/src/assets/ethereum/mainnet/liqEth/v1/accounting.sol/Accounting.json +542 -0
  336. package/src/assets/ethereum/mainnet/liqEth/v1/liqEth.sol/LiqEthToken.dbg.json +4 -0
  337. package/src/assets/ethereum/mainnet/liqEth/v1/liqEth.sol/LiqEthToken.json +1233 -0
  338. package/src/assets/ethereum/mainnet/liqEth/v1/stakingModule.sol/StakingModule.dbg.json +4 -0
  339. package/src/assets/ethereum/mainnet/liqEth/v1/stakingModule.sol/StakingModule.json +1772 -0
  340. package/src/assets/ethereum/mainnet/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +4 -0
  341. package/src/assets/ethereum/mainnet/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +973 -0
  342. package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +4 -0
  343. package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/Uint64BE.json +10 -0
  344. package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +4 -0
  345. package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/WithdrawalVault.json +441 -0
  346. package/src/assets/ethereum/mainnet/outpost/BAR.sol/BARV2.dbg.json +4 -0
  347. package/src/assets/ethereum/mainnet/outpost/BAR.sol/BARV2.json +1915 -0
  348. package/src/assets/ethereum/mainnet/outpost/Depositor.sol/DepositorV2.dbg.json +4 -0
  349. package/src/assets/ethereum/mainnet/outpost/Depositor.sol/DepositorV2.json +1845 -0
  350. package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +4 -0
  351. package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +122 -0
  352. package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +4 -0
  353. package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +551 -0
  354. package/src/assets/ethereum/mainnet/outpost/OPP.sol/OPP.dbg.json +4 -0
  355. package/src/assets/ethereum/mainnet/outpost/OPP.sol/OPP.json +948 -0
  356. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPP.dbg.json +4 -0
  357. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPP.json +88 -0
  358. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +4 -0
  359. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPEndpoint.json +29 -0
  360. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPInbound.dbg.json +4 -0
  361. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPInbound.json +194 -0
  362. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +4 -0
  363. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPReceiver.json +29 -0
  364. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPSender.dbg.json +4 -0
  365. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPSender.json +36 -0
  366. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/OPPCommon.dbg.json +4 -0
  367. package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/OPPCommon.json +199 -0
  368. package/src/assets/ethereum/mainnet/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +4 -0
  369. package/src/assets/ethereum/mainnet/outpost/OPPEndpoint.sol/OPPEndpoint.json +273 -0
  370. package/src/assets/ethereum/mainnet/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +4 -0
  371. package/src/assets/ethereum/mainnet/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.json +394 -0
  372. package/src/assets/ethereum/mainnet/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +4 -0
  373. package/src/assets/ethereum/mainnet/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.json +378 -0
  374. package/src/assets/ethereum/mainnet/outpost/OPPErrors.sol/OPPErrors.dbg.json +4 -0
  375. package/src/assets/ethereum/mainnet/outpost/OPPErrors.sol/OPPErrors.json +224 -0
  376. package/src/assets/ethereum/mainnet/outpost/OPPInbound.sol/OPPInbound.dbg.json +4 -0
  377. package/src/assets/ethereum/mainnet/outpost/OPPInbound.sol/OPPInbound.json +1010 -0
  378. package/src/assets/ethereum/mainnet/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +4 -0
  379. package/src/assets/ethereum/mainnet/outpost/OPPReceiver.sol/OPPReceiver.json +291 -0
  380. package/src/assets/ethereum/mainnet/outpost/OPPSender.sol/OPPSender.dbg.json +4 -0
  381. package/src/assets/ethereum/mainnet/outpost/OPPSender.sol/OPPSender.json +298 -0
  382. package/src/assets/ethereum/mainnet/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +4 -0
  383. package/src/assets/ethereum/mainnet/outpost/OutpostErrors.sol/OutpostErrors.json +488 -0
  384. package/src/assets/ethereum/mainnet/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +4 -0
  385. package/src/assets/ethereum/mainnet/outpost/OutpostManaged.sol/OutpostManaged.json +229 -0
  386. package/src/assets/ethereum/mainnet/outpost/OutpostManager.sol/OutpostManagerV2.dbg.json +4 -0
  387. package/src/assets/ethereum/mainnet/outpost/OutpostManager.sol/OutpostManagerV2.json +737 -0
  388. package/src/assets/ethereum/mainnet/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +4 -0
  389. package/src/assets/ethereum/mainnet/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json +1432 -0
  390. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +4 -0
  391. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostManager.json +130 -0
  392. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +4 -0
  393. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +29 -0
  394. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +4 -0
  395. package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.json +141 -0
  396. package/src/assets/ethereum/mainnet/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +4 -0
  397. package/src/assets/ethereum/mainnet/outpost/OutpostOwnable.sol/OutpostOwnable.json +213 -0
  398. package/src/assets/ethereum/mainnet/outpost/Pool.sol/PoolV2.dbg.json +4 -0
  399. package/src/assets/ethereum/mainnet/outpost/Pool.sol/PoolV2.json +943 -0
  400. package/src/assets/ethereum/mainnet/outpost/Pretoken.sol/PretokenV2.dbg.json +4 -0
  401. package/src/assets/ethereum/mainnet/outpost/Pretoken.sol/PretokenV2.json +1703 -0
  402. package/src/assets/ethereum/mainnet/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +4 -0
  403. package/src/assets/ethereum/mainnet/outpost/ReceiptNFT.sol/ReceiptNFT.json +2015 -0
  404. package/src/assets/ethereum/mainnet/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +4 -0
  405. package/src/assets/ethereum/mainnet/outpost/interfaces/IPretoken.sol/IPretoken.json +29 -0
  406. package/src/assets/ethereum/mainnet/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +4 -0
  407. package/src/assets/ethereum/mainnet/outpost/interfaces/IWarrant.sol/IWarrant.json +29 -0
  408. package/src/assets/ethereum/mainnet/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +4 -0
  409. package/src/assets/ethereum/mainnet/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +858 -0
  410. package/src/assets/ethereum/mainnet/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +4 -0
  411. package/src/assets/ethereum/mainnet/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.json +30 -0
  412. package/src/assets/ethereum/mainnet/outpost/v1/BAR.sol/BAR.dbg.json +4 -0
  413. package/src/assets/ethereum/mainnet/outpost/v1/BAR.sol/BAR.json +1871 -0
  414. package/src/assets/ethereum/mainnet/outpost/v1/Depositor.sol/Depositor.dbg.json +4 -0
  415. package/src/assets/ethereum/mainnet/outpost/v1/Depositor.sol/Depositor.json +1653 -0
  416. package/src/assets/ethereum/mainnet/outpost/v1/OutpostManager.sol/OutpostManager.dbg.json +4 -0
  417. package/src/assets/ethereum/mainnet/outpost/v1/OutpostManager.sol/OutpostManager.json +730 -0
  418. package/src/assets/ethereum/mainnet/outpost/v1/Pool.sol/Pool.dbg.json +4 -0
  419. package/src/assets/ethereum/mainnet/outpost/v1/Pool.sol/Pool.json +936 -0
  420. package/src/assets/ethereum/mainnet/outpost/v1/Pretoken.sol/Pretoken.dbg.json +4 -0
  421. package/src/assets/ethereum/mainnet/outpost/v1/Pretoken.sol/Pretoken.json +1665 -0
  422. package/src/assets/ethereum/mainnet/token/ERC1155Token.sol/ERC1155Token.dbg.json +4 -0
  423. package/src/assets/ethereum/mainnet/token/ERC1155Token.sol/ERC1155Token.json +472 -0
  424. package/src/assets/ethereum/mainnet/token/ERC20Token.sol/ERC20Token.dbg.json +4 -0
  425. package/src/assets/ethereum/mainnet/token/ERC20Token.sol/ERC20Token.json +330 -0
  426. package/src/assets/ethereum/mainnet/token/ERC721Token.sol/ERC721Token.dbg.json +4 -0
  427. package/src/assets/ethereum/mainnet/token/ERC721Token.sol/ERC721Token.json +449 -0
  428. package/src/assets/solana/devnet/idl/liqsol_core.json +8546 -0
  429. package/src/assets/solana/devnet/idl/liqsol_token.json +217 -0
  430. package/src/assets/solana/devnet/idl/transfer_hook.json +490 -0
  431. package/src/assets/solana/devnet/idl/validator_leaderboard.json +735 -0
  432. package/src/assets/solana/devnet/types/liqsol_core.ts +8552 -0
  433. package/src/assets/solana/devnet/types/liqsol_token.ts +223 -0
  434. package/src/assets/solana/devnet/types/transfer_hook.ts +496 -0
  435. package/src/assets/solana/devnet/types/validator_leaderboard.ts +741 -0
  436. package/src/assets/solana/mainnet/idl/liqsol_core.json +6678 -0
  437. package/src/assets/solana/mainnet/idl/liqsol_token.json +217 -0
  438. package/src/assets/solana/mainnet/idl/transfer_hook.json +479 -0
  439. package/src/assets/solana/mainnet/idl/validator_leaderboard.json +574 -0
  440. package/src/assets/solana/mainnet/types/liqsol_core.ts +6684 -0
  441. package/src/assets/solana/mainnet/types/liqsol_token.ts +223 -0
  442. package/src/assets/solana/mainnet/types/transfer_hook.ts +485 -0
  443. package/src/assets/solana/mainnet/types/validator_leaderboard.ts +580 -0
  444. package/src/assets/solana/realdevnet/idl/liqsol_core.json +7112 -0
  445. package/src/assets/solana/realdevnet/idl/liqsol_token.json +217 -0
  446. package/src/assets/solana/realdevnet/idl/transfer_hook.json +479 -0
  447. package/src/assets/solana/realdevnet/idl/validator_leaderboard.json +735 -0
  448. package/src/assets/solana/realdevnet/types/liqsol_core.ts +7118 -0
  449. package/src/assets/solana/realdevnet/types/liqsol_token.ts +223 -0
  450. package/src/assets/solana/realdevnet/types/transfer_hook.ts +485 -0
  451. package/src/assets/solana/realdevnet/types/validator_leaderboard.ts +741 -0
  452. package/src/index.ts +7 -8
  453. package/src/networks/ethereum/clients/convert.client.ts +221 -0
  454. package/src/networks/ethereum/clients/opp.client.ts +389 -0
  455. package/src/networks/ethereum/clients/pretoken.client.ts +165 -0
  456. package/src/networks/ethereum/clients/receipt.client.ts +199 -0
  457. package/src/networks/ethereum/clients/stake.client.ts +203 -0
  458. package/src/networks/ethereum/clients/validator.client.ts +61 -0
  459. package/src/networks/ethereum/contract.ts +438 -58
  460. package/src/networks/ethereum/ethereum.ts +591 -51
  461. package/src/networks/ethereum/types.ts +138 -2
  462. package/src/networks/ethereum/utils.ts +340 -0
  463. package/src/networks/solana/clients/convert.client.ts +341 -0
  464. package/src/networks/solana/clients/distribution.client.ts +304 -176
  465. package/src/networks/solana/clients/leaderboard.client.ts +85 -163
  466. package/src/networks/solana/clients/outpost.client.ts +325 -0
  467. package/src/networks/solana/clients/token.client.ts +210 -0
  468. package/src/networks/solana/constants.ts +152 -69
  469. package/src/networks/solana/program.ts +397 -102
  470. package/src/networks/solana/solana.ts +1208 -68
  471. package/src/networks/solana/types.ts +757 -0
  472. package/src/networks/solana/utils.ts +542 -93
  473. package/src/scripts/fetch-artifacts.sh +24 -0
  474. package/src/scripts/tsconfig.json +17 -0
  475. package/src/staker.ts +85 -0
  476. package/src/types.ts +364 -0
  477. package/src/assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.dbg.json +0 -4
  478. package/src/assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.json +0 -472
  479. package/src/assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.dbg.json +0 -4
  480. package/src/assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.json +0 -330
  481. package/src/assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.dbg.json +0 -4
  482. package/src/assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.json +0 -449
  483. package/src/assets/solana/idl/deposit.json +0 -260
  484. package/src/assets/solana/idl/distribution.json +0 -736
  485. package/src/assets/solana/idl/liq_sol_token.json +0 -275
  486. package/src/assets/solana/idl/stake_controller.json +0 -1788
  487. package/src/assets/solana/idl/stake_registry.json +0 -435
  488. package/src/assets/solana/idl/treasury.json +0 -336
  489. package/src/assets/solana/idl/validator_leaderboard.json +0 -528
  490. package/src/assets/solana/idl/validator_registry.json +0 -418
  491. package/src/assets/solana/idl/yield_oracle.json +0 -32
  492. package/src/assets/solana/types/deposit.ts +0 -266
  493. package/src/assets/solana/types/distribution.ts +0 -742
  494. package/src/assets/solana/types/liq_sol_token.ts +0 -281
  495. package/src/assets/solana/types/stake_controller.ts +0 -1794
  496. package/src/assets/solana/types/stake_registry.ts +0 -441
  497. package/src/assets/solana/types/treasury.ts +0 -342
  498. package/src/assets/solana/types/validator_leaderboard.ts +0 -534
  499. package/src/assets/solana/types/validator_registry.ts +0 -424
  500. package/src/assets/solana/types/yield_oracle.ts +0 -38
  501. package/src/networks/solana/clients/deposit.client.ts +0 -178
  502. package/src/staker/staker.ts +0 -56
  503. package/src/staker/types.ts +0 -40
  504. package/src/utils.ts +0 -9
@@ -1,107 +1,1247 @@
1
1
  import {
2
+ AddressLookupTableAccount,
3
+ Commitment,
4
+ ComputeBudgetProgram,
2
5
  Connection,
6
+ ConnectionConfig,
7
+ PerfSample,
8
+ SendTransactionError,
3
9
  PublicKey as SolPubKey,
10
+ SystemProgram,
4
11
  Transaction,
5
- VersionedTransaction,
12
+ TransactionInstruction,
13
+ TransactionMessage,
6
14
  TransactionSignature,
7
- Commitment,
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 { IStakingClient, SolanaTransaction, StakerConfig } from '../../staker/types';
12
- import { KeyType, PublicKey } from '@wireio/core';
13
- import { DepositClient } from './clients/deposit.client';
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';
36
+
37
+ import {
38
+ IStakingClient,
39
+ Portfolio,
40
+ SquadsXConfig,
41
+ StakerConfig,
42
+ TrancheSnapshot,
43
+ } from '../../types';
44
+
45
+ import { ConvertClient } from './clients/convert.client';
14
46
  import { DistributionClient } from './clients/distribution.client';
15
- import { ValidatorLeaderboardClient } from './clients/leaderboard.client';
47
+ import { LeaderboardClient } from './clients/leaderboard.client';
48
+ import { OutpostClient } from './clients/outpost.client';
49
+ import { TokenClient } from './clients/token.client';
50
+
51
+ import {
52
+ DEFAULT_AVERAGE_PAY_RATE,
53
+ INDEX_SCALE,
54
+ PAY_RATE_SCALE_FACTOR,
55
+ } from './constants';
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';
16
62
 
17
63
  const commitment: Commitment = 'confirmed';
18
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
+ */
19
78
  export class SolanaStakingClient implements IStakingClient {
20
- public pubKey: PublicKey;
79
+ public pubKey?: PublicKey; // Wire ED key (optional → read-only)
21
80
  public connection: Connection;
22
81
  public anchor: AnchorProvider;
23
82
 
24
- private depositClient: DepositClient;
25
- private distributionClient: DistributionClient;
26
- private leaderboardClient: ValidatorLeaderboardClient;
83
+ public convertClient: ConvertClient;
84
+ public distributionClient: DistributionClient;
85
+ public leaderboardClient: LeaderboardClient;
86
+ public outpostClient: OutpostClient;
87
+ public tokenClient: TokenClient;
88
+ public program: SolanaProgramService
27
89
 
28
- balanceNative: number = 0;
29
- balanceLiquid: number = 0;
90
+ private smartAccount?: SolPubKey; // PDA (off-curve)
91
+ private signer?: SolPubKey; // on-curve signer
30
92
 
31
93
  get solPubKey(): SolPubKey {
94
+ if (!this.pubKey) throw new Error('pubKey is undefined');
32
95
  return new SolPubKey(this.pubKey.data.array);
33
96
  }
34
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
+ }
113
+
35
114
  constructor(private config: StakerConfig) {
36
- // 1) unwrap & validate wallet adapter
37
- const adapter = config.provider as BaseSignerWalletAdapter;
38
- if (!adapter.publicKey) {
39
- throw new Error('Solana wallet adapter not connected');
40
- }
41
-
42
- // 2) sanity‐check wire ↔ solana pubkey
43
- const solPub = adapter.publicKey;
44
- const wirePub = new PublicKey(KeyType.ED, solPub.toBytes());
45
- if (!wirePub.equals(config.pubKey)) {
46
- throw new Error('Passed-in pubKey doesn\'t match adapter.publicKey');
47
- }
48
-
49
- this.pubKey = wirePub;
50
- this.connection = new Connection(config.network.rpcUrls[0], commitment);
51
- this.setBalances();
52
-
53
- const anchorWallet = {
54
- publicKey: solPub,
55
- async signTransaction<T extends SolanaTransaction>(tx: T): Promise<T> {
56
- return adapter.signTransaction(tx);
57
- },
58
- async signAllTransactions<T extends SolanaTransaction>(txs: T[]): Promise<T[]> {
59
- return Promise.all(txs.map((tx) => adapter.signTransaction(tx)));
60
- },
61
- };
115
+ const adapter = config.provider as BaseSignerWalletAdapter | undefined;
62
116
 
63
- this.anchor = new AnchorProvider(
64
- this.connection,
65
- anchorWallet,
66
- { commitment }
67
- );
117
+ if (!config.network.rpcUrls.length) {
118
+ throw new Error('No RPC URLs provided');
119
+ }
120
+
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));
130
+ }
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
+ // -------------------------------------------------------------
162
+ const opts: ConnectionConfig = { commitment };
163
+ if (
164
+ config.network.rpcUrls.length > 1 &&
165
+ config.network.rpcUrls[1].startsWith('ws')
166
+ ) {
167
+ opts.wsEndpoint = config.network.rpcUrls[1];
168
+ }
169
+
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
+
207
+ this.connection = new Connection(config.network.rpcUrls[0], opts);
208
+ this.anchor = new AnchorProvider(this.connection, anchorWallet, {
209
+ commitment,
210
+ });
211
+
212
+ this.program = new SolanaProgramService(this.anchor, config.network.chainId as SolChainID);
213
+
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.');
233
+
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
+ }
338
+ }
339
+
340
+ /**
341
+ * Unstake liqSOL from Outpost (pool → liqSOL) via liqsol_core::desynd.
342
+ */
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.');
68
347
 
69
- // 4) staking clients
70
- this.depositClient = new DepositClient(this.anchor);
71
- this.distributionClient = new DistributionClient(this.anchor);
72
- this.leaderboardClient = new ValidatorLeaderboardClient(this.anchor);
348
+ try {
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
+ }
73
358
  }
74
359
 
75
360
  /**
76
- * Update the native and liquid balances.
77
- * @returns The updated balances.
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).
78
365
  */
79
- async setBalances() {
80
- this.balanceNative = await this.connection.getBalance(this.solPubKey);
81
- this.balanceLiquid = 0; // TODO fetch liq balance
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.');
82
370
 
83
- return { native: this.balanceNative, liquid: this.balanceLiquid };
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
+ }
84
441
  }
85
442
 
86
443
  /**
87
- * Deposit funds into the staking pool.
88
- * @param lamports The amount to deposit (in lamports).
89
- * @returns The transaction signature.
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
90
451
  */
91
- async deposit(lamports: number): Promise<string> {
92
- const tx = await this.depositClient.buildDepositTx(
93
- this.solPubKey,
94
- lamports,
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
+
462
+ const userLiqsolAta = getAssociatedTokenAddressSync(
463
+ liqsolMint,
464
+ user,
465
+ true,
466
+ TOKEN_2022_PROGRAM_ID,
467
+ ASSOCIATED_TOKEN_PROGRAM_ID,
468
+ );
469
+
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)),
481
+ ]);
482
+
483
+ const LIQSOL_DECIMALS = 9;
484
+
485
+ const actualAmountStr = actualBalResp?.value?.amount ?? '0';
486
+
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';
526
+
527
+ const stakedLiqsol = BigInt(stakedLiqsolStr);
528
+ const currentIndex = BigInt(currentIndexStr);
529
+ const totalShares = BigInt(totalSharesStr);
530
+ const userShares = BigInt(userSharesStr);
531
+
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 {
545
+ native: {
546
+ amount: BigInt(nativeLamports),
547
+ symbol: 'SOL',
548
+ decimals: 9,
549
+ },
550
+ liq: {
551
+ amount: BigInt(actualAmountStr),
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,
561
+ },
562
+ staked: {
563
+ // liqSOL staked in Outpost via `synd`
564
+ amount: stakedLiqsol,
565
+ symbol: 'LiqSOL',
566
+ decimals: LIQSOL_DECIMALS,
567
+ },
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,
583
+ },
584
+ extras: {
585
+ userLiqsolAta: userLiqsolAta.toBase58(),
586
+ reservePoolPDA: reservePoolPDA.toBase58(),
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
594
+ },
595
+ chainID: this.network.chainId,
596
+ };
597
+ }
598
+ catch (err) {
599
+ console.log(`Failed to get Solana portfolio: ${err}`);
600
+ throw err;
601
+ }
602
+ }
603
+
604
+ /**
605
+ * Convenience helper to fetch the distribution userRecord for the current user.
606
+ * Used by balance-correction flows and debugging.
607
+ */
608
+ async getUserRecord() {
609
+ if (!this.pubKey) throw new Error('User pubKey is undefined');
610
+ return this.distributionClient.getUserRecord(this.solPubKey);
611
+ }
612
+
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);
801
+ }
802
+
803
+ /**
804
+ * Generic "fire and forget" send helper if the caller already
805
+ * prepared and signed the transaction.
806
+ */
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
+ // }
858
+ }
859
+
860
+ // ---------------------------------------------------------------------
861
+ // READ-ONLY Public Methods
862
+ // ---------------------------------------------------------------------
863
+
864
+ /**
865
+ * Unified, chain-agnostic tranche snapshot for Solana.
866
+ *
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.
873
+ */
874
+ async getTrancheSnapshot(chainID: ChainID): Promise<TrancheSnapshot> {
875
+ try {
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();
883
+
884
+ return buildSolanaTrancheSnapshot({
885
+ chainID,
886
+ globalState,
887
+ trancheState,
888
+ solPriceUsd,
889
+ nativePriceTimestamp: timestamp,
890
+ });
891
+ }
892
+ catch (err) {
893
+ console.log(`Failed to build Solana tranche snapshot: ${err}`);
894
+ throw err;
895
+ }
896
+ }
897
+
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;
918
+ }
919
+ }
920
+
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();
929
+
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,
95
998
  );
96
- const signed = await this.signTransaction(tx.transaction);
97
- return this.sendTransaction(signed);
999
+ if (!samples.length) {
1000
+ throw new Error('No performance samples available from cluster');
1001
+ }
1002
+
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
+ );
1010
+ }
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;
1029
+ }
1030
+
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());
98
1081
  }
99
1082
 
100
- async signTransaction(tx: SolanaTransaction): Promise<SolanaTransaction> {
101
- return await this.anchor.wallet.signTransaction(tx);
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;
102
1208
  }
103
1209
 
104
- async sendTransaction(signed: SolanaTransaction): Promise<TransactionSignature> {
105
- return await this.anchor.sendAndConfirm(signed);
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);
1230
+ tx.recentBlockhash = blockhash;
1231
+ tx.feePayer = payer;
1232
+
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;
106
1244
  }
107
- }
1245
+
1246
+
1247
+ }