@wireio/stake 1.1.0 → 2.1.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 +12958 -6707
  2. package/lib/stake.browser.js.map +1 -1
  3. package/lib/stake.d.ts +7612 -639
  4. package/lib/stake.js +13324 -7073
  5. package/lib/stake.js.map +1 -1
  6. package/lib/stake.m.js +12958 -6707
  7. package/lib/stake.m.js.map +1 -1
  8. package/package.json +4 -3
  9. package/src/assets/solana/{idl → devnet/idl}/liqsol_core.json +15 -3
  10. package/src/assets/solana/{types → devnet/types}/liqsol_core.ts +15 -3
  11. package/src/assets/solana/mainnet/idl/liqsol_core.json +6178 -0
  12. package/src/assets/solana/mainnet/idl/liqsol_token.json +183 -0
  13. package/src/assets/solana/mainnet/idl/transfer_hook.json +197 -0
  14. package/src/assets/solana/mainnet/idl/validator_leaderboard.json +574 -0
  15. package/src/assets/solana/mainnet/types/liqsol_core.ts +6184 -0
  16. package/src/assets/solana/mainnet/types/liqsol_token.ts +189 -0
  17. package/src/assets/solana/mainnet/types/transfer_hook.ts +203 -0
  18. package/src/assets/solana/mainnet/types/validator_leaderboard.ts +580 -0
  19. package/src/networks/ethereum/clients/convert.client.ts +30 -1
  20. package/src/networks/ethereum/clients/receipt.client.ts +81 -3
  21. package/src/networks/ethereum/clients/stake.client.ts +1 -0
  22. package/src/networks/ethereum/contract.ts +260 -222
  23. package/src/networks/ethereum/ethereum.ts +35 -30
  24. package/src/networks/ethereum/types.ts +17 -2
  25. package/src/networks/solana/clients/deposit.client.ts +294 -68
  26. package/src/networks/solana/clients/distribution.client.ts +15 -20
  27. package/src/networks/solana/clients/leaderboard.client.ts +11 -13
  28. package/src/networks/solana/clients/outpost.client.ts +13 -19
  29. package/src/networks/solana/clients/token.client.ts +13 -15
  30. package/src/networks/solana/constants.ts +44 -285
  31. package/src/networks/solana/program.ts +382 -28
  32. package/src/networks/solana/solana.ts +315 -92
  33. package/src/networks/solana/types.ts +4 -4
  34. package/src/networks/solana/utils.ts +16 -301
  35. package/src/staker.ts +10 -2
  36. package/src/types.ts +19 -6
  37. /package/src/assets/ethereum/{ABI → mainnet}/common/Base58.sol/Base58.dbg.json +0 -0
  38. /package/src/assets/ethereum/{ABI → mainnet}/common/Base58.sol/Base58.json +0 -0
  39. /package/src/assets/ethereum/{ABI → mainnet}/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.dbg.json +0 -0
  40. /package/src/assets/ethereum/{ABI → mainnet}/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.json +0 -0
  41. /package/src/assets/ethereum/{ABI → mainnet}/common/RestrictedCallers.sol/RestrictedCallers.dbg.json +0 -0
  42. /package/src/assets/ethereum/{ABI → mainnet}/common/RestrictedCallers.sol/RestrictedCallers.json +0 -0
  43. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata.sol/iodata.dbg.json +0 -0
  44. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata.sol/iodata.json +0 -0
  45. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata_util.sol/iodata_util.dbg.json +0 -0
  46. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata_util.sol/iodata_util.json +0 -0
  47. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_data.sol/sysio_data.dbg.json +0 -0
  48. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_data.sol/sysio_data.json +0 -0
  49. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_errors.sol/sysio_errors.dbg.json +0 -0
  50. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_errors.sol/sysio_errors.json +0 -0
  51. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_merkle.sol/sysio_merkle.dbg.json +0 -0
  52. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_merkle.sol/sysio_merkle.json +0 -0
  53. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_name.sol/sysio_name.dbg.json +0 -0
  54. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_name.sol/sysio_name.json +0 -0
  55. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_pubkey.sol/sysio_pubkey.dbg.json +0 -0
  56. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_pubkey.sol/sysio_pubkey.json +0 -0
  57. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_read.sol/sysio_read.dbg.json +0 -0
  58. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_read.sol/sysio_read.json +0 -0
  59. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_tester.sol/SysioTester.dbg.json +0 -0
  60. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_tester.sol/SysioTester.json +0 -0
  61. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_verify.sol/sysio_verify.dbg.json +0 -0
  62. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_verify.sol/sysio_verify.json +0 -0
  63. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_write.sol/sysio_write.dbg.json +0 -0
  64. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_write.sol/sysio_write.json +0 -0
  65. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/BeaconState.sol/BeaconState.dbg.json +0 -0
  66. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/BeaconState.sol/BeaconState.json +0 -0
  67. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/DepositManager.sol/DepositManager.dbg.json +0 -0
  68. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/DepositManager.sol/DepositManager.json +0 -0
  69. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +0 -0
  70. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +0 -0
  71. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +0 -0
  72. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IAccounting.json +0 -0
  73. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +0 -0
  74. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositContract.json +0 -0
  75. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +0 -0
  76. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositManager.json +0 -0
  77. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +0 -0
  78. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +0 -0
  79. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +0 -0
  80. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20.json +0 -0
  81. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +0 -0
  82. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +0 -0
  83. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +0 -0
  84. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IStakingModule.json +0 -0
  85. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +0 -0
  86. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +0 -0
  87. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +0 -0
  88. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +0 -0
  89. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +0 -0
  90. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/LiqEthCommon.json +0 -0
  91. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +0 -0
  92. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthManaged.sol/LiqEthManaged.json +0 -0
  93. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +0 -0
  94. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.json +0 -0
  95. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +0 -0
  96. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json +0 -0
  97. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/Yield.sol/YieldOracle.dbg.json +0 -0
  98. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/Yield.sol/YieldOracle.json +0 -0
  99. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/accounting.sol/Accounting.dbg.json +0 -0
  100. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/accounting.sol/Accounting.json +0 -0
  101. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/liqEth.sol/LiqEthToken.dbg.json +0 -0
  102. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/liqEth.sol/LiqEthToken.json +0 -0
  103. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/stakingModule.sol/StakingModule.dbg.json +0 -0
  104. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/stakingModule.sol/StakingModule.json +0 -0
  105. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +0 -0
  106. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +0 -0
  107. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +0 -0
  108. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/Uint64BE.json +0 -0
  109. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +0 -0
  110. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/WithdrawalVault.json +0 -0
  111. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Aggregator.sol/Aggregator.json +0 -0
  112. /package/src/assets/ethereum/{ABI → mainnet}/outpost/BAR.sol/BAR.dbg.json +0 -0
  113. /package/src/assets/ethereum/{ABI → mainnet}/outpost/BAR.sol/BAR.json +0 -0
  114. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Depositor.sol/Depositor.dbg.json +0 -0
  115. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Depositor.sol/Depositor.json +0 -0
  116. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +0 -0
  117. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +0 -0
  118. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +0 -0
  119. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +0 -0
  120. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPP.sol/OPP.dbg.json +0 -0
  121. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPP.sol/OPP.json +0 -0
  122. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPP.dbg.json +0 -0
  123. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPP.json +0 -0
  124. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +0 -0
  125. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPEndpoint.json +0 -0
  126. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPInbound.dbg.json +0 -0
  127. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPInbound.json +0 -0
  128. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +0 -0
  129. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPReceiver.json +0 -0
  130. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPSender.dbg.json +0 -0
  131. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPSender.json +0 -0
  132. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/OPPCommon.dbg.json +0 -0
  133. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/OPPCommon.json +0 -0
  134. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +0 -0
  135. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpoint.sol/OPPEndpoint.json +0 -0
  136. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +0 -0
  137. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.json +0 -0
  138. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +0 -0
  139. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.json +0 -0
  140. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPErrors.sol/OPPErrors.dbg.json +0 -0
  141. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPErrors.sol/OPPErrors.json +0 -0
  142. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPInbound.sol/OPPInbound.dbg.json +0 -0
  143. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPInbound.sol/OPPInbound.json +0 -0
  144. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +0 -0
  145. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPReceiver.sol/OPPReceiver.json +0 -0
  146. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPSender.sol/OPPSender.dbg.json +0 -0
  147. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPSender.sol/OPPSender.json +0 -0
  148. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +0 -0
  149. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostErrors.sol/OutpostErrors.json +0 -0
  150. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +0 -0
  151. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManaged.sol/OutpostManaged.json +0 -0
  152. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManager.sol/OutpostManager.dbg.json +0 -0
  153. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManager.sol/OutpostManager.json +0 -0
  154. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +0 -0
  155. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json +0 -0
  156. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +0 -0
  157. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostManager.json +0 -0
  158. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +0 -0
  159. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +0 -0
  160. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +0 -0
  161. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.json +0 -0
  162. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +0 -0
  163. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostOwnable.sol/OutpostOwnable.json +0 -0
  164. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pool.sol/Pool.dbg.json +0 -0
  165. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pool.sol/Pool.json +0 -0
  166. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pretoken.sol/Pretoken.dbg.json +0 -0
  167. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pretoken.sol/Pretoken.json +0 -0
  168. /package/src/assets/ethereum/{ABI → mainnet}/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +0 -0
  169. /package/src/assets/ethereum/{ABI → mainnet}/outpost/ReceiptNFT.sol/ReceiptNFT.json +0 -0
  170. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +0 -0
  171. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IPretoken.sol/IPretoken.json +0 -0
  172. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +0 -0
  173. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IWarrant.sol/IWarrant.json +0 -0
  174. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +0 -0
  175. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +0 -0
  176. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +0 -0
  177. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.json +0 -0
  178. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC1155Token.sol/ERC1155Token.dbg.json +0 -0
  179. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC1155Token.sol/ERC1155Token.json +0 -0
  180. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC20Token.sol/ERC20Token.dbg.json +0 -0
  181. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC20Token.sol/ERC20Token.json +0 -0
  182. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC721Token.sol/ERC721Token.dbg.json +0 -0
  183. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC721Token.sol/ERC721Token.json +0 -0
  184. /package/src/assets/solana/{idl → devnet/idl}/liqsol_token.json +0 -0
  185. /package/src/assets/solana/{idl → devnet/idl}/transfer_hook.json +0 -0
  186. /package/src/assets/solana/{idl → devnet/idl}/validator_leaderboard.json +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,15 +1,8 @@
