@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
@@ -7,17 +7,23 @@ import {
7
7
  PublicKey as SolPubKey,
8
8
  SystemProgram,
9
9
  Transaction,
10
+ TransactionInstruction,
11
+ TransactionMessage,
10
12
  TransactionSignature,
11
13
  } from '@solana/web3.js';
12
14
  import { AnchorProvider, BN } from '@coral-xyz/anchor';
13
15
  import { BaseSignerWalletAdapter } from '@solana/wallet-adapter-base';
14
16
  import {
15
17
  ASSOCIATED_TOKEN_PROGRAM_ID,
18
+ createAssociatedTokenAccountInstruction,
16
19
  getAssociatedTokenAddressSync,
17
20
  TOKEN_2022_PROGRAM_ID,
18
21
  } from '@solana/spl-token';
19
22
 
23
+ import * as multisig from "@sqds/multisig";
24
+
20
25
  import {
26
+ Base58,
21
27
  ChainID,
22
28
  ExternalNetwork,
23
29
  KeyType,
@@ -28,6 +34,7 @@ import {
28
34
  import {
29
35
  IStakingClient,
30
36
  Portfolio,
37
+ SquadsXConfig,
31
38
  StakerConfig,
32
39
  TrancheSnapshot,
33
40
  } from '../../types';
@@ -39,10 +46,7 @@ import { OutpostClient } from './clients/outpost.client';
39
46
  import { TokenClient } from './clients/token.client';
40
47
 
41
48
  import {
42
- deriveLiqsolMintPda,
43
- deriveReservePoolPda,
44
- deriveStakeMetricsPda,
45
- deriveVaultPda,
49
+ DEFAULT_AVERAGE_PAY_RATE,
46
50
  INDEX_SCALE,
47
51
  PAY_RATE_SCALE_FACTOR,
48
52
  } from './constants';
@@ -50,6 +54,7 @@ import {
50
54
  import { buildSolanaTrancheSnapshot, ceilDiv } from './utils';
51
55
  import { GlobalConfig, PayRateEntry, SolanaTransaction } from './types';
52
56
  import { SolanaProgramService } from './program';
57
+ import bs58 from 'bs58';
53
58
 
54
59
  const commitment: Commitment = 'confirmed';
55
60
 
@@ -78,6 +83,9 @@ export class SolanaStakingClient implements IStakingClient {
78
83
  public tokenClient: TokenClient;
79
84
  public program: SolanaProgramService
80
85
 
86
+ private smartAccount?: SolPubKey; // PDA (off-curve)
87
+ private signer?: SolPubKey; // on-curve signer
88
+
81
89
  get solPubKey(): SolPubKey {
82
90
  if (!this.pubKey) throw new Error('pubKey is undefined');
83
91
  return new SolPubKey(this.pubKey.data.array);
@@ -87,6 +95,18 @@ export class SolanaStakingClient implements IStakingClient {
87
95
  return this.config.network;
88
96
  }
89
97
 
98
+ get feePayer(): SolPubKey {
99
+ if (this.signer) return this.signer;
100
+ // fallback for normal wallets
101
+ if (this.anchor.wallet.publicKey) return this.anchor.wallet.publicKey;
102
+ throw new Error('No signing authority available');
103
+ }
104
+
105
+ get squadsX(): SquadsXConfig | null {
106
+ const config = this.config.extras?.squadsX;
107
+ return config ?? null;
108
+ }
109
+
90
110
  constructor(private config: StakerConfig) {
91
111
  const adapter = config.provider as BaseSignerWalletAdapter | undefined;
92
112
 
@@ -185,18 +205,95 @@ export class SolanaStakingClient implements IStakingClient {
185
205
  commitment,
186
206
  });
187
207
 
188
- this.depositClient = new DepositClient(this.anchor);
189
- this.distributionClient = new DistributionClient(this.anchor);
190
- this.leaderboardClient = new LeaderboardClient(this.anchor);
191
- this.outpostClient = new OutpostClient(this.anchor);
192
- this.tokenClient = new TokenClient(this.anchor);
193
- this.program = new SolanaProgramService(this.anchor);
208
+ this.program = new SolanaProgramService(this.anchor, config.network.chainId as SolChainID);
209
+
210
+ this.depositClient = new DepositClient(this.anchor, this.program);
211
+ this.distributionClient = new DistributionClient(this.anchor, this.program);
212
+ this.leaderboardClient = new LeaderboardClient(this.anchor, this.program);
213
+ this.outpostClient = new OutpostClient(this.anchor, this.program);
214
+ this.tokenClient = new TokenClient(this.anchor, this.program);
194
215
  }
195
216
 
196
217
  // ---------------------------------------------------------------------
197
218
  // IStakingClient core methods
198
219
  // ---------------------------------------------------------------------
199
220
 
221
+
222
+ async createVaultLiqsolAtaOneShot(params: {
223
+ connection: Connection;
224
+ payer: SolPubKey; // user's wallet pubkey (signer)
225
+ vaultPda: SolPubKey; // squads vault PDA (off-curve owner)
226
+ }): Promise<{ tx: Transaction; vaultAta: SolPubKey } | null> {
227
+ const { connection, payer, vaultPda } = params;
228
+
229
+ const liqsolMint = this.program.deriveLiqsolMintPda();
230
+
231
+ const vaultAta = getAssociatedTokenAddressSync(
232
+ liqsolMint,
233
+ vaultPda,
234
+ true, // allowOwnerOffCurve
235
+ TOKEN_2022_PROGRAM_ID,
236
+ ASSOCIATED_TOKEN_PROGRAM_ID,
237
+ );
238
+
239
+ // If it already exists, just no-op
240
+ const info = await connection.getAccountInfo(vaultAta, "confirmed");
241
+
242
+ if (info) return null;
243
+
244
+ const ix = createAssociatedTokenAccountInstruction(
245
+ payer, // payer = user
246
+ vaultAta, // ata address
247
+ vaultPda, // owner = vault
248
+ liqsolMint,
249
+ TOKEN_2022_PROGRAM_ID,
250
+ ASSOCIATED_TOKEN_PROGRAM_ID,
251
+ );
252
+
253
+ const tx = new Transaction().add(ix);
254
+ return { tx, vaultAta };
255
+ }
256
+
257
+ private async prepSquadsIxs(ix: TransactionInstruction): Promise<TransactionInstruction[]> {
258
+ if (!this.squadsX) throw new Error('Attempting to wrap Squads instruction without SquadsX config');
259
+
260
+ const multisigPda = this.squadsMultisigPDA!;
261
+ const vaultPda = this.squadsVaultPDA!;
262
+ const vaultIndex = this.squadsX?.vaultIndex ?? 0;
263
+ const creator = this.solPubKey;
264
+
265
+ // compute next transactionIndex
266
+ const ms = await multisig.accounts.Multisig.fromAccountAddress(this.connection, multisigPda);
267
+ const current = BigInt(ms.transactionIndex?.toString() ?? 0);
268
+ const transactionIndex = current + BigInt(1);
269
+
270
+ // inner message uses vault as payer
271
+ // const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 });
272
+ const { blockhash } = await this.connection.getLatestBlockhash("confirmed");
273
+ const transactionMessage = new TransactionMessage({
274
+ payerKey: vaultPda,
275
+ recentBlockhash: blockhash,
276
+ instructions: [ix],
277
+ });
278
+
279
+ const createVaultTxIx = await multisig.instructions.vaultTransactionCreate({
280
+ multisigPda,
281
+ transactionIndex,
282
+ creator,
283
+ vaultIndex,
284
+ transactionMessage,
285
+ ephemeralSigners: 0,
286
+ });
287
+
288
+ const createProposalIx = await multisig.instructions.proposalCreate({
289
+ multisigPda,
290
+ transactionIndex,
291
+ creator,
292
+ });
293
+
294
+ return [createVaultTxIx, createProposalIx];
295
+ }
296
+
200
297
  /**
201
298
  * Deposit native SOL into liqSOL (liqsol_core::deposit).
202
299
  * Handles tx build, sign, send, and confirmation.
@@ -208,18 +305,51 @@ export class SolanaStakingClient implements IStakingClient {
208
305
  }
209
306
 
210
307
  try {
211
- // Build compute budget increase instruction
212
308
  const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 400_000 });
213
-
214
- // Build the Outpost synd instruction
215
- const ix = await this.depositClient.buildDepositTx(amountLamports);
216
-
217
- // Wrap in a transaction and send
218
- const tx = new Transaction().add(cuIx, ix);
219
- const prepared = await this.prepareTx(tx);
220
- const signed = await this.signTransaction(prepared.tx);
221
-
222
- return this.sendAndConfirmHttp(signed, prepared);
309
+ // console.log('amountLamports', amountLamports);
310
+
311
+ // if (!!this.squadsX) {
312
+
313
+ // const createVaultTx = await this.createVaultLiqsolAtaOneShot({
314
+ // connection: this.connection,
315
+ // payer: this.solPubKey,
316
+ // vaultPda: this.squadsVaultPDA!,
317
+ // })
318
+
319
+ // if (createVaultTx !== null) {
320
+ // // console.log('need to create vault ata first...');
321
+ // const tx0 = new Transaction().add(createVaultTx.tx);
322
+ // const prepared0 = await this.prepareTx(tx0);
323
+ // const signed0 = await this.signTransaction(prepared0.tx);
324
+ // const sent0 = await this.sendAndConfirmHttp(signed0, prepared0);
325
+ // // console.log('create Vault ATA', sent0);
326
+ // }
327
+
328
+ // const ix = await this.depositClient.buildDepositTx(amountLamports, this.squadsVaultPDA!)
329
+ // const squadIxs = await this.prepSquadsIxs(ix)
330
+
331
+ // const tx1 = new Transaction().add(cuIx, squadIxs[0]);
332
+ // const prepared1 = await this.prepareTx(tx1);
333
+ // const signed1 = await this.signTransaction(prepared1.tx);
334
+ // const sent1 = await this.sendAndConfirmHttp(signed1, prepared1);
335
+ // console.log('SENT 1', sent1);
336
+
337
+ // const tx2 = new Transaction().add(cuIx, squadIxs[1]);
338
+ // const prepared2 = await this.prepareTx(tx2);
339
+ // const signed2 = await this.signTransaction(prepared2.tx);
340
+ // const sent2 = await this.sendAndConfirmHttp(signed2, prepared2);
341
+ // console.log('SENT 2', sent2);
342
+
343
+ // return sent2;
344
+ // }
345
+ // else {
346
+ const ix = await this.depositClient.buildDepositTx(amountLamports)
347
+ const tx = new Transaction().add(ix);
348
+ const prepared = await this.prepareTx(tx);
349
+ const signed = await this.signTransaction(prepared.tx);
350
+
351
+ return this.sendAndConfirmHttp(signed, prepared);
352
+ // }
223
353
  } catch (err) {
224
354
  throw new Error(`Failed to deposit Solana: ${err}`);
225
355
  }
@@ -361,16 +491,16 @@ export class SolanaStakingClient implements IStakingClient {
361
491
  if (!this.pubKey) throw new Error('User pubKey is undefined');
362
492
 
363
493
  try {
364
- const user = this.solPubKey;
494
+ const user = !!this.squadsX ? this.squadsVaultPDA! : this.solPubKey;
365
495
 
366
- const reservePoolPDA = deriveReservePoolPda();
367
- const vaultPDA = deriveVaultPda();
368
- const liqsolMint = deriveLiqsolMintPda();
496
+ const reservePoolPDA = this.program.deriveReservePoolPda();
497
+ const vaultPDA = this.program.deriveVaultPda();
498
+ const liqsolMint = this.program.deriveLiqsolMintPda();
369
499
 
370
500
  const userLiqsolAta = getAssociatedTokenAddressSync(
371
501
  liqsolMint,
372
502
  user,
373
- false,
503
+ true, //set to true to allow off curve (e.g. PDA for squadsx wallet)
374
504
  TOKEN_2022_PROGRAM_ID,
375
505
  ASSOCIATED_TOKEN_PROGRAM_ID,
376
506
  );
@@ -510,6 +640,21 @@ export class SolanaStakingClient implements IStakingClient {
510
640
  return this.distributionClient.getUserRecord(this.solPubKey);
511
641
  }
512
642
 
643
+ // ---------------------------------------------------------------------
644
+ // SquadsX Helpers
645
+ // ---------------------------------------------------------------------
646
+
647
+ get squadsMultisigPDA(): SolPubKey | null {
648
+ if (!this.squadsX) return null;
649
+ return new SolPubKey(this.squadsX.multisigPDA);
650
+ }
651
+ get squadsVaultPDA(): SolPubKey | null {
652
+ if (!this.squadsX || !this.squadsMultisigPDA) return null;
653
+ const multisigPda = this.squadsMultisigPDA;
654
+ const index = this.squadsX.vaultIndex ?? 0;
655
+ const pda = multisig.getVaultPda({ multisigPda, index });
656
+ return pda[0];
657
+ }
513
658
 
514
659
  // ---------------------------------------------------------------------
515
660
  // READ-ONLY Public Methods
@@ -525,18 +670,8 @@ export class SolanaStakingClient implements IStakingClient {
525
670
  *
526
671
  * This is READ-ONLY and works even with no connected wallet.
527
672
  */
528
- async getTrancheSnapshot(options?: {
529
- chainID?: ChainID;
530
- windowBefore?: number;
531
- windowAfter?: number;
532
- }): Promise<TrancheSnapshot> {
673
+ async getTrancheSnapshot(chainID: ChainID): Promise<TrancheSnapshot> {
533
674
  try {
534
- const {
535
- chainID = SolChainID.WireTestnet,
536
- windowBefore,
537
- windowAfter,
538
- } = options ?? {};
539
-
540
675
  const [globalState, trancheState] = await Promise.all([
541
676
  this.tokenClient.fetchGlobalState(),
542
677
  this.tokenClient.fetchTrancheState(),
@@ -551,8 +686,6 @@ export class SolanaStakingClient implements IStakingClient {
551
686
  trancheState,
552
687
  solPriceUsd,
553
688
  nativePriceTimestamp: timestamp,
554
- ladderWindowBefore: windowBefore,
555
- ladderWindowAfter: windowAfter,
556
689
  });
557
690
  }
558
691
  catch (err) {
@@ -588,24 +721,27 @@ export class SolanaStakingClient implements IStakingClient {
588
721
  * de-scaled using PAY_RATE_SCALE_FACTOR (1e12).
589
722
  */
590
723
  private async getEpochRateDecimalFromProgram(): Promise<number> {
591
- try {
592
-
593
- const liqSolCoreProgram = this.program.getProgram('liqsolCore');
594
- const stakeMetricsPda = deriveStakeMetricsPda();
595
- const stakeMetrics =
596
- await liqSolCoreProgram.account.stakeMetrics.fetch(stakeMetricsPda);
724
+ const liqSolCoreProgram = this.program.getProgram('liqsolCore');
725
+ const payRateHistoryPda = this.program.derivePayRateHistoryPda();
597
726
 
598
- // solSystemPayRate is stored on-chain with PAY_RATE_SCALE_FACTOR (1e12)
599
- const raw = BigInt(stakeMetrics.solSystemPayRate.toString());
727
+ const payRateHistory =
728
+ await liqSolCoreProgram.account.payRateHistory.fetch(payRateHistoryPda);
600
729
 
601
- // Convert to JS number in **decimal per epoch** units
602
- const rateDecimal = Number(raw) / Number(PAY_RATE_SCALE_FACTOR);
730
+ const totalEntriesAdded = Number(payRateHistory.totalEntriesAdded);
731
+ const maxEntries = Number(payRateHistory.maxEntries);
603
732
 
604
- return rateDecimal;
605
- }
606
- catch (err) {
607
- throw new Error(`Failed to read stakeMetrics from program: ${err}`);
733
+ if (totalEntriesAdded === 0) {
734
+ // No real entries yet, fall back to default
735
+ return Number(DEFAULT_AVERAGE_PAY_RATE) / Number(PAY_RATE_SCALE_FACTOR);
608
736
  }
737
+
738
+ // Latest entry is at (currentIndex - 1 + maxEntries) % maxEntries
739
+ const currentIndex = Number(payRateHistory.currentIndex);
740
+ const latestIdx = (currentIndex - 1 + maxEntries) % maxEntries;
741
+ const latestEntry = payRateHistory.entries[latestIdx];
742
+
743
+ const raw = BigInt(latestEntry.scaledRate.toString());
744
+ return Number(raw) / Number(PAY_RATE_SCALE_FACTOR);
609
745
  }
610
746
 
611
747
  // Simple cache so we don’t hammer RPC
@@ -690,7 +826,7 @@ export class SolanaStakingClient implements IStakingClient {
690
826
  return BigInt(0);
691
827
  }
692
828
 
693
- const [avgPayRate, globalConfig]: [BN, GlobalConfig] = await Promise.all([
829
+ const [avgPayRate, globalConfig]: [BN, GlobalConfig | null] = await Promise.all([
694
830
  this.distributionClient.getAverageScaledPayRate(windowSize),
695
831
  this.distributionClient.getGlobalConfig(),
696
832
  ]);
@@ -741,14 +877,12 @@ export class SolanaStakingClient implements IStakingClient {
741
877
  }): Promise<bigint> {
742
878
  this.ensureUser();
743
879
 
744
- const payer = this.solPubKey;
745
-
746
880
  // -------------------------------------------------------------
747
881
  // 1) Current wallet balance (prefer caller override)
748
882
  // -------------------------------------------------------------
749
883
  const balanceLamports: bigint =
750
884
  options?.balanceOverrideLamports ??
751
- BigInt(await this.connection.getBalance(payer, commitment));
885
+ BigInt(await this.connection.getBalance(this.feePayer, commitment));
752
886
 
753
887
  if (balanceLamports <= BigInt(0)) {
754
888
  return BigInt(0);
@@ -859,7 +993,7 @@ export class SolanaStakingClient implements IStakingClient {
859
993
  return this.cachedTxFee.value;
860
994
  }
861
995
 
862
- const payer = this.solPubKey;
996
+ const payer = this.feePayer;
863
997
 
864
998
  const dummyIx = SystemProgram.transfer({
865
999
  fromPubkey: payer,
@@ -961,7 +1095,7 @@ export class SolanaStakingClient implements IStakingClient {
961
1095
  const { blockhash, lastValidBlockHeight } =
962
1096
  await this.connection.getLatestBlockhash('confirmed');
963
1097
  tx.recentBlockhash = blockhash;
964
- tx.feePayer = this.solPubKey;
1098
+ tx.feePayer = this.feePayer;
965
1099
  return { tx, blockhash, lastValidBlockHeight };
966
1100
  }
967
1101
 
@@ -970,17 +1104,27 @@ export class SolanaStakingClient implements IStakingClient {
970
1104
  * Ensures we have a Wire pubKey and an Anchor wallet pubKey, and that they match.
971
1105
  */
972
1106
  ensureUser() {
973
- if (!this.pubKey || !this.anchor.wallet.publicKey) {
974
- throw new Error('User Authorization required: pubKey is undefined');
975
- }
976
- if (
977
- this.solPubKey.toBase58() !==
978
- this.anchor.wallet.publicKey.toBase58()
979
- ) {
980
- throw new Error(
981
- 'Write access requires connected wallet to match pubKey',
982
- );
1107
+ if (!this.pubKey) throw new Error('User pubKey is undefined');
1108
+
1109
+ const wallet = this.anchor?.wallet as any;
1110
+ const pk = wallet?.publicKey as SolPubKey | undefined;
1111
+
1112
+ if (!pk) throw new Error('Wallet not connected');
1113
+ if (typeof wallet.signTransaction !== 'function') {
1114
+ throw new Error('Wallet does not support signTransaction');
983
1115
  }
1116
+
1117
+ // if (!this.pubKey || !this.anchor.wallet.publicKey) {
1118
+ // throw new Error('User Authorization required: pubKey is undefined');
1119
+ // }
1120
+ // if (
1121
+ // this.solPubKey.toBase58() !==
1122
+ // this.anchor.wallet.publicKey.toBase58()
1123
+ // ) {
1124
+ // throw new Error(
1125
+ // 'Write access requires connected wallet to match pubKey',
1126
+ // );
1127
+ // }
984
1128
  }
985
1129
 
986
1130
  }
@@ -262,7 +262,7 @@ export type GlobalState = {
262
262
  roleWarmupDuration: BN;
263
263
 
264
264
  /** Wire lifecycle state (preLaunch / postLaunch / refund) */
265
- wireState: WireState;
265
+ wireState: WireState | any;
266
266
 
267
267
  /** PDA bump */
268
268
  bump: number;
@@ -615,7 +615,7 @@ export type LeaderboardState = {
615
615
  * Per-validator scores (i64 on-chain).
616
616
  * Index corresponds to `registryIndex` in ValidatorRecord.
617
617
  */
618
- scores: BN[];
618
+ scores: number[];
619
619
 
620
620
  /**
621
621
  * Sorted indices into `scores[]` / `voteAccounts[]`,
@@ -628,7 +628,7 @@ export type LeaderboardState = {
628
628
  * `voteAccounts[i]` is the vote account for validator with
629
629
  * `registryIndex == i`.
630
630
  */
631
- voteAccounts: PublicKey[];
631
+ voteAccounts: { bytes: number[]; }[];
632
632
 
633
633
  /**
634
634
  * Number of active validators currently tracked in the leaderboard.
@@ -643,7 +643,7 @@ export type LeaderboardState = {
643
643
  * Reserved padding / future-proofing on-chain (u64[8]).
644
644
  * Not used by client logic, but surfaced for completeness.
645
645
  */
646
- padding: BN[];
646
+ padding: number[];
647
647
  };
648
648
 
649
649
  /**