@wireio/stake 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/lib/stake.browser.js +12942 -6703
  2. package/lib/stake.browser.js.map +1 -1
  3. package/lib/stake.d.ts +7627 -646
  4. package/lib/stake.js +13315 -7071
  5. package/lib/stake.js.map +1 -1
  6. package/lib/stake.m.js +12942 -6703
  7. package/lib/stake.m.js.map +1 -1
  8. package/package.json +4 -3
  9. package/src/assets/solana/mainnet/idl/liqsol_core.json +6166 -0
  10. package/src/assets/solana/mainnet/idl/liqsol_token.json +183 -0
  11. package/src/assets/solana/mainnet/idl/transfer_hook.json +197 -0
  12. package/src/assets/solana/mainnet/idl/validator_leaderboard.json +574 -0
  13. package/src/assets/solana/mainnet/types/liqsol_core.ts +6172 -0
  14. package/src/assets/solana/mainnet/types/liqsol_token.ts +189 -0
  15. package/src/assets/solana/mainnet/types/transfer_hook.ts +203 -0
  16. package/src/assets/solana/mainnet/types/validator_leaderboard.ts +580 -0
  17. package/src/networks/ethereum/clients/convert.client.ts +30 -1
  18. package/src/networks/ethereum/clients/receipt.client.ts +81 -3
  19. package/src/networks/ethereum/clients/stake.client.ts +1 -0
  20. package/src/networks/ethereum/contract.ts +260 -222
  21. package/src/networks/ethereum/ethereum.ts +36 -28
  22. package/src/networks/ethereum/types.ts +17 -2
  23. package/src/networks/solana/clients/deposit.client.ts +294 -65
  24. package/src/networks/solana/clients/distribution.client.ts +13 -18
  25. package/src/networks/solana/clients/leaderboard.client.ts +9 -11
  26. package/src/networks/solana/clients/outpost.client.ts +11 -10
  27. package/src/networks/solana/clients/token.client.ts +11 -13
  28. package/src/networks/solana/constants.ts +44 -285
  29. package/src/networks/solana/program.ts +365 -26
  30. package/src/networks/solana/solana.ts +213 -69
  31. package/src/networks/solana/types.ts +4 -4
  32. package/src/networks/solana/utils.ts +16 -301
  33. package/src/staker.ts +10 -2
  34. package/src/types.ts +19 -6
  35. /package/src/assets/ethereum/{ABI → mainnet}/common/Base58.sol/Base58.dbg.json +0 -0
  36. /package/src/assets/ethereum/{ABI → mainnet}/common/Base58.sol/Base58.json +0 -0
  37. /package/src/assets/ethereum/{ABI → mainnet}/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.dbg.json +0 -0
  38. /package/src/assets/ethereum/{ABI → mainnet}/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.json +0 -0
  39. /package/src/assets/ethereum/{ABI → mainnet}/common/RestrictedCallers.sol/RestrictedCallers.dbg.json +0 -0
  40. /package/src/assets/ethereum/{ABI → mainnet}/common/RestrictedCallers.sol/RestrictedCallers.json +0 -0
  41. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata.sol/iodata.dbg.json +0 -0
  42. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata.sol/iodata.json +0 -0
  43. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata_util.sol/iodata_util.dbg.json +0 -0
  44. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata_util.sol/iodata_util.json +0 -0
  45. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_data.sol/sysio_data.dbg.json +0 -0
  46. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_data.sol/sysio_data.json +0 -0
  47. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_errors.sol/sysio_errors.dbg.json +0 -0
  48. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_errors.sol/sysio_errors.json +0 -0
  49. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_merkle.sol/sysio_merkle.dbg.json +0 -0
  50. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_merkle.sol/sysio_merkle.json +0 -0
  51. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_name.sol/sysio_name.dbg.json +0 -0
  52. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_name.sol/sysio_name.json +0 -0
  53. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_pubkey.sol/sysio_pubkey.dbg.json +0 -0
  54. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_pubkey.sol/sysio_pubkey.json +0 -0
  55. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_read.sol/sysio_read.dbg.json +0 -0
  56. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_read.sol/sysio_read.json +0 -0
  57. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_tester.sol/SysioTester.dbg.json +0 -0
  58. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_tester.sol/SysioTester.json +0 -0
  59. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_verify.sol/sysio_verify.dbg.json +0 -0
  60. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_verify.sol/sysio_verify.json +0 -0
  61. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_write.sol/sysio_write.dbg.json +0 -0
  62. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_write.sol/sysio_write.json +0 -0
  63. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/BeaconState.sol/BeaconState.dbg.json +0 -0
  64. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/BeaconState.sol/BeaconState.json +0 -0
  65. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/DepositManager.sol/DepositManager.dbg.json +0 -0
  66. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/DepositManager.sol/DepositManager.json +0 -0
  67. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +0 -0
  68. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +0 -0
  69. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +0 -0
  70. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IAccounting.json +0 -0
  71. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +0 -0
  72. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositContract.json +0 -0
  73. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +0 -0
  74. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositManager.json +0 -0
  75. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +0 -0
  76. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +0 -0
  77. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +0 -0
  78. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20.json +0 -0
  79. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +0 -0
  80. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +0 -0
  81. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +0 -0
  82. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IStakingModule.json +0 -0
  83. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +0 -0
  84. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +0 -0
  85. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +0 -0
  86. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +0 -0
  87. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +0 -0
  88. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/LiqEthCommon.json +0 -0
  89. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +0 -0
  90. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthManaged.sol/LiqEthManaged.json +0 -0
  91. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +0 -0
  92. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.json +0 -0
  93. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +0 -0
  94. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json +0 -0
  95. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/Yield.sol/YieldOracle.dbg.json +0 -0
  96. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/Yield.sol/YieldOracle.json +0 -0
  97. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/accounting.sol/Accounting.dbg.json +0 -0
  98. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/accounting.sol/Accounting.json +0 -0
  99. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/liqEth.sol/LiqEthToken.dbg.json +0 -0
  100. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/liqEth.sol/LiqEthToken.json +0 -0
  101. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/stakingModule.sol/StakingModule.dbg.json +0 -0
  102. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/stakingModule.sol/StakingModule.json +0 -0
  103. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +0 -0
  104. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +0 -0
  105. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +0 -0
  106. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/Uint64BE.json +0 -0
  107. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +0 -0
  108. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/WithdrawalVault.json +0 -0
  109. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Aggregator.sol/Aggregator.json +0 -0
  110. /package/src/assets/ethereum/{ABI → mainnet}/outpost/BAR.sol/BAR.dbg.json +0 -0
  111. /package/src/assets/ethereum/{ABI → mainnet}/outpost/BAR.sol/BAR.json +0 -0
  112. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Depositor.sol/Depositor.dbg.json +0 -0
  113. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Depositor.sol/Depositor.json +0 -0
  114. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +0 -0
  115. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +0 -0
  116. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +0 -0
  117. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +0 -0
  118. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPP.sol/OPP.dbg.json +0 -0
  119. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPP.sol/OPP.json +0 -0
  120. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPP.dbg.json +0 -0
  121. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPP.json +0 -0
  122. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +0 -0
  123. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPEndpoint.json +0 -0
  124. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPInbound.dbg.json +0 -0
  125. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPInbound.json +0 -0
  126. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +0 -0
  127. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPReceiver.json +0 -0
  128. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPSender.dbg.json +0 -0
  129. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPSender.json +0 -0
  130. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/OPPCommon.dbg.json +0 -0
  131. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/OPPCommon.json +0 -0
  132. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +0 -0
  133. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpoint.sol/OPPEndpoint.json +0 -0
  134. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +0 -0
  135. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.json +0 -0
  136. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +0 -0
  137. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.json +0 -0
  138. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPErrors.sol/OPPErrors.dbg.json +0 -0
  139. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPErrors.sol/OPPErrors.json +0 -0
  140. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPInbound.sol/OPPInbound.dbg.json +0 -0
  141. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPInbound.sol/OPPInbound.json +0 -0
  142. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +0 -0
  143. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPReceiver.sol/OPPReceiver.json +0 -0
  144. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPSender.sol/OPPSender.dbg.json +0 -0
  145. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPSender.sol/OPPSender.json +0 -0
  146. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +0 -0
  147. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostErrors.sol/OutpostErrors.json +0 -0
  148. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +0 -0
  149. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManaged.sol/OutpostManaged.json +0 -0
  150. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManager.sol/OutpostManager.dbg.json +0 -0
  151. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManager.sol/OutpostManager.json +0 -0
  152. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +0 -0
  153. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json +0 -0
  154. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +0 -0
  155. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostManager.json +0 -0
  156. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +0 -0
  157. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +0 -0
  158. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +0 -0
  159. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.json +0 -0
  160. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +0 -0
  161. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostOwnable.sol/OutpostOwnable.json +0 -0
  162. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pool.sol/Pool.dbg.json +0 -0
  163. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pool.sol/Pool.json +0 -0
  164. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pretoken.sol/Pretoken.dbg.json +0 -0
  165. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pretoken.sol/Pretoken.json +0 -0
  166. /package/src/assets/ethereum/{ABI → mainnet}/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +0 -0
  167. /package/src/assets/ethereum/{ABI → mainnet}/outpost/ReceiptNFT.sol/ReceiptNFT.json +0 -0
  168. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +0 -0
  169. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IPretoken.sol/IPretoken.json +0 -0
  170. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +0 -0
  171. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IWarrant.sol/IWarrant.json +0 -0
  172. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +0 -0
  173. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +0 -0
  174. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +0 -0
  175. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.json +0 -0
  176. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC1155Token.sol/ERC1155Token.dbg.json +0 -0
  177. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC1155Token.sol/ERC1155Token.json +0 -0
  178. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC20Token.sol/ERC20Token.dbg.json +0 -0
  179. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC20Token.sol/ERC20Token.json +0 -0
  180. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC721Token.sol/ERC721Token.dbg.json +0 -0
  181. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC721Token.sol/ERC721Token.json +0 -0
  182. /package/src/assets/solana/{idl → devnet/idl}/liqsol_core.json +0 -0
  183. /package/src/assets/solana/{idl → devnet/idl}/liqsol_token.json +0 -0
  184. /package/src/assets/solana/{idl → devnet/idl}/transfer_hook.json +0 -0
  185. /package/src/assets/solana/{idl → devnet/idl}/validator_leaderboard.json +0 -0
  186. /package/src/assets/solana/{types → devnet/types}/liqsol_core.ts +0 -0
  187. /package/src/assets/solana/{types → devnet/types}/liqsol_token.ts +0 -0
  188. /package/src/assets/solana/{types → devnet/types}/transfer_hook.ts +0 -0
  189. /package/src/assets/solana/{types → devnet/types}/validator_leaderboard.ts +0 -0
