@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
@@ -1,47 +1,386 @@
1
+ // src/networks/solana/programs.ts
1
2
  import { AnchorProvider, Program } from '@coral-xyz/anchor';
3
+ import { ChainID, SolChainID } from '@wireio/core';
4
+ import { PublicKey, StakeProgram } from '@solana/web3.js';
2
5
 
3
- import liqsolCoreJson from '../../assets/solana/idl/liqsol_core.json';
4
- import liqsolTokenJson from '../../assets/solana/idl/liqsol_token.json';
5
- import validatorLeaderboardJson from '../../assets/solana/idl/validator_leaderboard.json';
6
+ import {
7
+ PDA_SEEDS,
8
+ getProgramIds,
9
+ SolanaProgramIds,
10
+ } from './constants';
6
11
 
7
- import type { LiqsolCore } from '../../assets/solana/types/liqsol_core';
8
- import type { LiqsolToken } from '../../assets/solana/types/liqsol_token';
9
- import type { ValidatorLeaderboard } from '../../assets/solana/types/validator_leaderboard';
12
+ // Mainnet IDLs
13
+ import liqsolCoreMainnetJson from '../../assets/solana/mainnet/idl/liqsol_core.json';
14
+ import liqsolTokenMainnetJson from '../../assets/solana/mainnet/idl/liqsol_token.json';
15
+ import validatorLeaderboardMainnetJson from '../../assets/solana/mainnet/idl/validator_leaderboard.json';
10
16
 
11
- import { PROGRAM_IDS } from './constants';
17
+ // Devnet IDLs
18
+ import liqsolCoreDevnetJson from '../../assets/solana/devnet/idl/liqsol_core.json';
19
+ import liqsolTokenDevnetJson from '../../assets/solana/devnet/idl/liqsol_token.json';
20
+ import validatorLeaderboardDevnetJson from '../../assets/solana/devnet/idl/validator_leaderboard.json';
21
+
22
+ // Mainnet types
23
+ import type { LiqsolCore as LiqSolCoreMainnet } from '../../assets/solana/mainnet/types/liqsol_core';
24
+ import type { LiqsolToken as LiqsolTokenMainnet } from '../../assets/solana/mainnet/types/liqsol_token';
25
+ import type { ValidatorLeaderboard as ValidatorLeaderboardMainnet } from '../../assets/solana/mainnet/types/validator_leaderboard';
26
+
27
+ // Devnet types
28
+ import type { LiqsolCore as LiqSolCoreDevnet } from '../../assets/solana/devnet/types/liqsol_core';
29
+ import type { LiqsolToken as LiqsolTokenDevnet } from '../../assets/solana/devnet/types/liqsol_token';
30
+ import type { ValidatorLeaderboard as ValidatorLeaderboardDevnet } from '../../assets/solana/devnet/types/validator_leaderboard';
12
31
 
13
32
  type Entry<IDL> = {
14
33
  idl: IDL & { address: string };
15
34
  address: string;
16
35
  };
17
36
 