1
1
  import { AnchorProvider, Program, BN } from '@coral-xyz/anchor';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
 
4
- import { SolanaProgramService } from '../program';
5
- import type { LiqsolCore } from '../../../assets/solana/types/liqsol_core';
6
- import {
7
- deriveDistributionStatePda,
8
- deriveGlobalConfigPda,
9
- deriveLiqsolMintPda,
10
- derivePayRateHistoryPda,
11
- deriveUserRecordPda,
12
- } from '../constants';
4
+ import { LiqsolCoreClientIdl, SolanaProgramService } from '../program';
5
+ import type { LiqsolCore } from '../../../assets/solana/devnet/types/liqsol_core';
13
6
  import type { DistributionState, DistributionUserRecord, GlobalConfig, PayRateEntry, PayRateHistory } from '../types';
14
7
  import { getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID } from '@solana/spl-token';
15
8
  import { ceilDiv } from '../utils';
@@ -33,11 +26,13 @@ import { ceilDiv } from '../utils';
33
26
  * - DistributionState + UserRecord track *shares* for yield.
34
27
  */
35
28
  export class DistributionClient {
36
- private program: Program<LiqsolCore>;
29
+ private program: Program<LiqsolCoreClientIdl>;
37
30
 
38
- constructor(private provider: AnchorProvider) {
39
- const svc = new SolanaProgramService(provider);
40
- this.program = svc.getProgram('liqsolCore');
31
+ constructor(
32
+ private readonly provider: AnchorProvider,
33
+ private readonly pgs: SolanaProgramService
34
+ ) {
35
+ this.program = pgs.getProgram('liqsolCore');
41
36
  }
42
37
 
43
38
  get connection() {
@@ -50,7 +45,7 @@ export class DistributionClient {
50
45
  * IDL account name: "distributionState"
51
46
  */
52
47
  async getDistributionState(): Promise<DistributionState | null> {
53
- const pda = deriveDistributionStatePda();
48
+ const pda = this.pgs.deriveDistributionStatePda();
54
49
  try {
55
50
  return await this.program.account.distributionState.fetch(pda);
56
51
  } catch {
@@ -65,7 +60,7 @@ export class DistributionClient {
65
60
  * IDL account name: "payRateHistory"
66
61
  */
67
62
  async getPayRateHistory(): Promise<PayRateHistory | null> {
68
- const pda = derivePayRateHistoryPda();
63
+ const pda = this.pgs.derivePayRateHistoryPda();
69
64
  try {
70
65
  // Anchor types map directly onto our PayRateHistory TS type
71
66
  return (await this.program.account.payRateHistory.fetch(
@@ -82,7 +77,7 @@ export class DistributionClient {
82
77
  * IDL account name: "globalConfig"
83
78
  */
84
79
  async getGlobalConfig(): Promise<GlobalConfig | null> {
85
- const pda = deriveGlobalConfigPda();
80
+ const pda = this.pgs.deriveGlobalConfigPda();
86
81
  try {
87
82
  return (await this.program.account.globalConfig.fetch(
88
83
  pda,
@@ -99,17 +94,17 @@ export class DistributionClient {
99
94
  async getUserRecord(
100
95
  ownerOrAta: PublicKey,
101
96
  ): Promise<DistributionUserRecord | null> {
102
- const liqsolMint = deriveLiqsolMintPda();
97
+ const liqsolMint = this.pgs.deriveLiqsolMintPda();
103
98
 
104
99
  // 1) Try treating ownerOrAta as a WALLET: derive its liqSOL ATA, then userRecord.
105
100
  try {
106
101
  const ata = getAssociatedTokenAddressSync(
107
102
  liqsolMint,
108
103
  ownerOrAta,
109
- false,
104
+ true,
110
105
  TOKEN_2022_PROGRAM_ID,
111
106
  );
112
- const pdaFromWallet = deriveUserRecordPda(ata);
107
+ const pdaFromWallet = this.pgs.deriveUserRecordPda(ata);
113
108
  const recFromWallet =
114
109
  await this.program.account.userRecord.fetchNullable(pdaFromWallet);
115
110
  if (recFromWallet) {
@@ -121,7 +116,7 @@ export class DistributionClient {
121
116
 
122
117
  // 2) Fallback: treat ownerOrAta as already being the TOKEN ACCOUNT.
123
118
  try {
124
- const pdaFromAta = deriveUserRecordPda(ownerOrAta);
119
+ const pdaFromAta = this.pgs.deriveUserRecordPda(ownerOrAta);
125
120
  return await this.program.account.userRecord.fetchNullable(pdaFromAta);
126
121
  } catch {
127
122
  return null;
@@ -1,12 +1,8 @@
1
1
  import { AnchorProvider, Program } from '@coral-xyz/anchor';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
 
4
- import { SolanaProgramService } from '../program';
5
- import type { ValidatorLeaderboard } from '../../../assets/solana/types/validator_leaderboard';
6
- import {
7
- deriveLeaderboardStatePda,
8
- deriveValidatorRecordPda,
9
- } from '../constants';
4
+ import { SolanaProgramService, ValidatorLeaderboardClientIdl } from '../program';
5
+ import type { ValidatorLeaderboard } from '../../../assets/solana/devnet/types/validator_leaderboard';
10
6
  import { LeaderboardState, ValidatorRecord } from '../types';
11
7
 
12
8
  /**
@@ -15,15 +11,17 @@ import { LeaderboardState, ValidatorRecord } from '../types';
15
11
  * Adjust account names/fields to match your IDL (state, validatorRecord, etc).
16
12
  */
17
13
  export class LeaderboardClient {
18
- private program: Program<ValidatorLeaderboard>;
14
+ private program: Program<ValidatorLeaderboardClientIdl>;
19
15
 
20
- constructor(private provider: AnchorProvider) {
21
- const svc = new SolanaProgramService(provider);
22
- this.program = svc.getProgram('validatorLeaderboard');
16
+ constructor(
17
+ private readonly provider: AnchorProvider,
18
+ private readonly pgs: SolanaProgramService
19
+ ) {
20
+ this.program = pgs.getProgram('validatorLeaderboard');
23
21
  }
24
22
 
25
23
  async getState(): Promise<LeaderboardState | null> {
26
- const pda = deriveLeaderboardStatePda();
24
+ const pda = this.pgs.deriveLeaderboardStatePda();
27
25
  try {
28
26
  // Assumes account name "leaderboardState"
29
27
  return await this.program.account.leaderboardState.fetch(pda);
@@ -33,7 +31,7 @@ export class LeaderboardClient {
33
31
  }
34
32
 
35
33
  async getValidatorRecord(voteAccount: PublicKey): Promise<ValidatorRecord | null> {
36
- const pda = deriveValidatorRecordPda(voteAccount);
34
+ const pda = this.pgs.deriveValidatorRecordPda(voteAccount);
37
35
  try {
38
36
  // Assumes account name "validatorRecord"
39
37
  return await this.program.account.validatorRecord.fetchNullable(pda);
@@ -57,7 +55,7 @@ export class LeaderboardClient {
57
55
  async getTopValidators(limit = 20): Promise<ValidatorRecord[]> {
58
56
  // Try to use the leaderboard state first
59
57
  try {
60
- const leaderboardPda = deriveLeaderboardStatePda();
58
+ const leaderboardPda = this.pgs.deriveLeaderboardStatePda();
61
59
  const leaderboard: LeaderboardState
62
60
  = await this.program.account.leaderboardState.fetch(leaderboardPda);
63
61
 
@@ -9,8 +9,7 @@ import {
9
9
  TOKEN_2022_PROGRAM_ID,
10
10
  } from '@solana/spl-token';
11
11
 
12
- import liqsolCoreIDL from '../../../assets/solana/idl/liqsol_core.json';
13
- import { LiqsolCore } from '../../../assets/solana/types/liqsol_core';
12
+ import { LiqsolCore } from '../../../assets/solana/devnet/types/liqsol_core';
14
13
 
15
14
  import {
16
15
  OutpostAccounts,
@@ -23,7 +22,8 @@ import {
23
22
  TrancheState,
24
23
  WalletLike,
25
24
  } from '../types';
26
- import { INDEX_SCALE, PROGRAM_IDS } from '../constants';
25
+ import { INDEX_SCALE } from '../constants';
26
+ import { LiqsolCoreClientIdl, SolanaProgramService } from '../program';
27
27
 
28
28
  /**
29
29
  * OutpostClient
@@ -41,12 +41,13 @@ import { INDEX_SCALE, PROGRAM_IDS } from '../constants';
41
41
  * in sync with the on-chain PDAs and capital-staking Wire utils.
42
42
  */
43
43
  export class OutpostClient {
44
- private readonly program: Program<LiqsolCore>;
44
+ private readonly program: Program<LiqsolCoreClientIdl>;
45
45
 
46
46
  constructor(
47
47
  private readonly provider: AnchorProvider,
48
+ private readonly pgs: SolanaProgramService,
48
49
  ) {
49
- this.program = new Program(liqsolCoreIDL as any, provider);
50
+ this.program = pgs.getProgram('liqsolCore');
50
51
  }
51
52
 
52
53
  get connection() {
@@ -57,14 +58,6 @@ export class OutpostClient {
57
58
  return this.provider.wallet as unknown as WalletLike;
58
59
  }
59
60
 
60
- /**
61
- * Expose the raw Program in case callers need to build custom
62
- * instructions outside this client.
63
- */
64
- get liqsolCoreProgram(): Program<LiqsolCore> {
65
- return this.program;
66
- }
67
-
68
61
  /**
69
62
  * Build all outpost-related PDAs / ATAs for a given user.
70
63
  * Defaults to the connected wallet.
@@ -74,7 +67,7 @@ export class OutpostClient {
74
67
  if (!userPk) {
75
68
  throw new Error('OutpostClient.buildAccounts: wallet not connected');
76
69
  }
77
- return buildOutpostAccounts(this.connection, userPk);
70
+ return buildOutpostAccounts(this.connection, userPk, this.pgs);
78
71
  }
79
72
 
80
73
  /**
@@ -170,8 +163,8 @@ export class OutpostClient {
170
163
  senderUserRecord: a.userUserRecord,
171
164
  receiverUserRecord: a.liqsolPoolUserRecord,
172
165
  extraAccountMetaList: a.extraAccountMetaList,
173
- liqsolCoreProgram: PROGRAM_IDS.LIQSOL_CORE,
174
- transferHookProgram: PROGRAM_IDS.TRANSFER_HOOK,
166
+ liqsolCoreProgram: this.pgs.PROGRAM_IDS.LIQSOL_CORE,
167
+ transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
175
168
  liqsolPoolAta: a.liqsolPoolAta,
176
169
  outpostAccount: a.outpostAccount,
177
170
  tokenProgram: TOKEN_2022_PROGRAM_ID,
@@ -211,12 +204,13 @@ export class OutpostClient {
211
204
  senderUserRecord: a.liqsolPoolUserRecord,
212
205
  receiverUserRecord: a.userUserRecord,
213
206
  extraAccountMetaList: a.extraAccountMetaList,
214
- liqsolCoreProgram: PROGRAM_IDS.LIQSOL_CORE,
215
- transferHookProgram: PROGRAM_IDS.TRANSFER_HOOK,
207
+ liqsolCoreProgram: this.pgs.PROGRAM_IDS.LIQSOL_CORE,
208
+ transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
216
209
  liqsolPoolAta: a.liqsolPoolAta,
217
210
  outpostAccount: a.outpostAccount,
218
211
  tokenProgram: TOKEN_2022_PROGRAM_ID,
219
212
  systemProgram: SystemProgram.programId,
213
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
220
214
  })
221
215
  .instruction();
222
216
  }
@@ -277,7 +271,7 @@ export class OutpostClient {
277
271
  * if remainder > 0 → shares + 1
278
272
  */
279
273
  static tokensToShares(amount: BN, currentIndex: BN): BN {
280
- const numerator = amount.mul(INDEX_SCALE);
274
+ const numerator = amount.mul(new BN(INDEX_SCALE));
281
275
  const shares = numerator.div(currentIndex);
282
276
  const remainder = numerator.mod(currentIndex);
283
277
  return remainder.eqn(0) ? shares : shares.addn(1);
@@ -11,8 +11,8 @@ import {
11
11
  type OutpostAccounts,
12
12
  } from '../utils';
13
13
 
14
- import { SolanaProgramService } from '../program';
15
- import type { LiqsolCore } from '../../../assets/solana/types/liqsol_core';
14
+ import { LiqsolCoreClientIdl, SolanaProgramService } from '../program';
15
+ import type { LiqsolCore } from '../../../assets/solana/devnet/types/liqsol_core';
16
16
 
17
17
  import {
18
18
  GlobalState,
@@ -24,16 +24,12 @@ import {
24
24
  } from '../types';
25
25
 
26
26
  import {
27
- derivePriceHistoryPda,
28
27
  CHAINLINK_FEED,
29
28
  CHAINLINK_PROGRAM,
30
- PROGRAM_IDS,
31
- deriveExtraAccountMetaListPda,
32
29
  } from '../constants';
33
30
 
34
-
35
31
  export class TokenClient {
36
- private readonly program: Program<LiqsolCore>;
32
+ private readonly program: Program<LiqsolCoreClientIdl>;
37
33
 
38
34
  get wallet(): WalletLike {
39
35
  return this.provider.wallet;
@@ -43,9 +39,11 @@ export class TokenClient {
43
39
  return this.provider.connection;
44
40
  }
45
41
 
46
- constructor(private readonly provider: AnchorProvider) {
47
- const svc = new SolanaProgramService(provider);
48
- this.program = svc.getProgram('liqsolCore');
42
+ constructor(
43
+ private readonly provider: AnchorProvider,
44
+ private readonly pgs: SolanaProgramService
45
+ ) {
46
+ this.program = pgs.getProgram('liqsolCore');
49
47
  }
50
48
 
51
49
  // ---------------------------------------------------------------------------
@@ -53,7 +51,7 @@ export class TokenClient {
53
51
  // ---------------------------------------------------------------------------
54
52
 
55
53
  async getAccounts(user: PublicKey): Promise<OutpostAccounts> {
56
- return buildOutpostAccounts(this.provider.connection, user);
54
+ return buildOutpostAccounts(this.provider.connection, user, this.pgs);
57
55
  }
58
56
 
59
57
  async fetchGlobalState(): Promise<GlobalState> {
@@ -104,9 +102,9 @@ export class TokenClient {
104
102
  ): Promise<TransactionInstruction> {
105
103
  const a = await this.getAccounts(user);
106
104
 
107
- const extraAccountMetaList = deriveExtraAccountMetaListPda(a.liqsolMint);
108
- const liqsolCoreProgram = PROGRAM_IDS.LIQSOL_CORE;
109
- const transferHookProgram = PROGRAM_IDS.TRANSFER_HOOK;
105
+ const extraAccountMetaList = this.pgs.deriveExtraAccountMetaListPda(a.liqsolMint);
106
+ const liqsolCoreProgram = this.pgs.PROGRAM_IDS.LIQSOL_CORE;
107
+ const transferHookProgram = this.pgs.PROGRAM_IDS.TRANSFER_HOOK;
110
108
 
111
109
  return this.program.methods
112
110
  .purchase(new BN(amountLamports.toString()))
@@ -177,7 +175,7 @@ export class TokenClient {
177
175
  * Uses the ring-buffer semantics from capital-staking.
178
176
  */
179
177
  async getSolPriceUsd(): Promise<bigint> {
180
- const priceHistoryPda = derivePriceHistoryPda();
178
+ const priceHistoryPda = this.pgs.derivePriceHistoryPda();
181
179
  const history = (await this.program.account.priceHistory.fetch(
182
180
  priceHistoryPda,
183
181
  )) as PriceHistory;
@@ -1,40 +1,58 @@
1
1
  // src/networks/solana/constants.ts
2
2
  import { PublicKey, StakeProgram } from '@solana/web3.js';
3
+ import { SolChainID } from '@wireio/core';
3
4
 
4
- import liqsolCoreIDL from '../../assets/solana/idl/liqsol_core.json';
5
- import liqSolTokenIDL from '../../assets/solana/idl/liqsol_token.json';
6
- import validatorLeaderboardIDL from '../../assets/solana/idl/validator_leaderboard.json';
7
- import transferHookIDL from '../../assets/solana/idl/transfer_hook.json';
5
+ import mainnetLiqsolCoreIDL from '../../assets/solana/mainnet/idl/liqsol_core.json';
6
+ import mainnetLiqSolTokenIDL from '../../assets/solana/mainnet/idl/liqsol_token.json';
7
+ import mainnetValidatorLeaderboardIDL from '../../assets/solana/mainnet/idl/validator_leaderboard.json';
8
+ import mainnetTransferHookIDL from '../../assets/solana/mainnet/idl/transfer_hook.json';
9
+
10
+ import devnetLiqsolCoreIDL from '../../assets/solana/devnet/idl/liqsol_core.json';
11
+ import devnetLiqSolTokenIDL from '../../assets/solana/devnet/idl/liqsol_token.json';
12
+ import devnetValidatorLeaderboardIDL from '../../assets/solana/devnet/idl/validator_leaderboard.json';
13
+ import devnetTransferHookIDL from '../../assets/solana/devnet/idl/transfer_hook.json';
14
+ import { SupportedSolChainID } from '../../types';
8
15
 
9
16
  /**
10
- * ---------------------------------------------------------------------------
11
- * PROGRAM IDS
12
- * ---------------------------------------------------------------------------
13
- *
14
- * These should match:
15
- * - `metadata.address` in your Anchor IDLs under src/assets/solana/idl/*.json
16
- * - The program IDs printed by your deploy scripts
17
+ * Per-chain program IDs (NOT global anymore).
17
18
  */
18
- export const PROGRAM_IDS = {
19
- LIQSOL_CORE: new PublicKey(liqsolCoreIDL.address),
20
- LIQSOL_TOKEN: new PublicKey(liqSolTokenIDL.address),
21
- VALIDATOR_LEADERBOARD: new PublicKey(validatorLeaderboardIDL.address),
22
- TRANSFER_HOOK: new PublicKey(transferHookIDL.address),
23
- } as const;
19
+ export type SolanaProgramIds = {
20
+ LIQSOL_CORE: PublicKey;
21
+ LIQSOL_TOKEN: PublicKey;
22
+ VALIDATOR_LEADERBOARD: PublicKey;
23
+ TRANSFER_HOOK: PublicKey;
24
+ };
24
25
 
25
- export const {
26
- LIQSOL_CORE,
27
- LIQSOL_TOKEN,
28
- VALIDATOR_LEADERBOARD,
29
- TRANSFER_HOOK,
30
- } = PROGRAM_IDS;
26
+ const MAINNET_PROGRAM_IDS: SolanaProgramIds = {
27
+ LIQSOL_CORE: new PublicKey(mainnetLiqsolCoreIDL.address),
28
+ LIQSOL_TOKEN: new PublicKey(mainnetLiqSolTokenIDL.address),
29
+ VALIDATOR_LEADERBOARD: new PublicKey(mainnetValidatorLeaderboardIDL.address),
30
+ TRANSFER_HOOK: new PublicKey(mainnetTransferHookIDL.address),
31
+ };
32
+
33
+ const DEVNET_PROGRAM_IDS: SolanaProgramIds = {
34
+ LIQSOL_CORE: new PublicKey(devnetLiqsolCoreIDL.address),
35
+ LIQSOL_TOKEN: new PublicKey(devnetLiqSolTokenIDL.address),
36
+ VALIDATOR_LEADERBOARD: new PublicKey(devnetValidatorLeaderboardIDL.address),
37
+ TRANSFER_HOOK: new PublicKey(devnetTransferHookIDL.address),
38
+ };
39
+
40
+ export const PROGRAM_IDS_BY_CHAIN: Record<SupportedSolChainID, SolanaProgramIds> = {
41
+ [SolChainID.Mainnet]: MAINNET_PROGRAM_IDS,
42
+ [SolChainID.Devnet]: DEVNET_PROGRAM_IDS,
43
+ };
44
+
45
+ export const getProgramIds = (chainId: SolChainID): SolanaProgramIds => {
46
+ const ids = PROGRAM_IDS_BY_CHAIN[chainId];
47
+ if (!ids) throw new Error(`Unsupported Solana chainId=${chainId}`);
48
+ return ids;
49
+ };
31
50
 
32
51
  /**
33
52
  * ---------------------------------------------------------------------------
34
53
  * PDA SEEDS (must match on-chain programs)
35
54
  * ---------------------------------------------------------------------------
36
55
  */
37
-
38
56
  export const PDA_SEEDS = {
39
57
  // GLOBAL CONFIG
40
58
  GLOBAL_CONFIG: 'global_config',
@@ -53,7 +71,6 @@ export const PDA_SEEDS = {
53
71
 
54
72
  // distribution program (embedded in liqsol_core)
55
73
  DISTRIBUTION_STATE: 'distribution_state',
56
- // NOTE: in the current IDL, userRecord is keyed by the USER (wallet), not ATA
57
74
  USER_RECORD: 'user_record',
58
75
 
59
76
  // pay-rate / price history
@@ -91,257 +108,9 @@ export const PDA_SEEDS = {
91
108
  WITHDRAW_MINT: 'mint',
92
109
  } as const;
93
110
 
94
- // Global Config PDA
95
- export const deriveGlobalConfigPda = () =>
96
- PublicKey.findProgramAddressSync(
97
- [Buffer.from(PDA_SEEDS.GLOBAL_CONFIG)],
98
- LIQSOL_CORE,
99
- )[0];
100
-
101
-
102
- /**
103
- * ---------------------------------------------------------------------------
104
- * CORE / DISTRIBUTION / DEPOSIT PDAS
105
- * ---------------------------------------------------------------------------
106
- */
107
-
108
- export const deriveLiqsolMintPda = () =>
109
- PublicKey.findProgramAddressSync(
110
- [Buffer.from(PDA_SEEDS.LIQSOL_MINT)],
111
- LIQSOL_TOKEN,
112
- )[0];
113
-
114
- export const deriveLiqsolMintAuthorityPda = () =>
115
- PublicKey.findProgramAddressSync(
116
- [Buffer.from(PDA_SEEDS.LIQSOL_MINT_AUTHORITY)],
117
- LIQSOL_TOKEN,
118
- )[0];
119
-
120
- export const deriveDepositAuthorityPda = () =>
121
- PublicKey.findProgramAddressSync(
122
- [Buffer.from(PDA_SEEDS.DEPOSIT_AUTHORITY)],
123
- LIQSOL_CORE,
124
- )[0];
125
-
126
- export const deriveVaultPda = () =>
127
- PublicKey.findProgramAddressSync(
128
- [Buffer.from(PDA_SEEDS.VAULT)],
129
- LIQSOL_CORE,
130
- )[0];
131
-
132
- export const deriveReservePoolPda = () =>
133
- PublicKey.findProgramAddressSync(
134
- [Buffer.from(PDA_SEEDS.RESERVE_POOL)],
135
- LIQSOL_CORE,
136
- )[0];
137
-
138
- export const deriveStakeControllerStatePda = () =>
139
- PublicKey.findProgramAddressSync(
140
- [Buffer.from(PDA_SEEDS.STAKE_CONTROLLER_STATE)],
141
- LIQSOL_CORE,
142
- )[0];
143
-
144
- export const derivePayoutStatePda = () =>
145
- PublicKey.findProgramAddressSync(
146
- [Buffer.from(PDA_SEEDS.PAYOUT_STATE)],
147
- LIQSOL_CORE,
148
- )[0];
149
-
150
- export const deriveBucketAuthorityPda = () =>
151
- PublicKey.findProgramAddressSync(
152
- [Buffer.from(PDA_SEEDS.BUCKET_AUTHORITY)],
153
- LIQSOL_CORE,
154
- )[0];
155
-
156
- export const deriveDistributionStatePda = () =>
157
- PublicKey.findProgramAddressSync(
158
- [Buffer.from(PDA_SEEDS.DISTRIBUTION_STATE)],
159
- LIQSOL_CORE,
160
- )[0];
161
-
162
- /**
163
- * user_record PDA
164
- *
165
- * In the current liqsol_core IDL, this is keyed by USER (wallet),
166
- * not by token account.
167
- */
168
- export const deriveUserRecordPda = (user: PublicKey) =>
169
- PublicKey.findProgramAddressSync(
170
- [Buffer.from(PDA_SEEDS.USER_RECORD), user.toBuffer()],
171
- LIQSOL_CORE,
172
- )[0];
173
-
174
- export const derivePayRateHistoryPda = () =>
175
- PublicKey.findProgramAddressSync(
176
- [Buffer.from(PDA_SEEDS.PAY_RATE_HISTORY)],
177
- LIQSOL_CORE,
178
- )[0];
179
-
180
- /**
181
- * ---------------------------------------------------------------------------
182
- * WITHDRAW MODULE / RECEIPTS
183
- * ---------------------------------------------------------------------------
184
- */
185
-
186
- export const deriveWithdrawGlobalPda = () =>
187
- PublicKey.findProgramAddressSync(
188
- [Buffer.from(PDA_SEEDS.WITHDRAW_GLOBAL)],
189
- LIQSOL_CORE,
190
- )[0];
191
-
192
- export const deriveStakeAllocationStatePda = () =>
193
- PublicKey.findProgramAddressSync(
194
- [Buffer.from(PDA_SEEDS.STAKE_ALLOCATION_STATE)],
195
- LIQSOL_CORE,
196
- )[0];
197
-
198
- export const deriveStakeMetricsPda = () =>
199
- PublicKey.findProgramAddressSync(
200
- [Buffer.from(PDA_SEEDS.STAKE_METRICS)],
201
- LIQSOL_CORE,
202
- )[0];
203
-
204
- export const deriveMaintenanceLedgerPda = () =>
205
- PublicKey.findProgramAddressSync(
206
- [Buffer.from(PDA_SEEDS.MAINTENANCE_LEDGER)],
207
- LIQSOL_CORE,
208
- )[0];
209
-
210
- export const deriveWithdrawMintAuthorityPda = () =>
211
- PublicKey.findProgramAddressSync(
212
- [Buffer.from(PDA_SEEDS.WITHDRAW_MINT_AUTHORITY)],
213
- LIQSOL_CORE,
214
- )[0];
215
-
216
- export const deriveWithdrawMintMetadataPda = () =>
217
- PublicKey.findProgramAddressSync(
218
- [Buffer.from(PDA_SEEDS.MINT_METADATA)],
219
- LIQSOL_CORE,
220
- )[0];
221
-
222
111
  /**
223
- * NFT mint for withdrawal receipt, derived from nextReceiptId.
224
- */
225
- export const deriveWithdrawNftMintPda = (receiptId: bigint | number) => {
226
- const receiptIdBytes = Buffer.alloc(8);
227
- // receiptId comes in as BN or bigint upstream → normalize
228
- const asBigInt =
229
- typeof receiptId === 'bigint'
230
- ? receiptId
231
- : BigInt(receiptId.toString());
232
- receiptIdBytes.writeBigUInt64LE(asBigInt);
233
- return PublicKey.findProgramAddressSync(
234
- [Buffer.from(PDA_SEEDS.WITHDRAW_MINT), receiptIdBytes],
235
- LIQSOL_CORE,
236
- )[0];
237
- };
238
-
239
- export const deriveLiqReceiptDataPda = (nftMint: PublicKey) =>
240
- PublicKey.findProgramAddressSync(
241
- [Buffer.from(PDA_SEEDS.LIQ_RECEIPT_DATA), nftMint.toBuffer()],
242
- LIQSOL_CORE,
243
- )[0];
244
-
245
- /**
246
- * ---------------------------------------------------------------------------
247
- * VALIDATOR LEADERBOARD
248
- * ---------------------------------------------------------------------------
249
- */
250
-
251
- export const deriveLeaderboardStatePda = () =>
252
- PublicKey.findProgramAddressSync(
253
- [Buffer.from(PDA_SEEDS.LEADERBOARD_STATE)],
254
- VALIDATOR_LEADERBOARD,
255
- )[0];
256
-
257
- export const deriveValidatorRecordPda = (voteAccount: PublicKey) =>
258
- PublicKey.findProgramAddressSync(
259
- [Buffer.from(PDA_SEEDS.VALIDATOR_RECORD), voteAccount.toBuffer()],
260
- VALIDATOR_LEADERBOARD,
261
- )[0];
262
-
263
- export const deriveStakeControllerVaultPda = () =>
264
- PublicKey.findProgramAddressSync(
265
- [Buffer.from(PDA_SEEDS.VAULT)],
266
- LIQSOL_CORE,
267
- )[0];
268
-
269
- /**
270
- * ---------------------------------------------------------------------------
271
- * OUTPOST / PRETOKENS
272
- * ---------------------------------------------------------------------------
273
- */
274
-
275
- export const deriveOutpostGlobalStatePda = () =>
276
- PublicKey.findProgramAddressSync(
277
- [Buffer.from(PDA_SEEDS.OUTPOST_GLOBAL_STATE)],
278
- LIQSOL_CORE,
279
- )[0];
280
-
281
- export const deriveOutpostPoolAuthorityPda = () =>
282
- PublicKey.findProgramAddressSync(
283
- [Buffer.from(PDA_SEEDS.LIQSOL_POOL)],
284
- LIQSOL_CORE,
285
- )[0];
286
-
287
- export const deriveOutpostAccountPda = (user: PublicKey) =>
288
- PublicKey.findProgramAddressSync(
289
- [Buffer.from(PDA_SEEDS.OUTPOST_ACCOUNT), user.toBuffer()],
290
- LIQSOL_CORE,
291
- )[0];
292
-
293
- export const deriveUserPretokenRecordPda = (user: PublicKey) =>
294
- PublicKey.findProgramAddressSync(
295
- [Buffer.from(PDA_SEEDS.USER_PRETOKEN_RECORD), user.toBuffer()],
296
- LIQSOL_CORE,
297
- )[0];
298
-
299
- export const deriveTrancheStatePda = () =>
300
- PublicKey.findProgramAddressSync(
301
- [Buffer.from(PDA_SEEDS.TRANCHE_STATE)],
302
- LIQSOL_CORE,
303
- )[0];
304
-
305
- export const derivePriceHistoryPda = () =>
306
- PublicKey.findProgramAddressSync(
307
- [Buffer.from(PDA_SEEDS.PRICE_HISTORY)],
308
- LIQSOL_CORE,
309
- )[0];
310
-
311
- /**
312
- * BAR (bonded actor roles)
313
- */
314
-
315
- export const deriveBarConfigPda = () =>
316
- PublicKey.findProgramAddressSync(
317
- [Buffer.from(PDA_SEEDS.BAR_STATE_SEED)],
318
- LIQSOL_CORE,
319
- )[0];
320
-
321
- export const deriveBondLevelPda = (bondLevelId: number[]) =>
322
- PublicKey.findProgramAddressSync(
323
- [Buffer.from(PDA_SEEDS.BOND_LEVEL_SEED), Buffer.from(bondLevelId)],
324
- LIQSOL_CORE,
325
- )[0];
326
-
327
- export const deriveBondedActorPda = (actor: PublicKey) =>
328
- PublicKey.findProgramAddressSync(
329
- [Buffer.from(PDA_SEEDS.BONDED_ACTOR_SEED), actor.toBuffer()],
330
- LIQSOL_CORE,
331
- )[0];
332
-
333
- /**
334
- * SPL Transfer-hook: extra-account-metas PDA for the liqSOL mint.
335
- */
336
- export const deriveExtraAccountMetaListPda = (liqsolMint: PublicKey) =>
337
- PublicKey.findProgramAddressSync(
338
- [Buffer.from(PDA_SEEDS.EXTRA_ACCOUNT_METAS), liqsolMint.toBuffer()],
339
- PROGRAM_IDS.TRANSFER_HOOK,
340
- )[0];
341
-
342
- /**
343
- * Ephemeral stake account address used per-deposit.
344
- * On-chain convention: seed = `ephemeral_<u32>` under StakeProgram.programId.
112
+ * Ephemeral stake account address seed helper
113
+ * (this one really is global & chain-agnostic).
345
114
  */
346
115
  export const deriveEphemeralStakeAddress = async (
347
116
  user: PublicKey,
@@ -366,22 +135,12 @@ export const CHAINLINK_PROGRAM = new PublicKey(
366
135
  * ECONOMICS & MATH CONSTANTS
367
136
  * ---------------------------------------------------------------------------
368
137
  */
369
-
370
- // Same scale factor used on-chain for pay-rate math
371
138
  export const PAY_RATE_SCALE_FACTOR = BigInt(1_000_000_000_000); // 10^12
372
-
373
- // Default pay rate fallback used in tests & utils
374
139
  export const DEFAULT_AVERAGE_PAY_RATE = BigInt(191_780_821);
375
-
376
- // How many history entries to average when computing expected fee
377
140
  export const DEFAULT_PAY_RATE_LOOKBACK = 5;
378
-
379
- // Rent exemption for ephemeral stake account (lamports)
380
141
  export const EPHEMERAL_RENT_EXEMPTION = 2_282_880;
381
142
 
382
- // For convenience: lamports <-> SOL helpers (no RPC dependency)
383
143
  export const LAMPORTS_PER_SOL = 1_000_000_000;
384
-
385
144
  export const INDEX_SCALE = BigInt(1_000_000_000_000); // 1e12
386
145
 
387
146
  export const lamportsToSol = (lamports: number | bigint): number =>