@@ -4,53 +4,26 @@ import {
4
4
  Connection,
5
5
  Keypair,
6
6
  PublicKey,
7
- SystemProgram,
8
- StakeProgram,
9
7
  } from '@solana/web3.js';
10
8
  import {
11
9
  TOKEN_2022_PROGRAM_ID,
12
- ASSOCIATED_TOKEN_PROGRAM_ID,
13
10
  getAssociatedTokenAddress,
14
11
  } from '@solana/spl-token';
15
12
 
16
13
  import {
17
- LIQSOL_CORE,
18
- LIQSOL_TOKEN,
19
- PAY_RATE_SCALE_FACTOR,
20
14
  DEFAULT_AVERAGE_PAY_RATE,
21
15
  EPHEMERAL_RENT_EXEMPTION,
22
- LAMPORTS_PER_SOL,
23
- lamportsToSol,
24
16
  solToLamports,
25
- deriveDepositAuthorityPda,
26
- deriveLiqsolMintPda,
27
- deriveLiqsolMintAuthorityPda,
28
- deriveVaultPda,
29
- deriveReservePoolPda,
30
- deriveStakeControllerStatePda,
31
- derivePayoutStatePda,
32
- deriveBucketAuthorityPda,
33
- deriveDistributionStatePda,
34
- deriveUserRecordPda,
35
- derivePayRateHistoryPda,
36
- deriveStakeControllerVaultPda,
37
- deriveEphemeralStakeAddress,
38
17
  DEFAULT_PAY_RATE_LOOKBACK,
39
- deriveOutpostGlobalStatePda,
40
- deriveOutpostPoolAuthorityPda,
41
- deriveOutpostAccountPda,
42
- deriveTrancheStatePda,
43
- deriveUserPretokenRecordPda,
44
18
  CHAINLINK_FEED,
45
19
  CHAINLINK_PROGRAM,
46
- deriveExtraAccountMetaListPda,
47
20
  } from './constants';
