@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.
- package/lib/stake.browser.js +12942 -6703
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +7627 -646
- package/lib/stake.js +13315 -7071
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +12942 -6703
- package/lib/stake.m.js.map +1 -1
- package/package.json +4 -3
- package/src/assets/solana/mainnet/idl/liqsol_core.json +6166 -0
- package/src/assets/solana/mainnet/idl/liqsol_token.json +183 -0
- package/src/assets/solana/mainnet/idl/transfer_hook.json +197 -0
- package/src/assets/solana/mainnet/idl/validator_leaderboard.json +574 -0
- package/src/assets/solana/mainnet/types/liqsol_core.ts +6172 -0
- package/src/assets/solana/mainnet/types/liqsol_token.ts +189 -0
- package/src/assets/solana/mainnet/types/transfer_hook.ts +203 -0
- package/src/assets/solana/mainnet/types/validator_leaderboard.ts +580 -0
- package/src/networks/ethereum/clients/convert.client.ts +30 -1
- package/src/networks/ethereum/clients/receipt.client.ts +81 -3
- package/src/networks/ethereum/clients/stake.client.ts +1 -0
- package/src/networks/ethereum/contract.ts +260 -222
- package/src/networks/ethereum/ethereum.ts +36 -28
- package/src/networks/ethereum/types.ts +17 -2
- package/src/networks/solana/clients/deposit.client.ts +294 -65
- package/src/networks/solana/clients/distribution.client.ts +13 -18
- package/src/networks/solana/clients/leaderboard.client.ts +9 -11
- package/src/networks/solana/clients/outpost.client.ts +11 -10
- package/src/networks/solana/clients/token.client.ts +11 -13
- package/src/networks/solana/constants.ts +44 -285
- package/src/networks/solana/program.ts +365 -26
- package/src/networks/solana/solana.ts +213 -69
- package/src/networks/solana/types.ts +4 -4
- package/src/networks/solana/utils.ts +16 -301
- package/src/staker.ts +10 -2
- package/src/types.ts +19 -6
- /package/src/assets/ethereum/{ABI → mainnet}/common/Base58.sol/Base58.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/Base58.sol/Base58.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/RestrictedCallers.sol/RestrictedCallers.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/RestrictedCallers.sol/RestrictedCallers.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/iodata.sol/iodata.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/iodata.sol/iodata.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/iodata_util.sol/iodata_util.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/iodata_util.sol/iodata_util.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_data.sol/sysio_data.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_data.sol/sysio_data.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_errors.sol/sysio_errors.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_errors.sol/sysio_errors.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_merkle.sol/sysio_merkle.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_merkle.sol/sysio_merkle.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_name.sol/sysio_name.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_name.sol/sysio_name.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_pubkey.sol/sysio_pubkey.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_pubkey.sol/sysio_pubkey.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_read.sol/sysio_read.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_read.sol/sysio_read.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_tester.sol/SysioTester.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_tester.sol/SysioTester.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_verify.sol/sysio_verify.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_verify.sol/sysio_verify.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_write.sol/sysio_write.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/common/sysio_write.sol/sysio_write.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/BeaconState.sol/BeaconState.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/BeaconState.sol/BeaconState.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/DepositManager.sol/DepositManager.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/DepositManager.sol/DepositManager.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IAccounting.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositContract.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IDepositManager.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IStakingModule.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthCommon.sol/LiqEthCommon.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/LiqEthManaged.sol/LiqEthManaged.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/Yield.sol/YieldOracle.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/Yield.sol/YieldOracle.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/accounting.sol/Accounting.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/accounting.sol/Accounting.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/liqEth.sol/LiqEthToken.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/liqEth.sol/LiqEthToken.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/stakingModule.sol/StakingModule.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/stakingModule.sol/StakingModule.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/Uint64BE.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/liqEth/withdrawalVault.sol/WithdrawalVault.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/Aggregator.sol/Aggregator.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/BAR.sol/BAR.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/BAR.sol/BAR.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/Depositor.sol/Depositor.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/Depositor.sol/Depositor.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPP.sol/OPP.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPP.sol/OPP.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPP.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPP.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPEndpoint.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPInbound.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPInbound.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPReceiver.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPSender.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/IOPPSender.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/OPPCommon.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPCommon.sol/OPPCommon.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpoint.sol/OPPEndpoint.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPErrors.sol/OPPErrors.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPErrors.sol/OPPErrors.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPInbound.sol/OPPInbound.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPInbound.sol/OPPInbound.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPReceiver.sol/OPPReceiver.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPSender.sol/OPPSender.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPSender.sol/OPPSender.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostErrors.sol/OutpostErrors.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManaged.sol/OutpostManaged.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManager.sol/OutpostManager.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManager.sol/OutpostManager.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostManager.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostOwnable.sol/OutpostOwnable.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pool.sol/Pool.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pool.sol/Pool.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pretoken.sol/Pretoken.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/Pretoken.sol/Pretoken.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/ReceiptNFT.sol/ReceiptNFT.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IPretoken.sol/IPretoken.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/interfaces/IWarrant.sol/IWarrant.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/token/ERC1155Token.sol/ERC1155Token.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/token/ERC1155Token.sol/ERC1155Token.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/token/ERC20Token.sol/ERC20Token.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/token/ERC20Token.sol/ERC20Token.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/token/ERC721Token.sol/ERC721Token.dbg.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/token/ERC721Token.sol/ERC721Token.json +0 -0
- /package/src/assets/solana/{idl → devnet/idl}/liqsol_core.json +0 -0
- /package/src/assets/solana/{idl → devnet/idl}/liqsol_token.json +0 -0
- /package/src/assets/solana/{idl → devnet/idl}/transfer_hook.json +0 -0
- /package/src/assets/solana/{idl → devnet/idl}/validator_leaderboard.json +0 -0
- /package/src/assets/solana/{types → devnet/types}/liqsol_core.ts +0 -0
- /package/src/assets/solana/{types → devnet/types}/liqsol_token.ts +0 -0
- /package/src/assets/solana/{types → devnet/types}/transfer_hook.ts +0 -0
- /package/src/assets/solana/{types → devnet/types}/validator_leaderboard.ts +0 -0
|
@@ -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(
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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(
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
|
25
|
+
import { INDEX_SCALE } from '../constants';
|
|
26
|
+
import { SolanaProgramService } from '../program';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* OutpostClient
|
|
@@ -45,8 +45,9 @@ export class OutpostClient {
|
|
|
45
45
|
|
|
46
46
|
constructor(
|
|
47
47
|
private readonly provider: AnchorProvider,
|
|
48
|
+
private readonly pgs: SolanaProgramService,
|
|
48
49
|
) {
|
|
49
|
-
this.program =
|
|
50
|
+
this.program = pgs.getProgram('liqsolCore');
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
get connection() {
|
|
@@ -74,7 +75,7 @@ export class OutpostClient {
|
|
|
74
75
|
if (!userPk) {
|
|
75
76
|
throw new Error('OutpostClient.buildAccounts: wallet not connected');
|
|
76
77
|
}
|
|
77
|
-
return buildOutpostAccounts(this.connection, userPk);
|
|
78
|
+
return buildOutpostAccounts(this.connection, userPk, this.pgs);
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
/**
|
|
@@ -170,8 +171,8 @@ export class OutpostClient {
|
|
|
170
171
|
senderUserRecord: a.userUserRecord,
|
|
171
172
|
receiverUserRecord: a.liqsolPoolUserRecord,
|
|
172
173
|
extraAccountMetaList: a.extraAccountMetaList,
|
|
173
|
-
liqsolCoreProgram: PROGRAM_IDS.LIQSOL_CORE,
|
|
174
|
-
transferHookProgram: PROGRAM_IDS.TRANSFER_HOOK,
|
|
174
|
+
liqsolCoreProgram: this.pgs.PROGRAM_IDS.LIQSOL_CORE,
|
|
175
|
+
transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
|
|
175
176
|
liqsolPoolAta: a.liqsolPoolAta,
|
|
176
177
|
outpostAccount: a.outpostAccount,
|
|
177
178
|
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
@@ -211,8 +212,8 @@ export class OutpostClient {
|
|
|
211
212
|
senderUserRecord: a.liqsolPoolUserRecord,
|
|
212
213
|
receiverUserRecord: a.userUserRecord,
|
|
213
214
|
extraAccountMetaList: a.extraAccountMetaList,
|
|
214
|
-
liqsolCoreProgram: PROGRAM_IDS.LIQSOL_CORE,
|
|
215
|
-
transferHookProgram: PROGRAM_IDS.TRANSFER_HOOK,
|
|
215
|
+
liqsolCoreProgram: this.pgs.PROGRAM_IDS.LIQSOL_CORE,
|
|
216
|
+
transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
|
|
216
217
|
liqsolPoolAta: a.liqsolPoolAta,
|
|
217
218
|
outpostAccount: a.outpostAccount,
|
|
218
219
|
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
@@ -277,7 +278,7 @@ export class OutpostClient {
|
|
|
277
278
|
* if remainder > 0 → shares + 1
|
|
278
279
|
*/
|
|
279
280
|
static tokensToShares(amount: BN, currentIndex: BN): BN {
|
|
280
|
-
const numerator = amount.mul(INDEX_SCALE);
|
|
281
|
+
const numerator = amount.mul(new BN(INDEX_SCALE));
|
|
281
282
|
const shares = numerator.div(currentIndex);
|
|
282
283
|
const remainder = numerator.mod(currentIndex);
|
|
283
284
|
return remainder.eqn(0) ? shares : shares.addn(1);
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from '../utils';
|
|
13
13
|
|
|
14
14
|
import { SolanaProgramService } from '../program';
|
|
15
|
-
import type { LiqsolCore } from '../../../assets/solana/types/liqsol_core';
|
|
15
|
+
import type { LiqsolCore } from '../../../assets/solana/devnet/types/liqsol_core';
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
GlobalState,
|
|
@@ -24,14 +24,10 @@ 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
32
|
private readonly program: Program<LiqsolCore>;
|
|
37
33
|
|
|
@@ -43,9 +39,11 @@ export class TokenClient {
|
|
|
43
39
|
return this.provider.connection;
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
constructor(
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
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
|
|
19
|
-
LIQSOL_CORE:
|
|
20
|
-
LIQSOL_TOKEN:
|
|
21
|
-
VALIDATOR_LEADERBOARD:
|
|
22
|
-
TRANSFER_HOOK:
|
|
23
|
-
}
|
|
19
|
+
export type SolanaProgramIds = {
|
|
20
|
+
LIQSOL_CORE: PublicKey;
|
|
21
|
+
LIQSOL_TOKEN: PublicKey;
|
|
22
|
+
VALIDATOR_LEADERBOARD: PublicKey;
|
|
23
|
+
TRANSFER_HOOK: PublicKey;
|
|
24
|
+
};
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
LIQSOL_CORE,
|
|
27
|
-
LIQSOL_TOKEN,
|
|
28
|
-
VALIDATOR_LEADERBOARD,
|
|
29
|
-
TRANSFER_HOOK,
|
|
30
|
-
}
|
|
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
|
-
*
|
|
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 =>
|