18
- const PROGRAMS = {
19
- liqsolCore: {
20
- idl: liqsolCoreJson,
21
- address: PROGRAM_IDS.LIQSOL_CORE.toBase58(),
22
- } as Entry<LiqsolCore>,
23
- liqsolToken: {
24
- idl: liqsolTokenJson,
25
- address: PROGRAM_IDS.LIQSOL_TOKEN.toBase58(),
26
- } as Entry<LiqsolToken>,
27
- validatorLeaderboard: {
28
- idl: validatorLeaderboardJson,
29
- address: PROGRAM_IDS.VALIDATOR_LEADERBOARD.toBase58(),
30
- } as Entry<ValidatorLeaderboard>,
37
+ const PROGRAMS_BY_CHAIN = {
38
+ [SolChainID.Mainnet]: {
39
+ liqsolCore: {
40
+ idl: liqsolCoreMainnetJson,
41
+ address: liqsolCoreMainnetJson.address,
42
+ } as Entry<LiqSolCoreMainnet>,
43
+ liqsolToken: {
44
+ idl: liqsolTokenMainnetJson,
45
+ address: liqsolTokenMainnetJson.address,
46
+ } as Entry<LiqsolTokenMainnet>,
47
+ validatorLeaderboard: {
48
+ idl: validatorLeaderboardMainnetJson,
49
+ address: validatorLeaderboardMainnetJson.address,
50
+ } as Entry<ValidatorLeaderboardMainnet>,
51
+ },
52
+ [SolChainID.Devnet]: {
53
+ liqsolCore: {
54
+ idl: liqsolCoreDevnetJson,
55
+ address: liqsolCoreDevnetJson.address,
56
+ } as Entry<LiqSolCoreDevnet>,
57
+ liqsolToken: {
58
+ idl: liqsolTokenDevnetJson,
59
+ address: liqsolTokenDevnetJson.address,
60
+ } as Entry<LiqsolTokenDevnet>,
61
+ validatorLeaderboard: {
62
+ idl: validatorLeaderboardDevnetJson,
63
+ address: validatorLeaderboardDevnetJson.address,
64
+ } as Entry<ValidatorLeaderboardDevnet>,
65
+ },
31
66
  } as const;
32
67
 
33
- export type SolanaProgramName = keyof typeof PROGRAMS;
68
+ export type SolanaProgramName =
69
+ keyof (typeof PROGRAMS_BY_CHAIN)[SolChainID.Mainnet];
34
70
 
35
71
  export class SolanaProgramService {
36
- constructor(private provider: AnchorProvider) { }
72
+ private readonly ids: SolanaProgramIds;
73
+ private readonly programs: (typeof PROGRAMS_BY_CHAIN)[SolChainID.Mainnet];
74
+
75
+ constructor(
76
+ private provider: AnchorProvider,
77
+ private chainId: ChainID,
78
+ ) {
79
+ const solChain = chainId as SolChainID;
80
+ this.ids = getProgramIds(solChain);
81
+ const programs = PROGRAMS_BY_CHAIN[solChain];
82
+ if (!programs) {
83
+ throw new Error(`Unsupported Solana chainId=${chainId}`);
84
+ }
85
+ this.programs = programs;
86
+ }
87
+
88
+ /** Expose per-chain program IDs */
89
+ get programIds(): SolanaProgramIds {
90
+ return this.ids;
91
+ }
37
92
 
38
- getProgram<K extends SolanaProgramName>(name: K): Program<(typeof PROGRAMS)[K]['idl']> {
39
- const { idl, address } = PROGRAMS[name];
93
+ /** Anchor Program getter */
94
+ getProgram<K extends SolanaProgramName>(
95
+ name: K,
96
+ ): Program<(typeof this.programs)[K]['idl']> {
97
+ const { idl, address } = this.programs[name];
40
98
  const idlWithAddr = { ...idl, address };
41
- return new Program(idlWithAddr, this.provider) as Program<(typeof PROGRAMS)[K]['idl']>;
99
+ return new Program(idlWithAddr, this.provider) as Program<
100
+ (typeof this.programs)[K]['idl']
101
+ >;
42
102
  }
43
103
 
44
104
  listProgramNames(): SolanaProgramName[] {
45
- return Object.keys(PROGRAMS) as SolanaProgramName[];
105
+ return Object.keys(this.programs) as SolanaProgramName[];
106
+ }
107
+
108
+ get PROGRAM_IDS(): SolanaProgramIds {
109
+ return this.ids;
110
+ }
111
+
112
+
113
+ // ---------------------------------------------------------------------
114
+ // PDA helpers (instance methods, no ids passed in)
115
+ // ---------------------------------------------------------------------
116
+
117
+ // GLOBAL CONFIG
118
+ deriveGlobalConfigPda(): PublicKey {
119
+ return PublicKey.findProgramAddressSync(
120
+ [Buffer.from(PDA_SEEDS.GLOBAL_CONFIG)],
121
+ this.ids.LIQSOL_CORE,
122
+ )[0];
123
+ }
124
+
125
+ // CORE / DISTRIBUTION / DEPOSIT
126
+
127
+ deriveLiqsolMintPda(): PublicKey {
128
+ return PublicKey.findProgramAddressSync(
129
+ [Buffer.from(PDA_SEEDS.LIQSOL_MINT)],
130
+ this.ids.LIQSOL_TOKEN,
131
+ )[0];
132
+ }
133
+
134
+ deriveLiqsolMintAuthorityPda(): PublicKey {
135
+ return PublicKey.findProgramAddressSync(
136
+ [Buffer.from(PDA_SEEDS.LIQSOL_MINT_AUTHORITY)],
137
+ this.ids.LIQSOL_TOKEN,
138
+ )[0];
139
+ }
140
+
141
+ deriveDepositAuthorityPda(): PublicKey {
142
+ return PublicKey.findProgramAddressSync(
143
+ [Buffer.from(PDA_SEEDS.DEPOSIT_AUTHORITY)],
144
+ this.ids.LIQSOL_CORE,
145
+ )[0];
146
+ }
147
+
148
+ deriveVaultPda(): PublicKey {
149
+ return PublicKey.findProgramAddressSync(
150
+ [Buffer.from(PDA_SEEDS.VAULT)],
151
+ this.ids.LIQSOL_CORE,
152
+ )[0];
153
+ }
154
+
155
+ deriveReservePoolPda(): PublicKey {
156
+ return PublicKey.findProgramAddressSync(
157
+ [Buffer.from(PDA_SEEDS.RESERVE_POOL)],
158
+ this.ids.LIQSOL_CORE,
159
+ )[0];
160
+ }
161
+
162
+ deriveStakeControllerStatePda(): PublicKey {
163
+ return PublicKey.findProgramAddressSync(
164
+ [Buffer.from(PDA_SEEDS.STAKE_CONTROLLER_STATE)],
165
+ this.ids.LIQSOL_CORE,
166
+ )[0];
167
+ }
168
+
169
+ derivePayoutStatePda(): PublicKey {
170
+ return PublicKey.findProgramAddressSync(
171
+ [Buffer.from(PDA_SEEDS.PAYOUT_STATE)],
172
+ this.ids.LIQSOL_CORE,
173
+ )[0];
174
+ }
175
+
176
+ deriveBucketAuthorityPda(): PublicKey {
177
+ return PublicKey.findProgramAddressSync(
178
+ [Buffer.from(PDA_SEEDS.BUCKET_AUTHORITY)],
179
+ this.ids.LIQSOL_CORE,
180
+ )[0];
181
+ }
182
+
183
+ deriveDistributionStatePda(): PublicKey {
184
+ return PublicKey.findProgramAddressSync(
185
+ [Buffer.from(PDA_SEEDS.DISTRIBUTION_STATE)],
186
+ this.ids.LIQSOL_CORE,
187
+ )[0];
188
+ }
189
+
190
+ /**
191
+ * user_record PDA (keyed by USER wallet)
192
+ */
193
+ deriveUserRecordPda(user: PublicKey): PublicKey {
194
+ return PublicKey.findProgramAddressSync(
195
+ [Buffer.from(PDA_SEEDS.USER_RECORD), user.toBuffer()],
196
+ this.ids.LIQSOL_CORE,
197
+ )[0];
198
+ }
199
+
200
+ derivePayRateHistoryPda(): PublicKey {
201
+ return PublicKey.findProgramAddressSync(
202
+ [Buffer.from(PDA_SEEDS.PAY_RATE_HISTORY)],
203
+ this.ids.LIQSOL_CORE,
204
+ )[0];
205
+ }
206
+
207
+ // --- Withdraw module / receipts ---
208
+
209
+ deriveWithdrawGlobalPda(): PublicKey {
210
+ return PublicKey.findProgramAddressSync(
211
+ [Buffer.from(PDA_SEEDS.WITHDRAW_GLOBAL)],
212
+ this.ids.LIQSOL_CORE,
213
+ )[0];
214
+ }
215
+
216
+ deriveStakeAllocationStatePda(): PublicKey {
217
+ return PublicKey.findProgramAddressSync(
218
+ [Buffer.from(PDA_SEEDS.STAKE_ALLOCATION_STATE)],
219
+ this.ids.LIQSOL_CORE,
220
+ )[0];
221
+ }
222
+
223
+ deriveStakeMetricsPda(): PublicKey {
224
+ return PublicKey.findProgramAddressSync(
225
+ [Buffer.from(PDA_SEEDS.STAKE_METRICS)],
226
+ this.ids.LIQSOL_CORE,
227
+ )[0];
228
+ }
229
+
230
+ deriveMaintenanceLedgerPda(): PublicKey {
231
+ return PublicKey.findProgramAddressSync(
232
+ [Buffer.from(PDA_SEEDS.MAINTENANCE_LEDGER)],
233
+ this.ids.LIQSOL_CORE,
234
+ )[0];
235
+ }
236
+
237
+ deriveWithdrawMintAuthorityPda(): PublicKey {
238
+ return PublicKey.findProgramAddressSync(
239
+ [Buffer.from(PDA_SEEDS.WITHDRAW_MINT_AUTHORITY)],
240
+ this.ids.LIQSOL_CORE,
241
+ )[0];
242
+ }
243
+
244
+ deriveWithdrawMintMetadataPda(): PublicKey {
245
+ return PublicKey.findProgramAddressSync(
246
+ [Buffer.from(PDA_SEEDS.MINT_METADATA)],
247
+ this.ids.LIQSOL_CORE,
248
+ )[0];
249
+ }
250
+
251
+ /**
252
+ * NFT mint for withdrawal receipt, derived from nextReceiptId.
253
+ */
254
+ deriveWithdrawNftMintPda(receiptId: bigint | number): PublicKey {
255
+ const receiptIdBytes = Buffer.alloc(8);
256
+ const asBigInt =
257
+ typeof receiptId === 'bigint'
258
+ ? receiptId
259
+ : BigInt(receiptId.toString());
260
+ receiptIdBytes.writeBigUInt64LE(asBigInt);
261
+ return PublicKey.findProgramAddressSync(
262
+ [Buffer.from(PDA_SEEDS.WITHDRAW_MINT), receiptIdBytes],
263
+ this.ids.LIQSOL_CORE,
264
+ )[0];
265
+ }
266
+
267
+ deriveLiqReceiptDataPda(nftMint: PublicKey): PublicKey {
268
+ return PublicKey.findProgramAddressSync(
269
+ [Buffer.from(PDA_SEEDS.LIQ_RECEIPT_DATA), nftMint.toBuffer()],
270
+ this.ids.LIQSOL_CORE,
271
+ )[0];
272
+ }
273
+
274
+ // --- Validator leaderboard ---
275
+
276
+ deriveLeaderboardStatePda(): PublicKey {
277
+ return PublicKey.findProgramAddressSync(
278
+ [Buffer.from(PDA_SEEDS.LEADERBOARD_STATE)],
279
+ this.ids.VALIDATOR_LEADERBOARD,
280
+ )[0];
281
+ }
282
+
283
+ deriveValidatorRecordPda(voteAccount: PublicKey): PublicKey {
284
+ return PublicKey.findProgramAddressSync(
285
+ [Buffer.from(PDA_SEEDS.VALIDATOR_RECORD), voteAccount.toBuffer()],
286
+ this.ids.VALIDATOR_LEADERBOARD,
287
+ )[0];
288
+ }
289
+
290
+ deriveStakeControllerVaultPda(): PublicKey {
291
+ return PublicKey.findProgramAddressSync(
292
+ [Buffer.from(PDA_SEEDS.VAULT)],
293
+ this.ids.LIQSOL_CORE,
294
+ )[0];
295
+ }
296
+
297
+ // --- Outpost / pretokens ---
298
+
299
+ deriveOutpostGlobalStatePda(): PublicKey {
300
+ return PublicKey.findProgramAddressSync(
301
+ [Buffer.from(PDA_SEEDS.OUTPOST_GLOBAL_STATE)],
302
+ this.ids.LIQSOL_CORE,
303
+ )[0];
304
+ }
305
+
306
+ deriveOutpostPoolAuthorityPda(): PublicKey {
307
+ return PublicKey.findProgramAddressSync(
308
+ [Buffer.from(PDA_SEEDS.LIQSOL_POOL)],
309
+ this.ids.LIQSOL_CORE,
310
+ )[0];
311
+ }
312
+
313
+ deriveOutpostAccountPda(user: PublicKey): PublicKey {
314
+ return PublicKey.findProgramAddressSync(
315
+ [Buffer.from(PDA_SEEDS.OUTPOST_ACCOUNT), user.toBuffer()],
316
+ this.ids.LIQSOL_CORE,
317
+ )[0];
318
+ }
319
+
320
+ deriveUserPretokenRecordPda(user: PublicKey): PublicKey {
321
+ return PublicKey.findProgramAddressSync(
322
+ [Buffer.from(PDA_SEEDS.USER_PRETOKEN_RECORD), user.toBuffer()],
323
+ this.ids.LIQSOL_CORE,
324
+ )[0];
325
+ }
326
+
327
+ deriveTrancheStatePda(): PublicKey {
328
+ return PublicKey.findProgramAddressSync(
329
+ [Buffer.from(PDA_SEEDS.TRANCHE_STATE)],
330
+ this.ids.LIQSOL_CORE,
331
+ )[0];
332
+ }
333
+
334
+ derivePriceHistoryPda(): PublicKey {
335
+ return PublicKey.findProgramAddressSync(
336
+ [Buffer.from(PDA_SEEDS.PRICE_HISTORY)],
337
+ this.ids.LIQSOL_CORE,
338
+ )[0];
339
+ }
340
+
341
+ // --- BAR (bonded actor roles) ---
342
+
343
+ deriveBarConfigPda(): PublicKey {
344
+ return PublicKey.findProgramAddressSync(
345
+ [Buffer.from(PDA_SEEDS.BAR_STATE_SEED)],
346
+ this.ids.LIQSOL_CORE,
347
+ )[0];
348
+ }
349
+
350
+ deriveBondLevelPda(bondLevelId: number[]): PublicKey {
351
+ return PublicKey.findProgramAddressSync(
352
+ [Buffer.from(PDA_SEEDS.BOND_LEVEL_SEED), Buffer.from(bondLevelId)],
353
+ this.ids.LIQSOL_CORE,
354
+ )[0];
355
+ }
356
+
357
+ deriveBondedActorPda(actor: PublicKey): PublicKey {
358
+ return PublicKey.findProgramAddressSync(
359
+ [Buffer.from(PDA_SEEDS.BONDED_ACTOR_SEED), actor.toBuffer()],
360
+ this.ids.LIQSOL_CORE,
361
+ )[0];
362
+ }
363
+
364
+ // --- Transfer-hook extra metas ---
365
+
366
+ deriveExtraAccountMetaListPda(liqsolMint: PublicKey): PublicKey {
367
+ return PublicKey.findProgramAddressSync(
368
+ [Buffer.from(PDA_SEEDS.EXTRA_ACCOUNT_METAS), liqsolMint.toBuffer()],
369
+ this.ids.TRANSFER_HOOK,
370
+ )[0];
371
+ }
372
+
373
+ // --- Ephemeral stake address (per-deposit) ---
374
+
375
+ /**
376
+ * Ephemeral stake account address used per-deposit.
377
+ * On-chain convention: seed = `ephemeral_<u32>` under StakeProgram.programId.
378
+ */
379
+ async deriveEphemeralStakeAddress(
380
+ user: PublicKey,
381
+ seed: number,
382
+ ): Promise<PublicKey> {
383
+ const seedStr = `ephemeral_${seed}`;
384
+ return PublicKey.createWithSeed(user, seedStr, StakeProgram.programId);
46
385
  }
47
386
  }