48
21
 
49
- import liqsolCoreIDL from '../../assets/solana/idl/liqsol_core.json';
50
- import { LiqsolCore } from '../../assets/solana/types/liqsol_core';
22
+ import { LiqsolCore } from '../../assets/solana/devnet/types/liqsol_core';
51
23
  import { GlobalState, TrancheState } from './types';
52
24
  import { TrancheLadderItem, TrancheSnapshot } from '../../types';
53
25
  import { ChainID } from '@wireio/core';
26
+ import { SolanaProgramService } from './program';
54
27
 
55
28
  // -----------------------------------------------------------------------------
56
29
  // Tranche Support
@@ -268,265 +241,6 @@ export function buildSolanaTrancheSnapshot(options: {
268
241
  };
269
242
  }
270
243
 
271
-
272
- // -----------------------------------------------------------------------------
273
- // Read-only liqsol_core Program helper
274
- // -----------------------------------------------------------------------------
275
-
276
- let _liqsolCoreProgram: Program<LiqsolCore> | null = null;
277
-
278
- export function getLiqsolCoreProgram(
279
- connection: Connection,
280
- ): Program<LiqsolCore> {
281
- if (_liqsolCoreProgram && _liqsolCoreProgram.provider.connection === connection) {
282
- return _liqsolCoreProgram;
283
- }
284
-
285
- // Dummy wallet – we're only doing read-only account fetches here.
286
- const tmpKeypair = Keypair.generate();
287
- const wallet: any = {
288
- publicKey: tmpKeypair.publicKey,
289
- signAllTransactions: async () => [],
290
- signTransaction: async () => tmpKeypair,
291
- };
292
-
293
- const provider = new AnchorProvider(connection, wallet, {
294
- commitment: 'confirmed',
295
- });
296
-
297
- const program = new Program(
298
- liqsolCoreIDL,
299
- provider,
300
- ) as Program<LiqsolCore>;
301
-
302
- _liqsolCoreProgram = program;
303
- return program;
304
- }
305
-
306
-
307
- // -----------------------------------------------------------------------------
308
- // Balance + state getters (UI-friendly)
309
- // -----------------------------------------------------------------------------
310
-
311
- export async function getUserLiqSolBalance(
312
- connection: Connection,
313
- user: PublicKey,
314
- ): Promise<number> {
315
- const liqsolMint = deriveLiqsolMintPda();
316
- const ata = await getAssociatedTokenAddress(
317
- liqsolMint,
318
- user,
319
- false,
320
- TOKEN_2022_PROGRAM_ID,
321
- );
322
-
323
- try {
324
- const bal = await connection.getTokenAccountBalance(ata);
325
- return Number(bal.value.amount); // raw lamports, not decimals-adjusted
326
- } catch {
327
- return 0;
328
- }
329
- }
330
-
331
- export async function getBucketLiqSolBalance(
332
- connection: Connection,
333
- ): Promise<number> {
334
- const liqsolMint = deriveLiqsolMintPda();
335
- const bucketAuthority = deriveBucketAuthorityPda();
336
- const ata = await getAssociatedTokenAddress(
337
- liqsolMint,
338
- bucketAuthority,
339
- true,
340
- TOKEN_2022_PROGRAM_ID,
341
- );
342
-
343
- try {
344
- const bal = await connection.getTokenAccountBalance(ata);
345
- return Number(bal.value.amount);
346
- } catch {
347
- return 0;
348
- }
349
- }
350
-
351
- export async function getReservePoolBalance(
352
- connection: Connection,
353
- ): Promise<number> {
354
- const reservePool = deriveReservePoolPda();
355
- try {
356
- const lamports = await connection.getBalance(reservePool);
357
- return lamports;
358
- } catch {
359
- return 0;
360
- }
361
- }
362
-
363
- /**
364
- * Raw account info for the stake_controller state (Anchor decode is left
365
- * to the caller so the SDK can stay IDL-agnostic at this layer).
366
- */
367
- export async function getStakeControllerStateRaw(
368
- connection: Connection,
369
- ): Promise<Uint8Array | null> {
370
- const pda = deriveStakeControllerStatePda();
371
- const info = await connection.getAccountInfo(pda);
372
- return info?.data ?? null;
373
- }
374
-
375
- /**
376
- * Raw account info for the payout-state account.
377
- */
378
- export async function getPayoutStateRaw(
379
- connection: Connection,
380
- ): Promise<Uint8Array | null> {
381
- const pda = derivePayoutStatePda();
382
- const info = await connection.getAccountInfo(pda);
383
- return info?.data ?? null;
384
- }
385
-
386
- /**
387
- * Raw account info for a user's distribution user_record.
388
- *
389
- * NOTE: user_record is keyed by the TOKEN ACCOUNT (ATA), not the wallet.
390
- * Here we derive the user's liqSOL ATA and then its user_record PDA.
391
- */
392
- export async function getUserRecordRaw(
393
- connection: Connection,
394
- user: PublicKey,
395
- ): Promise<Uint8Array | null> {
396
- const liqsolMint = deriveLiqsolMintPda();
397
- const userAta = await getAssociatedTokenAddress(
398
- liqsolMint,
399
- user,
400
- false,
401
- TOKEN_2022_PROGRAM_ID,
402
- );
403
- const pda = deriveUserRecordPda(userAta);
404
- const info = await connection.getAccountInfo(pda);
405
- return info?.data ?? null;
406
- }
407
-
408
-
409
- // -----------------------------------------------------------------------------
410
- // Pay-rate & fee utilities (on-chain compatible)
411
- // -----------------------------------------------------------------------------
412
-
413
- export async function getAveragePayRate(
414
- connection: Connection,
415
- lookback: number = DEFAULT_PAY_RATE_LOOKBACK,
416
- ): Promise<bigint> {
417
- const program = getLiqsolCoreProgram(connection);
418
- const payRateHistoryPda = derivePayRateHistoryPda();
419
-
420
- try {
421
- const anyProgram = program;
422
- const payRateHistoryAccount = await anyProgram.account.payRateHistory.fetch(
423
- payRateHistoryPda,
424
- );
425
-
426
- const entries = payRateHistoryAccount.entries ?? [];
427
- const totalEntriesAdded = Number(
428
- payRateHistoryAccount.totalEntriesAdded ?? 0,
429
- );
430
- const currentIndex: number = payRateHistoryAccount.currentIndex ?? 0;
431
- const maxEntries: number =
432
- payRateHistoryAccount.maxEntries ?? entries.length;
433
-
434
- if (!entries.length) {
435
- return DEFAULT_AVERAGE_PAY_RATE;
436
- }
437
-
438
- const entriesToFetch = Math.min(lookback, maxEntries, entries.length);
439
-
440
- let idx: number;
441
- if (totalEntriesAdded === 0) {
442
- idx = 0;
443
- } else if (currentIndex === 0) {
444
- idx = maxEntries - 1;
445
- } else {
446
- idx = currentIndex - 1;
447
- }
448
-
449
- let sum = BigInt(0);
450
- let validCount = BigInt(0);
451
-
452
- for (let i = 0; i < entriesToFetch; i++) {
453
- const entry = entries[idx];
454
- if (entry && typeof entry.scaledRate !== 'undefined') {
455
- const rate = BigInt(entry.scaledRate.toString());
456
- if (rate > BigInt(0)) {
457
- sum += rate;
458
- validCount += BigInt(1);
459
- }
460
- }
461
-
462
- if (totalEntriesAdded === 0) {
463
- idx = (idx + 1) % maxEntries;
464
- } else {
465
- idx = idx === 0 ? maxEntries - 1 : idx - 1;
466
- }
467
- }
468
-
469
- if (validCount === BigInt(0)) {
470
- return DEFAULT_AVERAGE_PAY_RATE;
471
- }
472
-
473
- return sum / validCount;
474
- } catch (err) {
475
- // Fallback to default when history missing/unavailable
476
- return DEFAULT_AVERAGE_PAY_RATE;
477
- }
478
- }
479
-
480
- /**
481
- * On-chain fee formula:
482
- * fee = (average_pay_rate * 4 * deposit_amount_lamports) / 10^12
483
- */
484
- export function calculateExpectedFee(
485
- depositAmountLamports: BN,
486
- averagePayRate: BN,
487
- ): BN {
488
- return averagePayRate
489
- .mul(new BN(4))
490
- .mul(depositAmountLamports)
491
- .div(new BN(1_000_000_000_000)); // 10^12
492
- }
493
-
494
- /**
495
- * Convenience helper to preview how a deposit splits between user + bucket
496
- * and how much goes into the reserve, assuming the simple model:
497
- *
498
- * - userLiqSol = amount - fee + EPHEMERAL_RENT_EXEMPTION
499
- * - bucketLiqSol = fee
500
- * - reserveLamports = amount + EPHEMERAL_RENT_EXEMPTION
501
- */
502
- export function previewDepositEffects(params: {
503
- depositAmountLamports: BN;
504
- averagePayRate: BN;
505
- rentExemptionLamports?: number;
506
- }): {
507
- feeLamports: BN;
508
- userLiqSolLamports: BN;
509
- bucketLiqSolLamports: BN;
510
- reserveIncreaseLamports: BN;
511
- } {
512
- const { depositAmountLamports, averagePayRate } = params;
513
- const rent = new BN(
514
- params.rentExemptionLamports ?? EPHEMERAL_RENT_EXEMPTION,
515
- );
516
-
517
- const fee = calculateExpectedFee(depositAmountLamports, averagePayRate);
518
- const userLiqSol = depositAmountLamports.sub(fee).add(rent);
519
- const bucketLiqSol = fee;
520
- const reserveIncrease = depositAmountLamports.add(rent);
521
-
522
- return {
523
- feeLamports: fee,
524
- userLiqSolLamports: userLiqSol,
525
- bucketLiqSolLamports: bucketLiqSol,
526
- reserveIncreaseLamports: reserveIncrease,
527
- };
528
- }
529
-
530
244
  /**
531
245
  * ---------------------------------------------------------------------------
532
246
  * Outpost-specific helpers
@@ -569,17 +283,18 @@ export interface OutpostAccounts {
569
283
  export async function buildOutpostAccounts(
570
284
  connection: Connection,
571
285
  user: PublicKey,
286
+ pgs: SolanaProgramService,
572
287
  ): Promise<OutpostAccounts> {
573
- const globalState = deriveOutpostGlobalStatePda();
574
- const poolAuthority = deriveOutpostPoolAuthorityPda();
575
- const liqsolMint = deriveLiqsolMintPda();
576
- const distributionState = deriveDistributionStatePda();
577
- const bucketAuthority = deriveBucketAuthorityPda();
578
- const trancheState = deriveTrancheStatePda();
288
+ const globalState = pgs.deriveOutpostGlobalStatePda();
289
+ const poolAuthority = pgs.deriveOutpostPoolAuthorityPda();
290
+ const liqsolMint = pgs.deriveLiqsolMintPda();
291
+ const distributionState = pgs.deriveDistributionStatePda();
292
+ const bucketAuthority = pgs.deriveBucketAuthorityPda();
293
+ const trancheState = pgs.deriveTrancheStatePda();
579
294
 
580
295
  // Outpost / pretoken PDAs
581
- const outpostAccount = deriveOutpostAccountPda(user);
582
- const userPretokenRecord = deriveUserPretokenRecordPda(user);
296
+ const outpostAccount = pgs.deriveOutpostAccountPda(user);
297
+ const userPretokenRecord = pgs.deriveUserPretokenRecordPda(user);
583
298
 
584
299
  // ATAs
585
300
  const liqsolPoolAta = await getAssociatedTokenAddress(
@@ -604,18 +319,18 @@ export async function buildOutpostAccounts(
604
319
  );
605
320
 
606
321
  // user_record PDAs keyed by TOKEN ACCOUNTS (matches capital-staking)
607
- const bucketUserRecord = deriveUserRecordPda(bucketTokenAccount);
608
- const liqsolPoolUserRecord = deriveUserRecordPda(liqsolPoolAta);
609
- const userUserRecord = deriveUserRecordPda(userAta);
322
+ const bucketUserRecord = pgs.deriveUserRecordPda(bucketTokenAccount);
323
+ const liqsolPoolUserRecord = pgs.deriveUserRecordPda(liqsolPoolAta);
324
+ const userUserRecord = pgs.deriveUserRecordPda(userAta);
610
325
 
611
- const extraAccountMetaList = deriveExtraAccountMetaListPda(liqsolMint);
326
+ const extraAccountMetaList = pgs.deriveExtraAccountMetaListPda(liqsolMint);
612
327
 
613
328
  // Chainlink program feeds
614
329
  let chainLinkFeed = CHAINLINK_FEED;
615
330
  let chainLinkProgram = CHAINLINK_PROGRAM;
616
331
 
617
332
  try {
618
- const program = getLiqsolCoreProgram(connection);
333
+ const program = pgs.getProgram('liqsolCore');
619
334
  const ts: TrancheState =
620
335
  await program.account.trancheState.fetch(trancheState);
621
336
 
package/src/staker.ts CHANGED
@@ -37,6 +37,7 @@ export class Staker {
37
37
  config.forEach((cfg) => {
38
38
  switch (cfg.network.chainId) {
39
39
  case SolChainID.Mainnet:
40
+ case SolChainID.Devnet:
40
41
  this.clients.set(cfg.network.chainId, new SolanaStakingClient(cfg));
41
42
  break;
42
43
 
@@ -53,13 +54,20 @@ export class Staker {
53
54
 
54
55
  this.selectedChainID = selectedChainID;
55
56
  }
56
-
57
+
57
58
  /**
58
59
  * Select a chain. Returns true if a client exists for it, false otherwise.
59
60
  * (We still record the selectedChainID so the UI can reflect the chosen chain.)
60
61
  */
