@wireio/stake 1.0.1 → 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 (190) hide show
  1. package/lib/stake.browser.js +13027 -6773
  2. package/lib/stake.browser.js.map +1 -1
  3. package/lib/stake.d.ts +7627 -646
  4. package/lib/stake.js +13406 -7147
  5. package/lib/stake.js.map +1 -1
  6. package/lib/stake.m.js +13027 -6773
  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/opp.client.ts +20 -21
  19. package/src/networks/ethereum/clients/receipt.client.ts +89 -4
  20. package/src/networks/ethereum/clients/stake.client.ts +1 -0
  21. package/src/networks/ethereum/contract.ts +260 -222
  22. package/src/networks/ethereum/ethereum.ts +121 -104
  23. package/src/networks/ethereum/types.ts +17 -2
  24. package/src/networks/solana/clients/deposit.client.ts +294 -65
  25. package/src/networks/solana/clients/distribution.client.ts +13 -18
  26. package/src/networks/solana/clients/leaderboard.client.ts +9 -11
  27. package/src/networks/solana/clients/outpost.client.ts +11 -10
  28. package/src/networks/solana/clients/token.client.ts +11 -13
  29. package/src/networks/solana/constants.ts +44 -285
  30. package/src/networks/solana/program.ts +365 -26
  31. package/src/networks/solana/solana.ts +213 -69
  32. package/src/networks/solana/types.ts +4 -4
  33. package/src/networks/solana/utils.ts +16 -301
  34. package/src/staker.ts +11 -2
  35. package/src/types.ts +19 -6
  36. /package/src/assets/ethereum/{ABI → mainnet}/common/Base58.sol/Base58.dbg.json +0 -0
  37. /package/src/assets/ethereum/{ABI → mainnet}/common/Base58.sol/Base58.json +0 -0
  38. /package/src/assets/ethereum/{ABI → mainnet}/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.dbg.json +0 -0
  39. /package/src/assets/ethereum/{ABI → mainnet}/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.json +0 -0
  40. /package/src/assets/ethereum/{ABI → mainnet}/common/RestrictedCallers.sol/RestrictedCallers.dbg.json +0 -0
  41. /package/src/assets/ethereum/{ABI → mainnet}/common/RestrictedCallers.sol/RestrictedCallers.json +0 -0
  42. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata.sol/iodata.dbg.json +0 -0
  43. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata.sol/iodata.json +0 -0
  44. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata_util.sol/iodata_util.dbg.json +0 -0
  45. /package/src/assets/ethereum/{ABI → mainnet}/common/iodata_util.sol/iodata_util.json +0 -0
  46. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_data.sol/sysio_data.dbg.json +0 -0
  47. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_data.sol/sysio_data.json +0 -0
  48. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_errors.sol/sysio_errors.dbg.json +0 -0
  49. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_errors.sol/sysio_errors.json +0 -0
  50. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_merkle.sol/sysio_merkle.dbg.json +0 -0
  51. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_merkle.sol/sysio_merkle.json +0 -0
  52. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_name.sol/sysio_name.dbg.json +0 -0
  53. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_name.sol/sysio_name.json +0 -0
  54. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_pubkey.sol/sysio_pubkey.dbg.json +0 -0
  55. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_pubkey.sol/sysio_pubkey.json +0 -0
  56. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_read.sol/sysio_read.dbg.json +0 -0
  57. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_read.sol/sysio_read.json +0 -0
  58. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_tester.sol/SysioTester.dbg.json +0 -0
  59. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_tester.sol/SysioTester.json +0 -0
  60. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_verify.sol/sysio_verify.dbg.json +0 -0
  61. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_verify.sol/sysio_verify.json +0 -0
  62. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_write.sol/sysio_write.dbg.json +0 -0
  63. /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_write.sol/sysio_write.json +0 -0
  64. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/BeaconState.sol/BeaconState.dbg.json +0 -0
  65. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/BeaconState.sol/BeaconState.json +0 -0
  66. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/DepositManager.sol/DepositManager.dbg.json +0 -0
  67. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/DepositManager.sol/DepositManager.json +0 -0
  68. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +0 -0
  69. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +0 -0
  70. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +0 -0
  71. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IAccounting.json +0 -0
  72. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +0 -0
  73. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositContract.json +0 -0
  74. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +0 -0
  75. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositManager.json +0 -0
  76. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +0 -0
  77. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +0 -0
  78. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +0 -0
  79. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20.json +0 -0
  80. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +0 -0
  81. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +0 -0
  82. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +0 -0
  83. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IStakingModule.json +0 -0
  84. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +0 -0
  85. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +0 -0
  86. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +0 -0
  87. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +0 -0
  88. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +0 -0
  89. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/LiqEthCommon.json +0 -0
  90. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +0 -0
  91. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthManaged.sol/LiqEthManaged.json +0 -0
  92. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +0 -0
  93. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.json +0 -0
  94. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +0 -0
  95. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json +0 -0
  96. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/Yield.sol/YieldOracle.dbg.json +0 -0
  97. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/Yield.sol/YieldOracle.json +0 -0
  98. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/accounting.sol/Accounting.dbg.json +0 -0
  99. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/accounting.sol/Accounting.json +0 -0
  100. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/liqEth.sol/LiqEthToken.dbg.json +0 -0
  101. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/liqEth.sol/LiqEthToken.json +0 -0
  102. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/stakingModule.sol/StakingModule.dbg.json +0 -0
  103. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/stakingModule.sol/StakingModule.json +0 -0
  104. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +0 -0
  105. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +0 -0
  106. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +0 -0
  107. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/Uint64BE.json +0 -0
  108. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +0 -0
  109. /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/WithdrawalVault.json +0 -0
  110. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Aggregator.sol/Aggregator.json +0 -0
  111. /package/src/assets/ethereum/{ABI → mainnet}/outpost/BAR.sol/BAR.dbg.json +0 -0
  112. /package/src/assets/ethereum/{ABI → mainnet}/outpost/BAR.sol/BAR.json +0 -0
  113. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Depositor.sol/Depositor.dbg.json +0 -0
  114. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Depositor.sol/Depositor.json +0 -0
  115. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +0 -0
  116. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +0 -0
  117. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +0 -0
  118. /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +0 -0
  119. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPP.sol/OPP.dbg.json +0 -0
  120. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPP.sol/OPP.json +0 -0
  121. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPP.dbg.json +0 -0
  122. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPP.json +0 -0
  123. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +0 -0
  124. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPEndpoint.json +0 -0
  125. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPInbound.dbg.json +0 -0
  126. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPInbound.json +0 -0
  127. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +0 -0
  128. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPReceiver.json +0 -0
  129. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPSender.dbg.json +0 -0
  130. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPSender.json +0 -0
  131. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/OPPCommon.dbg.json +0 -0
  132. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/OPPCommon.json +0 -0
  133. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +0 -0
  134. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpoint.sol/OPPEndpoint.json +0 -0
  135. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +0 -0
  136. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.json +0 -0
  137. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +0 -0
  138. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.json +0 -0
  139. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPErrors.sol/OPPErrors.dbg.json +0 -0
  140. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPErrors.sol/OPPErrors.json +0 -0
  141. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPInbound.sol/OPPInbound.dbg.json +0 -0
  142. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPInbound.sol/OPPInbound.json +0 -0
  143. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +0 -0
  144. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPReceiver.sol/OPPReceiver.json +0 -0
  145. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPSender.sol/OPPSender.dbg.json +0 -0
  146. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPSender.sol/OPPSender.json +0 -0
  147. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +0 -0
  148. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostErrors.sol/OutpostErrors.json +0 -0
  149. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +0 -0
  150. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManaged.sol/OutpostManaged.json +0 -0
  151. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManager.sol/OutpostManager.dbg.json +0 -0
  152. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManager.sol/OutpostManager.json +0 -0
  153. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +0 -0
  154. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json +0 -0
  155. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +0 -0
  156. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostManager.json +0 -0
  157. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +0 -0
  158. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +0 -0
  159. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +0 -0
  160. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.json +0 -0
  161. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +0 -0
  162. /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostOwnable.sol/OutpostOwnable.json +0 -0
  163. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pool.sol/Pool.dbg.json +0 -0
  164. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pool.sol/Pool.json +0 -0
  165. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pretoken.sol/Pretoken.dbg.json +0 -0
  166. /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pretoken.sol/Pretoken.json +0 -0
  167. /package/src/assets/ethereum/{ABI → mainnet}/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +0 -0
  168. /package/src/assets/ethereum/{ABI → mainnet}/outpost/ReceiptNFT.sol/ReceiptNFT.json +0 -0
  169. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +0 -0
  170. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IPretoken.sol/IPretoken.json +0 -0
  171. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +0 -0
  172. /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IWarrant.sol/IWarrant.json +0 -0
  173. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +0 -0
  174. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +0 -0
  175. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +0 -0
  176. /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.json +0 -0
  177. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC1155Token.sol/ERC1155Token.dbg.json +0 -0
  178. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC1155Token.sol/ERC1155Token.json +0 -0
  179. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC20Token.sol/ERC20Token.dbg.json +0 -0
  180. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC20Token.sol/ERC20Token.json +0 -0
  181. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC721Token.sol/ERC721Token.dbg.json +0 -0
  182. /package/src/assets/ethereum/{ABI → mainnet}/token/ERC721Token.sol/ERC721Token.json +0 -0
  183. /package/src/assets/solana/{idl → devnet/idl}/liqsol_core.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_core.ts +0 -0
  188. /package/src/assets/solana/{types → devnet/types}/liqsol_token.ts +0 -0
  189. /package/src/assets/solana/{types → devnet/types}/transfer_hook.ts +0 -0
  190. /package/src/assets/solana/{types → devnet/types}/validator_leaderboard.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { AnchorProvider, BN, Program } from '@coral-xyz/anchor';