61
62
  setChain(chainID: ChainID): boolean {
63
+ const hasClient = this.clients.has(chainID);
64
+
65
+ if (!hasClient) {
66
+ console.warn(`[Staker] setChain: no client configured for chain ${chainID}`);
67
+ return false;
68
+ }
69
+
62
70
  this.selectedChainID = chainID;
63
- return this.clients.has(chainID);
71
+ return true;
64
72
  }
65
73
  }
package/src/types.ts CHANGED
@@ -1,12 +1,29 @@
1
1
  import { BaseSignerWalletAdapter } from '@solana/wallet-adapter-base';
2
2
  import { PublicKey as SolPubKey } from '@solana/web3.js';
3
- import { ChainID, ExternalNetwork, PublicKey } from '@wireio/core';
3
+ import { ChainID, EvmChainID, ExternalNetwork, PublicKey, SolChainID } from '@wireio/core';
4
4
  import { ethers } from 'ethers';
5
5
 
6
6
  export type StakerConfig = {
7
7
  network: ExternalNetwork;
8
8
  provider?: BaseSignerWalletAdapter | ethers.providers.Web3Provider;
9
9
  pubKey?: PublicKey;
10
+ extras?: {
11
+ squadsX?: SquadsXConfig;
12
+ }
13
+ }
14
+
15
+ export type SquadsXConfig = {
16
+ multisigPDA: string; // REQUIRED, base58 multisig address string
17
+ vaultIndex?: number; // default 0
18
+ };
19
+
20
+ export enum SupportedEvmChainID {
21
+ Ethereum = EvmChainID.Ethereum,
22
+ Hoodi = EvmChainID.Hoodi,
23
+ }
24
+ export enum SupportedSolChainID {
25
+ Mainnet = SolChainID.Mainnet,
26
+ Devnet = SolChainID.Devnet,
10
27
  }
11
28
 
12
29
  export interface IStakingClient {
@@ -33,11 +50,7 @@ export interface IStakingClient {
33
50
  * - `TrancheSnapshot` when the chain supports pretoken/tranches
34
51
  * - `null` if this chain has no WIRE/pretoken integration
35
52
  */
36
- getTrancheSnapshot(options?: {
37
- chainID?: ChainID;
38
- windowBefore?: number;
39
- windowAfter?: number;
40
- }): Promise<TrancheSnapshot | null>;
53
+ getTrancheSnapshot(chainId: ChainID): Promise<TrancheSnapshot | null>;
41
54
 
42
55
  /**
43
56
  * Protocol fee charged for deposit from Native to LIQ