1
+ import { AnchorProvider, BN, Program, Wallet } from '@coral-xyz/anchor';
2
2
  import {
3
3
  SystemProgram,
4
4
  Transaction,
@@ -8,52 +8,41 @@ import {
8
8
  SYSVAR_CLOCK_PUBKEY,
9
9
  SYSVAR_RENT_PUBKEY,
10
10
  SYSVAR_STAKE_HISTORY_PUBKEY,
11
+ Connection,
12
+ PublicKey,
13
+ TransactionMessage,
14
+ LAMPORTS_PER_SOL,
15
+ Signer,
11
16
  } from '@solana/web3.js';
17
+
12
18
  import {
13
19
  TOKEN_2022_PROGRAM_ID,
14
20
  ASSOCIATED_TOKEN_PROGRAM_ID,
15
21
  getAssociatedTokenAddressSync,
16
22
  } from '@solana/spl-token';
23
+ import * as multisig from "@sqds/multisig";
17
24
 
18
25
  import { SolanaProgramService } from '../program';
19
- import type { LiqsolCore } from '../../../assets/solana/types/liqsol_core';
26
+ import type { LiqsolCore } from '../../../assets/solana/devnet/types/liqsol_core';
20
27
 
21
- import {
22
- PROGRAM_IDS,
23
- deriveDepositAuthorityPda,
24
- deriveLiqsolMintPda,
25
- deriveLiqsolMintAuthorityPda,
26
- deriveReservePoolPda,
27
- deriveVaultPda,
28
- deriveStakeControllerStatePda,
29
- derivePayoutStatePda,
30
- deriveBucketAuthorityPda,
31
- derivePayRateHistoryPda,
32
- deriveDistributionStatePda,
33
- deriveUserRecordPda,
34
- deriveEphemeralStakeAddress,
35
- deriveWithdrawGlobalPda,
36
- deriveStakeAllocationStatePda,
37
- deriveStakeMetricsPda,
38
- deriveMaintenanceLedgerPda,
39
- deriveWithdrawMintAuthorityPda,
40
- deriveWithdrawMintMetadataPda,
41
- deriveWithdrawNftMintPda,
42
- deriveLiqReceiptDataPda,
43
- deriveGlobalConfigPda,
44
- } from '../constants';
45
28
  import { GlobalAccount, WalletLike } from '../types';
46
29
 
47
30
  export class DepositClient {
48
31
  private program: Program<LiqsolCore>;
49
32
 
33
+ get connection() {
34
+ return this.provider.connection;
35
+ }
36
+
50
37
  get wallet(): WalletLike {
51
38
  return this.provider.wallet;
52
39
  }
53
40
 
54
- constructor(private provider: AnchorProvider) {
55
- const svc = new SolanaProgramService(provider);
56
- this.program = svc.getProgram('liqsolCore');
41
+ constructor(
42
+ private readonly provider: AnchorProvider,
43
+ private readonly pgs: SolanaProgramService
44
+ ) {
45
+ this.program = pgs.getProgram('liqsolCore');
57
46
  }
58
47
 
59
48
  /**
@@ -63,7 +52,7 @@ export class DepositClient {
63
52
  async buildDepositTx(
64
53
  amount: bigint,
65
54
  user = this.wallet.publicKey,
66
- ): Promise<Transaction> {
55
+ ): Promise<TransactionInstruction> {
67
56
  if (!user) {
68
57
  throw new Error(
69
58
  'DepositClient.buildDepositTx: wallet not connected',
@@ -78,16 +67,16 @@ export class DepositClient {
78
67
  // -------------------------------------------------------------
79
68
  // PDAs
80
69
  // -------------------------------------------------------------
81
- const depositAuthority = deriveDepositAuthorityPda();
82
- const liqsolMint = deriveLiqsolMintPda();
83
- const liqsolMintAuthority = deriveLiqsolMintAuthorityPda();
84
- const reservePool = deriveReservePoolPda();
85
- const vault = deriveVaultPda();
86
- const controllerState = deriveStakeControllerStatePda();
87
- const payoutState = derivePayoutStatePda();
88
- const bucketAuthority = deriveBucketAuthorityPda();
89
- const payRateHistory = derivePayRateHistoryPda();
90
- const globalConfig = deriveGlobalConfigPda();
70
+ const depositAuthority = this.pgs.deriveDepositAuthorityPda();
71
+ const liqsolMint = this.pgs.deriveLiqsolMintPda();
72
+ const liqsolMintAuthority = this.pgs.deriveLiqsolMintAuthorityPda();
73
+ const reservePool = this.pgs.deriveReservePoolPda();
74
+ const vault = this.pgs.deriveVaultPda();
75
+ const controllerState = this.pgs.deriveStakeControllerStatePda();
76
+ const payoutState = this.pgs.derivePayoutStatePda();
77
+ const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
78
+ const payRateHistory = this.pgs.derivePayRateHistoryPda();
79
+ const globalConfig = this.pgs.deriveGlobalConfigPda();
91
80
 
92
81
  // -------------------------------------------------------------
93
82
  // Token-2022 ATAs
@@ -95,15 +84,15 @@ export class DepositClient {
95
84
  const userAta = getAssociatedTokenAddressSync(
96
85
  liqsolMint,
97
86
  user,
98
- false,
87
+ true,
99
88
  TOKEN_2022_PROGRAM_ID,
100
89
  );
101
90
 
102
91
  // -------------------------------------------------------------
103
92
  // Distribution state + user_record (KEYED BY TOKEN ACCOUNT)
104
93
  // -------------------------------------------------------------
105
- const distributionState = deriveDistributionStatePda();
106
- const userRecord = deriveUserRecordPda(userAta);
94
+ const distributionState = this.pgs.deriveDistributionStatePda();
95
+ const userRecord = this.pgs.deriveUserRecordPda(userAta);
107
96
 
108
97
  const bucketTokenAccount = getAssociatedTokenAddressSync(
109
98
  liqsolMint,
@@ -116,12 +105,12 @@ export class DepositClient {
116
105
  // Ephemeral stake
117
106
  // -------------------------------------------------------------
118
107
  const seed = Math.floor(Math.random() * 2 ** 32);
119
- const ephemeralStake = await deriveEphemeralStakeAddress(user, seed);
108
+ const ephemeralStake = await this.pgs.deriveEphemeralStakeAddress(user, seed);
120
109
 
121
110
  // -------------------------------------------------------------
122
111
  // BUILD IX (MUST MATCH IDL)
123
112
  // -------------------------------------------------------------
124
- const ix: TransactionInstruction = await this.program.methods
113
+ return await this.program.methods
125
114
  .deposit(new BN(amount.toString()), seed)
126
115
  .accounts({
127
116
  user,
@@ -129,7 +118,7 @@ export class DepositClient {
129
118
  systemProgram: SystemProgram.programId,
130
119
  tokenProgram: TOKEN_2022_PROGRAM_ID,
131
120
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
132
- liqsolProgram: PROGRAM_IDS.LIQSOL_TOKEN,
121
+ liqsolProgram: this.pgs.PROGRAM_IDS.LIQSOL_TOKEN,
133
122
  stakeProgram: StakeProgram.programId,
134
123
  liqsolMint,
135
124
  userAta,
@@ -151,10 +140,130 @@ export class DepositClient {
151
140
  globalConfig
152
141
  })
153
142
  .instruction();
143
+ }
154
144
 
155
- return new Transaction().add(ix);
145
+
146
+
147
+ async buildSquadsDepositProposalTx(params: {
148
+ connection: Connection;
149
+ multisigPda: PublicKey;
150
+ amountLamports: bigint;
151
+ wallet: WalletLikeSigner; // your WalletLikeSigner type
152
+ vaultIndex?: number;
153
+ }): Promise<{
154
+ tx: Transaction;
155
+ transactionIndex: bigint;
156
+ vaultPda: PublicKey;
157
+ }> {
158
+ const { connection, multisigPda, amountLamports, wallet } = params;
159
+ const vaultIndex = params.vaultIndex ?? 0;
160
+
161
+ if (!wallet?.publicKey) throw new Error("wallet.publicKey missing");
162
+ if (!amountLamports || amountLamports <= BigInt(0)) throw new Error("amountLamports must be > 0");
163
+
164
+ // 1) vault PDA
165
+ const [vaultPda] = multisig.getVaultPda({ multisigPda, index: vaultIndex });
166
+
167
+ // 2) build deposit ix where `user` = vaultPda (off-curve OK)
168
+ const depositBuilt = await this.buildDepositIxForUser(amountLamports, vaultPda);
169
+
170
+ // 3) compute next transactionIndex (best-effort; see note below)
171
+ const ms = await multisig.accounts.Multisig.fromAccountAddress(connection, multisigPda);
172
+ const current = BigInt((ms as any).transactionIndex?.toString?.() ?? 0);
173
+ const transactionIndex = current + BigInt(1);
174
+
175
+ // 4) inner message uses vault as payer
176
+ const { blockhash } = await connection.getLatestBlockhash("confirmed");
177
+ const message = new TransactionMessage({
178
+ payerKey: vaultPda,
179
+ recentBlockhash: blockhash,
180
+ instructions: [depositBuilt.ix],
181
+ });
182
+
183
+ // 5) squads instructions (no rpc.*)
184
+ const createVaultTxIx = await multisig.instructions.vaultTransactionCreate({
185
+ multisigPda,
186
+ transactionIndex,
187
+ creator: wallet.publicKey,
188
+ vaultIndex,
189
+ ephemeralSigners: 0,
190
+ transactionMessage: message,
191
+ });
192
+
193
+ // const createProposalIx = await multisig.instructions.proposalCreate({
194
+ // multisigPda,
195
+ // transactionIndex,
196
+ // creator: wallet.publicKey,
197
+ // });
198
+ // console.log('createVaultTxIx', createVaultTxIx);
199
+
200
+
201
+ // 6) return a normal Transaction for your pipeline
202
+ const tx = new Transaction().add(createVaultTxIx);
203
+
204
+ return { tx, transactionIndex, vaultPda };
156
205
  }
157
206
 
207
+ async buildSquadsDepositProposalTx2(params: {
208
+ connection: Connection;
209
+ multisigPda: PublicKey;
210
+ amountLamports: bigint;
211
+ wallet: WalletLikeSigner; // your WalletLikeSigner type
212
+ vaultIndex?: number;
213
+ }): Promise<{
214
+ tx: Transaction;
215
+ transactionIndex: bigint;
216
+ vaultPda: PublicKey;
217
+ }> {
218
+ const { connection, multisigPda, amountLamports, wallet } = params;
219
+ const vaultIndex = params.vaultIndex ?? 0;
220
+
221
+ if (!wallet?.publicKey) throw new Error("wallet.publicKey missing");
222
+ if (!amountLamports || amountLamports <= BigInt(0)) throw new Error("amountLamports must be > 0");
223
+
224
+ // 1) vault PDA
225
+ const [vaultPda] = multisig.getVaultPda({ multisigPda, index: vaultIndex });
226
+
227
+ // 2) build deposit ix where `user` = vaultPda (off-curve OK)
228
+ const depositBuilt = await this.buildDepositIxForUser(amountLamports, vaultPda);
229
+
230
+ // 3) compute next transactionIndex (best-effort; see note below)
231
+ const ms = await multisig.accounts.Multisig.fromAccountAddress(connection, multisigPda);
232
+ const current = BigInt(ms.transactionIndex?.toString?.() ?? 0);
233
+ const transactionIndex = current + BigInt(1);
234
+
235
+ // 4) inner message uses vault as payer
236
+ const { blockhash } = await connection.getLatestBlockhash("confirmed");
237
+ const message = new TransactionMessage({
238
+ payerKey: vaultPda,
239
+ recentBlockhash: blockhash,
240
+ instructions: [depositBuilt.ix],
241
+ });
242
+
243
+ // 5) squads instructions (no rpc.*)
244
+ // const createVaultTxIx = await multisig.instructions.vaultTransactionCreate({
245
+ // multisigPda,
246
+ // transactionIndex,
247
+ // creator: wallet.publicKey,
248
+ // vaultIndex,
249
+ // ephemeralSigners: 0,
250
+ // transactionMessage: message,
251
+ // });
252
+
253
+ const createProposalIx = await multisig.instructions.proposalCreate({
254
+ multisigPda,
255
+ transactionIndex,
256
+ creator: wallet.publicKey,
257
+ });
258
+
259
+ // 6) return a normal Transaction for your pipeline
260
+ const tx = new Transaction().add(createProposalIx);
261
+
262
+ return { tx, transactionIndex, vaultPda };
263
+ }
264
+
265
+
266
+
158
267
  /**
159
268
  * Build a withdraw-request transaction:
160
269
  * liqSOL -> SOL via liqsol_core::requestWithdraw.
@@ -182,33 +291,33 @@ export class DepositClient {
182
291
  // -------------------------------------------------------------
183
292
  // Core program + liqSOL mint / user ATA
184
293
  // -------------------------------------------------------------
185
- const liqsolMint = deriveLiqsolMintPda();
294
+ const liqsolMint = this.pgs.deriveLiqsolMintPda();
186
295
 
187
296
  const userAta = getAssociatedTokenAddressSync(
188
297
  liqsolMint,
189
298
  user,
190
- false,
299
+ true,
191
300
  TOKEN_2022_PROGRAM_ID,
192
301
  );
193
302
 
194
303
  // Distribution / balance-tracking
195
304
  // user_record is keyed by the user’s liqSOL ATA (same convention
196
305
  // as deposit/purchase).
197
- const userRecord = deriveUserRecordPda(userAta);
198
- const distributionState = deriveDistributionStatePda();
306
+ const userRecord = this.pgs.deriveUserRecordPda(userAta);
307
+ const distributionState = this.pgs.deriveDistributionStatePda();
199
308
 
200
309
  // Reserve + stake controller PDAs
201
- const global = deriveWithdrawGlobalPda(); // withdraw operator state
202
- const reservePool = deriveReservePoolPda();
203
- const stakeAllocationState = deriveStakeAllocationStatePda();
204
- const stakeMetrics = deriveStakeMetricsPda();
205
- const maintenanceLedger = deriveMaintenanceLedgerPda();
206
- const globalConfig = deriveGlobalConfigPda(); // liqSOL config / roles
310
+ const global = this.pgs.deriveWithdrawGlobalPda(); // withdraw operator state
311
+ const reservePool = this.pgs.deriveReservePoolPda();
312
+ const stakeAllocationState = this.pgs.deriveStakeAllocationStatePda();
313
+ const stakeMetrics = this.pgs.deriveStakeMetricsPda();
314
+ const maintenanceLedger = this.pgs.deriveMaintenanceLedgerPda();
315
+ const globalConfig = this.pgs.deriveGlobalConfigPda(); // liqSOL config / roles
207
316
 
208
317
  // -------------------------------------------------------------
209
318
  // Need nextReceiptId from withdraw global state
210
319
  // -------------------------------------------------------------
211
- const globalAcct : GlobalAccount = await this.program.account.global.fetch(global);
320
+ const globalAcct: GlobalAccount = await this.program.account.global.fetch(global);
212
321
 
213
322
  const rawId = globalAcct.nextReceiptId;
214
323
  let receiptId: bigint;
@@ -231,22 +340,22 @@ export class DepositClient {
231
340
  // -------------------------------------------------------------
232
341
  // NFT receipt PDAs (mint, metadata, data, ATA)
233
342
  // -------------------------------------------------------------
234
- const mintAuthority = deriveWithdrawMintAuthorityPda();
235
- const metadata = deriveWithdrawMintMetadataPda();
343
+ const mintAuthority = this.pgs.deriveWithdrawMintAuthorityPda();
344
+ const metadata = this.pgs.deriveWithdrawMintMetadataPda();
236
345
 
237
- const nftMint = deriveWithdrawNftMintPda(receiptId);
238
- const receiptData = deriveLiqReceiptDataPda(nftMint);
346
+ const nftMint = this.pgs.deriveWithdrawNftMintPda(receiptId);
347
+ const receiptData = this.pgs.deriveLiqReceiptDataPda(nftMint);
239
348
 
240
349
  const owner = user;
241
350
  const nftAta = getAssociatedTokenAddressSync(
242
351
  nftMint,
243
352
  owner,
244
- false,
353
+ true,
245
354
  TOKEN_2022_PROGRAM_ID,
246
355
  );
247
356
 
248
357
  // Bucket token account (same bucket used by deposit/distribution)
249
- const bucketAuthority = deriveBucketAuthorityPda();
358
+ const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
250
359
  const bucketTokenAccount = getAssociatedTokenAddressSync(
251
360
  liqsolMint,
252
361
  bucketAuthority,
@@ -289,4 +398,124 @@ export class DepositClient {
289
398
 
290
399
  return new Transaction().add(ix);
291
400
  }
292
- }
401
+
402
+
403
+
404
+
405
+
406
+ /**
407
+ * Internal helper: build the liqsol_core::deposit instruction for a specific `user`.
408
+ * This is the exact same account wiring as buildDepositTx(), but returns the IX
409
+ * plus useful this.pgs.derived addresses/seed for Squads flows.
410
+ */
411
+ private async buildDepositIxForUser(
412
+ amount: bigint,
413
+ user: PublicKey,
414
+ ): Promise<{
415
+ ix: TransactionInstruction;
416
+ seed: number;
417
+ userAta: PublicKey;
418
+ ephemeralStake: PublicKey;
419
+ }> {
420
+ if (!user) {
421
+ throw new Error("buildDepositIxForUser: user is required");
422
+ }
423
+ if (!amount || amount <= BigInt(0)) {
424
+ throw new Error("buildDepositIxForUser: amount must be > 0");
425
+ }
426
+
427
+ // -------------------------------------------------------------
428
+ // PDAs
429
+ // -------------------------------------------------------------
430
+ const depositAuthority = this.pgs.deriveDepositAuthorityPda();
431
+ const liqsolMint = this.pgs.deriveLiqsolMintPda();
432
+ const liqsolMintAuthority = this.pgs.deriveLiqsolMintAuthorityPda();
433
+ const reservePool = this.pgs.deriveReservePoolPda();
434
+ const vault = this.pgs.deriveVaultPda();
435
+ const controllerState = this.pgs.deriveStakeControllerStatePda();
436
+ const payoutState = this.pgs.derivePayoutStatePda();
437
+ const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
438
+ const payRateHistory = this.pgs.derivePayRateHistoryPda();
439
+ const globalConfig = this.pgs.deriveGlobalConfigPda();
440
+
441
+ // -------------------------------------------------------------
442
+ // Token-2022 ATAs
443
+ // -------------------------------------------------------------
444
+ const userAta = getAssociatedTokenAddressSync(
445
+ liqsolMint,
446
+ user,
447
+ true,
448
+ TOKEN_2022_PROGRAM_ID,
449
+ );
450
+
451
+ // -------------------------------------------------------------
452
+ // Distribution state + user_record (KEYED BY TOKEN ACCOUNT)
453
+ // -------------------------------------------------------------
454
+ const distributionState = this.pgs.deriveDistributionStatePda();
455
+ const userRecord = this.pgs.deriveUserRecordPda(userAta);
456
+
457
+ const bucketTokenAccount = getAssociatedTokenAddressSync(
458
+ liqsolMint,
459
+ bucketAuthority,
460
+ true,
461
+ TOKEN_2022_PROGRAM_ID,
462
+ );
463
+
464
+ // -------------------------------------------------------------
465
+ // Ephemeral stake
466
+ // -------------------------------------------------------------
467
+ const seed = Math.floor(Math.random() * 2 ** 32);
468
+ const ephemeralStake = await this.pgs.deriveEphemeralStakeAddress(user, seed);
469
+
470
+ // -------------------------------------------------------------
471
+ // BUILD IX (MUST MATCH IDL)
472
+ // -------------------------------------------------------------
473
+ const ix: TransactionInstruction = await this.program.methods
474
+ .deposit(new BN(amount.toString()), seed)
475
+ .accounts({
476
+ user,
477
+ depositAuthority,
478
+ systemProgram: SystemProgram.programId,
479
+ tokenProgram: TOKEN_2022_PROGRAM_ID,
480
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
481
+ liqsolProgram: this.pgs.PROGRAM_IDS.LIQSOL_TOKEN,
482
+ stakeProgram: StakeProgram.programId,
483
+ liqsolMint,
484
+ userAta,
485
+ liqsolMintAuthority,
486
+ reservePool,
487
+ vault,
488
+ ephemeralStake,
489
+ controllerState,
490
+ payoutState,
491
+ bucketAuthority,
492
+ bucketTokenAccount,
493
+ userRecord,
494
+ distributionState,
495
+ payRateHistory,
496
+ instructionsSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
497
+ clock: SYSVAR_CLOCK_PUBKEY,
498
+ stakeHistory: SYSVAR_STAKE_HISTORY_PUBKEY,
499
+ rent: SYSVAR_RENT_PUBKEY,
500
+ globalConfig,
501
+ })
502
+ .instruction();
503
+
504
+ return { ix, seed, userAta, ephemeralStake };
505
+ }
506
+
507
+ }
508
+
509
+ // A “wallet-adapter-like” shape (AnchorProvider.wallet matches this)
510
+ type WalletLikeSigner = {
511
+ publicKey: PublicKey;
512
+ signTransaction: (tx: Transaction) => Promise<Transaction>;
513
+ };
514
+
515
+ function isKeypairSigner(x: any): x is { publicKey: PublicKey; secretKey: Uint8Array } {
516
+ return !!x && x.publicKey instanceof PublicKey && x.secretKey instanceof Uint8Array;
517
+ }
518
+
519
+ function isWalletLikeSigner(x: any): x is WalletLikeSigner {
520
+ return !!x && x.publicKey instanceof PublicKey && typeof x.signTransaction === "function";
521
+ }
@@ -2,14 +2,7 @@ import { AnchorProvider, Program, BN } from '@coral-xyz/anchor';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
 
4
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';
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';
@@ -35,9 +28,11 @@ import { ceilDiv } from '../utils';
35
28
  export class DistributionClient {
36
29
  private program: Program<LiqsolCore>;
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;
@@ -2,11 +2,7 @@ import { AnchorProvider, Program } from '@coral-xyz/anchor';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
 
4
4
  import { SolanaProgramService } from '../program';
5
- import type { ValidatorLeaderboard } from '../../../assets/solana/types/validator_leaderboard';
6
- import {
7
- deriveLeaderboardStatePda,
8
- deriveValidatorRecordPda,
9
- } from '../constants';
5
+ import type { ValidatorLeaderboard } from '../../../assets/solana/devnet/types/validator_leaderboard';
10
6
  import { LeaderboardState, ValidatorRecord } from '../types';
11
7
 
12
8
  /**
@@ -17,13 +13,15 @@ import { LeaderboardState, ValidatorRecord } from '../types';
17
13
  export class LeaderboardClient {
18
14
  private program: Program<ValidatorLeaderboard>;
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