@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.
- package/lib/stake.browser.js +12958 -6707
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +7612 -639
- package/lib/stake.js +13324 -7073
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +12958 -6707
- package/lib/stake.m.js.map +1 -1
- package/package.json +4 -3
- package/src/assets/solana/{idl → devnet/idl}/liqsol_core.json +15 -3
- package/src/assets/solana/{types → devnet/types}/liqsol_core.ts +15 -3
- package/src/assets/solana/mainnet/idl/liqsol_core.json +6178 -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 +6184 -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 +35 -30
- package/src/networks/ethereum/types.ts +17 -2
- package/src/networks/solana/clients/deposit.client.ts +294 -68
- package/src/networks/solana/clients/distribution.client.ts +15 -20
- package/src/networks/solana/clients/leaderboard.client.ts +11 -13
- package/src/networks/solana/clients/outpost.client.ts +13 -19
- package/src/networks/solana/clients/token.client.ts +13 -15
- package/src/networks/solana/constants.ts +44 -285
- package/src/networks/solana/program.ts +382 -28
- package/src/networks/solana/solana.ts +315 -92
- 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_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_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
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
TrancheSnapshot
|
|
9
9
|
} from '../../types';
|
|
10
10
|
import { EthereumContractService } from './contract';
|
|
11
|
-
import { preLaunchReceipt } from './types';
|
|
11
|
+
import { preLaunchReceipt, WithdrawReceipt } from './types';
|
|
12
12
|
import { buildEthereumTrancheSnapshot } from './utils';
|
|
13
13
|
import { ConvertClient } from './clients/convert.client';
|
|
14
14
|
import { StakeClient } from './clients/stake.client';
|
|
@@ -48,6 +48,7 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
48
48
|
this.contractService = new EthereumContractService({
|
|
49
49
|
provider: this.provider,
|
|
50
50
|
signer: this.signer,
|
|
51
|
+
chainId: config.network.chainId as EvmChainID,
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
this.convertClient = new ConvertClient(this.contractService);
|
|
@@ -98,6 +99,31 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
98
99
|
return result.txHash;
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Withdraw native ETH from the liqETH protocol via the liqeth safeBurn function, which burns the LiqETH and adds the user to the withdrawal queue.
|
|
104
|
+
* @param amount Amount in wei (or something convertible to BigNumber).
|
|
105
|
+
* @returns transaction hash
|
|
106
|
+
*/
|
|
107
|
+
async loadPendingWithdraws(): Promise<WithdrawReceipt[]> {
|
|
108
|
+
this.ensureUser();
|
|
109
|
+
const address = await this.signer!.getAddress();
|
|
110
|
+
|
|
111
|
+
return await this.receiptClient.fetchWithdrawReceipts(address);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Withdraw native ETH from the liqETH protocol via the liqeth safeBurn function, which burns the LiqETH and adds the user to the withdrawal queue.
|
|
116
|
+
* @param tokenId The ID of the withdrawal request NFT
|
|
117
|
+
* @returns transaction hash
|
|
118
|
+
*/
|
|
119
|
+
async claimWithdraw(tokenId: bigint): Promise<string> {
|
|
120
|
+
this.ensureUser();
|
|
121
|
+
|
|
122
|
+
const tokenIdBigNum = BigNumber.from(tokenId)
|
|
123
|
+
const result = await this.convertClient.claimWithdraw(tokenIdBigNum)
|
|
124
|
+
return result.txHash;
|
|
125
|
+
}
|
|
126
|
+
|
|
101
127
|
|
|
102
128
|
/**
|
|
103
129
|
* Stake liqETH via DepositManager.
|
|
@@ -213,17 +239,14 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
213
239
|
// sharesToTokens(userShares, currentIndex) = userShares * currentIndex / indexScale
|
|
214
240
|
let estimatedClaim = BigInt(0);
|
|
215
241
|
let estimatedYield = BigInt(0);
|
|
242
|
+
|
|
243
|
+
if (userShares > BigInt(0) && currentIndex > BigInt(0)) {
|
|
244
|
+
estimatedClaim = (userShares * currentIndex) / indexScale;
|
|
245
|
+
if (estimatedClaim > stakeBalanceBN.toBigInt()) {
|
|
246
|
+
estimatedYield = estimatedClaim - stakeBalanceBN.toBigInt();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
216
249
|
|
|
217
|
-
// started work on estimating the user's personal APY - not necessary at the moment
|
|
218
|
-
// let estimatedAPY: number | null = null;
|
|
219
|
-
// if (userShares > BigInt(0) && currentIndex > BigInt(0)) {
|
|
220
|
-
// estimatedClaim = (userShares * currentIndex) / indexScale;
|
|
221
|
-
// if (estimatedClaim > stakeBalanceBN.toBigInt()) {
|
|
222
|
-
// estimatedYield = estimatedClaim - stakeBalanceBN.toBigInt();
|
|
223
|
-
// }
|
|
224
|
-
|
|
225
|
-
// estimatedAPY = null;
|
|
226
|
-
// }
|
|
227
250
|
|
|
228
251
|
const portfolio: Portfolio = {
|
|
229
252
|
native: {
|
|
@@ -342,24 +365,11 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
342
365
|
*
|
|
343
366
|
* SUPPORTS READ-ONLY ACcESS
|
|
344
367
|
*/
|
|
345
|
-
async getTrancheSnapshot(
|
|
346
|
-
chainID?: ChainID;
|
|
347
|
-
windowBefore?: number;
|
|
348
|
-
windowAfter?: number;
|
|
349
|
-
}): Promise<TrancheSnapshot> {
|
|
350
|
-
const {
|
|
351
|
-
chainID = EvmChainID.Ethereum,
|
|
352
|
-
windowBefore,
|
|
353
|
-
windowAfter,
|
|
354
|
-
} = options ?? {};
|
|
355
|
-
|
|
356
|
-
|
|
368
|
+
async getTrancheSnapshot(chainID: ChainID): Promise<TrancheSnapshot> {
|
|
357
369
|
try {
|
|
358
|
-
|
|
359
370
|
const blockNumber = await this.provider.getBlockNumber();
|
|
360
371
|
const blockTag = { blockTag: blockNumber };
|
|
361
372
|
|
|
362
|
-
|
|
363
373
|
// Fetch all required contract data
|
|
364
374
|
const [totalSharesBn, indexBn, trancheNumberBn, trancheSupplyBn, tranchePriceUsdBn, totalSupplyBn, supplyGrowthBps, priceGrowthCents, minPriceUsd, maxPriceUsd] = await Promise.all([
|
|
365
375
|
this.contract.Depositor.totalShares(blockTag),
|
|
@@ -377,7 +387,6 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
377
387
|
const totalTrancheSupply = BigInt(totalSupplyBn.toString()) / BigInt(1e10);
|
|
378
388
|
const currentTrancheSupply = BigInt(trancheSupplyBn.toString()) / BigInt(1e10);
|
|
379
389
|
|
|
380
|
-
|
|
381
390
|
// fetch price and timestamp from aggregator
|
|
382
391
|
// const [roundId, answer, startedAt, updatedAt, answeredInRound] = await this.contract.MockAggregator.latestRoundData();
|
|
383
392
|
//originally fetched ethPrice from aggregator - pulling from EthUsdPriceConsumer instead - this is where the actual price gets pulled from when purchasing pretokens.
|
|
@@ -403,11 +412,7 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
403
412
|
priceGrowthCents,
|
|
404
413
|
minPriceUsd,
|
|
405
414
|
maxPriceUsd,
|
|
406
|
-
|
|
407
415
|
ethPriceUsd,
|
|
408
|
-
// nativePriceTimestamp,
|
|
409
|
-
ladderWindowBefore: windowBefore,
|
|
410
|
-
ladderWindowAfter: windowAfter,
|
|
411
416
|
});
|
|
412
417
|
}
|
|
413
418
|
catch (err: any) {
|
|
@@ -11,7 +11,7 @@ export const CONTRACT_NAMES = [
|
|
|
11
11
|
"DepositManager",
|
|
12
12
|
"WithdrawalVault",
|
|
13
13
|
"StakingModule",
|
|
14
|
-
"YieldOracle",
|
|
14
|
+
// "YieldOracle",
|
|
15
15
|
|
|
16
16
|
//Outpost contracts
|
|
17
17
|
"OutpostManagerAuthority",
|
|
@@ -29,7 +29,7 @@ export const CONTRACT_NAMES = [
|
|
|
29
29
|
"Pretoken",
|
|
30
30
|
"OPPInbound",
|
|
31
31
|
"Depositor",
|
|
32
|
-
|
|
32
|
+
"MockAggregator",
|
|
33
33
|
] as const;
|
|
34
34
|
|
|
35
35
|
export type ContractName = typeof CONTRACT_NAMES[number];
|
|
@@ -110,4 +110,19 @@ export interface preLaunchReceipt {
|
|
|
110
110
|
shares: BalanceView,
|
|
111
111
|
timestamp: string,
|
|
112
112
|
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface ClaimedEvent {
|
|
116
|
+
user: string;
|
|
117
|
+
amount: BigNumber;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
export interface WithdrawReceipt {
|
|
122
|
+
tokenId: bigint;
|
|
123
|
+
receipt: {
|
|
124
|
+
ethAmount: BigNumber;
|
|
125
|
+
ethBalance: BalanceView;
|
|
126
|
+
readyAt: number;
|
|
127
|
+
}
|
|
113
128
|
}
|
|
@@ -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,40 @@ 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
|
-
import { SolanaProgramService } from '../program';
|
|
19
|
-
import type { LiqsolCore } from '../../../assets/solana/types/liqsol_core';
|
|
25
|
+
import { LiqsolCoreClientIdl, SolanaProgramService } from '../program';
|
|
20
26
|
|
|
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
27
|
import { GlobalAccount, WalletLike } from '../types';
|
|
46
28
|
|
|
47
29
|
export class DepositClient {
|
|
48
|
-
private program: Program<
|
|
30
|
+
private program: Program<LiqsolCoreClientIdl>;
|
|
31
|
+
|
|
32
|
+
get connection() {
|
|
33
|
+
return this.provider.connection;
|
|
34
|
+
}
|
|
49
35
|
|
|
50
36
|
get wallet(): WalletLike {
|
|
51
37
|
return this.provider.wallet;
|
|
52
38
|
}
|
|
53
39
|
|
|
54
|
-
constructor(
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
constructor(
|
|
41
|
+
private readonly provider: AnchorProvider,
|
|
42
|
+
private readonly pgs: SolanaProgramService
|
|
43
|
+
) {
|
|
44
|
+
this.program = pgs.getProgram('liqsolCore');
|
|
57
45
|
}
|
|
58
46
|
|
|
59
47
|
/**
|
|
@@ -63,7 +51,7 @@ export class DepositClient {
|
|
|
63
51
|
async buildDepositTx(
|
|
64
52
|
amount: bigint,
|
|
65
53
|
user = this.wallet.publicKey,
|
|
66
|
-
): Promise<
|
|
54
|
+
): Promise<TransactionInstruction> {
|
|
67
55
|
if (!user) {
|
|
68
56
|
throw new Error(
|
|
69
57
|
'DepositClient.buildDepositTx: wallet not connected',
|
|
@@ -78,16 +66,16 @@ export class DepositClient {
|
|
|
78
66
|
// -------------------------------------------------------------
|
|
79
67
|
// PDAs
|
|
80
68
|
// -------------------------------------------------------------
|
|
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();
|
|
69
|
+
const depositAuthority = this.pgs.deriveDepositAuthorityPda();
|
|
70
|
+
const liqsolMint = this.pgs.deriveLiqsolMintPda();
|
|
71
|
+
const liqsolMintAuthority = this.pgs.deriveLiqsolMintAuthorityPda();
|
|
72
|
+
const reservePool = this.pgs.deriveReservePoolPda();
|
|
73
|
+
const vault = this.pgs.deriveVaultPda();
|
|
74
|
+
const controllerState = this.pgs.deriveStakeControllerStatePda();
|
|
75
|
+
const payoutState = this.pgs.derivePayoutStatePda();
|
|
76
|
+
const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
|
|
77
|
+
const payRateHistory = this.pgs.derivePayRateHistoryPda();
|
|
78
|
+
const globalConfig = this.pgs.deriveGlobalConfigPda();
|
|
91
79
|
|
|
92
80
|
// -------------------------------------------------------------
|
|
93
81
|
// Token-2022 ATAs
|
|
@@ -95,15 +83,15 @@ export class DepositClient {
|
|
|
95
83
|
const userAta = getAssociatedTokenAddressSync(
|
|
96
84
|
liqsolMint,
|
|
97
85
|
user,
|
|
98
|
-
|
|
86
|
+
true,
|
|
99
87
|
TOKEN_2022_PROGRAM_ID,
|
|
100
88
|
);
|
|
101
89
|
|
|
102
90
|
// -------------------------------------------------------------
|
|
103
91
|
// Distribution state + user_record (KEYED BY TOKEN ACCOUNT)
|
|
104
92
|
// -------------------------------------------------------------
|
|
105
|
-
const distributionState = deriveDistributionStatePda();
|
|
106
|
-
const userRecord = deriveUserRecordPda(userAta);
|
|
93
|
+
const distributionState = this.pgs.deriveDistributionStatePda();
|
|
94
|
+
const userRecord = this.pgs.deriveUserRecordPda(userAta);
|
|
107
95
|
|
|
108
96
|
const bucketTokenAccount = getAssociatedTokenAddressSync(
|
|
109
97
|
liqsolMint,
|
|
@@ -116,12 +104,12 @@ export class DepositClient {
|
|
|
116
104
|
// Ephemeral stake
|
|
117
105
|
// -------------------------------------------------------------
|
|
118
106
|
const seed = Math.floor(Math.random() * 2 ** 32);
|
|
119
|
-
const ephemeralStake = await deriveEphemeralStakeAddress(user, seed);
|
|
107
|
+
const ephemeralStake = await this.pgs.deriveEphemeralStakeAddress(user, seed);
|
|
120
108
|
|
|
121
109
|
// -------------------------------------------------------------
|
|
122
110
|
// BUILD IX (MUST MATCH IDL)
|
|
123
111
|
// -------------------------------------------------------------
|
|
124
|
-
|
|
112
|
+
return await this.program.methods
|
|
125
113
|
.deposit(new BN(amount.toString()), seed)
|
|
126
114
|
.accounts({
|
|
127
115
|
user,
|
|
@@ -129,7 +117,7 @@ export class DepositClient {
|
|
|
129
117
|
systemProgram: SystemProgram.programId,
|
|
130
118
|
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
131
119
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
132
|
-
liqsolProgram: PROGRAM_IDS.LIQSOL_TOKEN,
|
|
120
|
+
liqsolProgram: this.pgs.PROGRAM_IDS.LIQSOL_TOKEN,
|
|
133
121
|
stakeProgram: StakeProgram.programId,
|
|
134
122
|
liqsolMint,
|
|
135
123
|
userAta,
|
|
@@ -151,10 +139,128 @@ export class DepositClient {
|
|
|
151
139
|
globalConfig
|
|
152
140
|
})
|
|
153
141
|
.instruction();
|
|
154
|
-
|
|
155
|
-
return new Transaction().add(ix);
|
|
156
142
|
}
|
|
157
143
|
|
|
144
|
+
// async buildSquadsDepositProposalTx(params: {
|
|
145
|
+
// connection: Connection;
|
|
146
|
+
// multisigPda: PublicKey;
|
|
147
|
+
// amountLamports: bigint;
|
|
148
|
+
// wallet: WalletLikeSigner; // your WalletLikeSigner type
|
|
149
|
+
// vaultIndex?: number;
|
|
150
|
+
// }): Promise<{
|
|
151
|
+
// tx: Transaction;
|
|
152
|
+
// transactionIndex: bigint;
|
|
153
|
+
// vaultPda: PublicKey;
|
|
154
|
+
// }> {
|
|
155
|
+
// const { connection, multisigPda, amountLamports, wallet } = params;
|
|
156
|
+
// const vaultIndex = params.vaultIndex ?? 0;
|
|
157
|
+
|
|
158
|
+
// if (!wallet?.publicKey) throw new Error("wallet.publicKey missing");
|
|
159
|
+
// if (!amountLamports || amountLamports <= BigInt(0)) throw new Error("amountLamports must be > 0");
|
|
160
|
+
|
|
161
|
+
// // 1) vault PDA
|
|
162
|
+
// const [vaultPda] = multisig.getVaultPda({ multisigPda, index: vaultIndex });
|
|
163
|
+
|
|
164
|
+
// // 2) build deposit ix where `user` = vaultPda (off-curve OK)
|
|
165
|
+
// const depositBuilt = await this.buildDepositIxForUser(amountLamports, vaultPda);
|
|
166
|
+
|
|
167
|
+
// // 3) compute next transactionIndex (best-effort; see note below)
|
|
168
|
+
// const ms = await multisig.accounts.Multisig.fromAccountAddress(connection, multisigPda);
|
|
169
|
+
// const current = BigInt((ms as any).transactionIndex?.toString?.() ?? 0);
|
|
170
|
+
// const transactionIndex = current + BigInt(1);
|
|
171
|
+
|
|
172
|
+
// // 4) inner message uses vault as payer
|
|
173
|
+
// const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
174
|
+
// const message = new TransactionMessage({
|
|
175
|
+
// payerKey: vaultPda,
|
|
176
|
+
// recentBlockhash: blockhash,
|
|
177
|
+
// instructions: [depositBuilt.ix],
|
|
178
|
+
// });
|
|
179
|
+
|
|
180
|
+
// // 5) squads instructions (no rpc.*)
|
|
181
|
+
// const createVaultTxIx = await multisig.instructions.vaultTransactionCreate({
|
|
182
|
+
// multisigPda,
|
|
183
|
+
// transactionIndex,
|
|
184
|
+
// creator: wallet.publicKey,
|
|
185
|
+
// vaultIndex,
|
|
186
|
+
// ephemeralSigners: 0,
|
|
187
|
+
// transactionMessage: message,
|
|
188
|
+
// });
|
|
189
|
+
|
|
190
|
+
// // const createProposalIx = await multisig.instructions.proposalCreate({
|
|
191
|
+
// // multisigPda,
|
|
192
|
+
// // transactionIndex,
|
|
193
|
+
// // creator: wallet.publicKey,
|
|
194
|
+
// // });
|
|
195
|
+
// // console.log('createVaultTxIx', createVaultTxIx);
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
// // 6) return a normal Transaction for your pipeline
|
|
199
|
+
// const tx = new Transaction().add(createVaultTxIx);
|
|
200
|
+
|
|
201
|
+
// return { tx, transactionIndex, vaultPda };
|
|
202
|
+
// }
|
|
203
|
+
|
|
204
|
+
// async buildSquadsDepositProposalTx2(params: {
|
|
205
|
+
// connection: Connection;
|
|
206
|
+
// multisigPda: PublicKey;
|
|
207
|
+
// amountLamports: bigint;
|
|
208
|
+
// wallet: WalletLikeSigner; // your WalletLikeSigner type
|
|
209
|
+
// vaultIndex?: number;
|
|
210
|
+
// }): Promise<{
|
|
211
|
+
// tx: Transaction;
|
|
212
|
+
// transactionIndex: bigint;
|
|
213
|
+
// vaultPda: PublicKey;
|
|
214
|
+
// }> {
|
|
215
|
+
// const { connection, multisigPda, amountLamports, wallet } = params;
|
|
216
|
+
// const vaultIndex = params.vaultIndex ?? 0;
|
|
217
|
+
|
|
218
|
+
// if (!wallet?.publicKey) throw new Error("wallet.publicKey missing");
|
|
219
|
+
// if (!amountLamports || amountLamports <= BigInt(0)) throw new Error("amountLamports must be > 0");
|
|
220
|
+
|
|
221
|
+
// // 1) vault PDA
|
|
222
|
+
// const [vaultPda] = multisig.getVaultPda({ multisigPda, index: vaultIndex });
|
|
223
|
+
|
|
224
|
+
// // 2) build deposit ix where `user` = vaultPda (off-curve OK)
|
|
225
|
+
// const depositBuilt = await this.buildDepositIxForUser(amountLamports, vaultPda);
|
|
226
|
+
|
|
227
|
+
// // 3) compute next transactionIndex (best-effort; see note below)
|
|
228
|
+
// const ms = await multisig.accounts.Multisig.fromAccountAddress(connection, multisigPda);
|
|
229
|
+
// const current = BigInt(ms.transactionIndex?.toString?.() ?? 0);
|
|
230
|
+
// const transactionIndex = current + BigInt(1);
|
|
231
|
+
|
|
232
|
+
// // 4) inner message uses vault as payer
|
|
233
|
+
// const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
234
|
+
// const message = new TransactionMessage({
|
|
235
|
+
// payerKey: vaultPda,
|
|
236
|
+
// recentBlockhash: blockhash,
|
|
237
|
+
// instructions: [depositBuilt.ix],
|
|
238
|
+
// });
|
|
239
|
+
|
|
240
|
+
// // 5) squads instructions (no rpc.*)
|
|
241
|
+
// // const createVaultTxIx = await multisig.instructions.vaultTransactionCreate({
|
|
242
|
+
// // multisigPda,
|
|
243
|
+
// // transactionIndex,
|
|
244
|
+
// // creator: wallet.publicKey,
|
|
245
|
+
// // vaultIndex,
|
|
246
|
+
// // ephemeralSigners: 0,
|
|
247
|
+
// // transactionMessage: message,
|
|
248
|
+
// // });
|
|
249
|
+
|
|
250
|
+
// const createProposalIx = await multisig.instructions.proposalCreate({
|
|
251
|
+
// multisigPda,
|
|
252
|
+
// transactionIndex,
|
|
253
|
+
// creator: wallet.publicKey,
|
|
254
|
+
// });
|
|
255
|
+
|
|
256
|
+
// // 6) return a normal Transaction for your pipeline
|
|
257
|
+
// const tx = new Transaction().add(createProposalIx);
|
|
258
|
+
|
|
259
|
+
// return { tx, transactionIndex, vaultPda };
|
|
260
|
+
// }
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
158
264
|
/**
|
|
159
265
|
* Build a withdraw-request transaction:
|
|
160
266
|
* liqSOL -> SOL via liqsol_core::requestWithdraw.
|
|
@@ -182,33 +288,33 @@ export class DepositClient {
|
|
|
182
288
|
// -------------------------------------------------------------
|
|
183
289
|
// Core program + liqSOL mint / user ATA
|
|
184
290
|
// -------------------------------------------------------------
|
|
185
|
-
const liqsolMint = deriveLiqsolMintPda();
|
|
291
|
+
const liqsolMint = this.pgs.deriveLiqsolMintPda();
|
|
186
292
|
|
|
187
293
|
const userAta = getAssociatedTokenAddressSync(
|
|
188
294
|
liqsolMint,
|
|
189
295
|
user,
|
|
190
|
-
|
|
296
|
+
true,
|
|
191
297
|
TOKEN_2022_PROGRAM_ID,
|
|
192
298
|
);
|
|
193
299
|
|
|
194
300
|
// Distribution / balance-tracking
|
|
195
301
|
// user_record is keyed by the user’s liqSOL ATA (same convention
|
|
196
302
|
// as deposit/purchase).
|
|
197
|
-
const userRecord = deriveUserRecordPda(userAta);
|
|
198
|
-
const distributionState = deriveDistributionStatePda();
|
|
303
|
+
const userRecord = this.pgs.deriveUserRecordPda(userAta);
|
|
304
|
+
const distributionState = this.pgs.deriveDistributionStatePda();
|
|
199
305
|
|
|
200
306
|
// 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
|
|
307
|
+
const global = this.pgs.deriveWithdrawGlobalPda(); // withdraw operator state
|
|
308
|
+
const reservePool = this.pgs.deriveReservePoolPda();
|
|
309
|
+
const stakeAllocationState = this.pgs.deriveStakeAllocationStatePda();
|
|
310
|
+
const stakeMetrics = this.pgs.deriveStakeMetricsPda();
|
|
311
|
+
const maintenanceLedger = this.pgs.deriveMaintenanceLedgerPda();
|
|
312
|
+
const globalConfig = this.pgs.deriveGlobalConfigPda(); // liqSOL config / roles
|
|
207
313
|
|
|
208
314
|
// -------------------------------------------------------------
|
|
209
315
|
// Need nextReceiptId from withdraw global state
|
|
210
316
|
// -------------------------------------------------------------
|
|
211
|
-
const globalAcct
|
|
317
|
+
const globalAcct: GlobalAccount = await this.program.account.global.fetch(global);
|
|
212
318
|
|
|
213
319
|
const rawId = globalAcct.nextReceiptId;
|
|
214
320
|
let receiptId: bigint;
|
|
@@ -231,22 +337,22 @@ export class DepositClient {
|
|
|
231
337
|
// -------------------------------------------------------------
|
|
232
338
|
// NFT receipt PDAs (mint, metadata, data, ATA)
|
|
233
339
|
// -------------------------------------------------------------
|
|
234
|
-
const mintAuthority = deriveWithdrawMintAuthorityPda();
|
|
235
|
-
const metadata = deriveWithdrawMintMetadataPda();
|
|
340
|
+
const mintAuthority = this.pgs.deriveWithdrawMintAuthorityPda();
|
|
341
|
+
const metadata = this.pgs.deriveWithdrawMintMetadataPda();
|
|
236
342
|
|
|
237
|
-
const nftMint = deriveWithdrawNftMintPda(receiptId);
|
|
238
|
-
const receiptData = deriveLiqReceiptDataPda(nftMint);
|
|
343
|
+
const nftMint = this.pgs.deriveWithdrawNftMintPda(receiptId);
|
|
344
|
+
const receiptData = this.pgs.deriveLiqReceiptDataPda(nftMint);
|
|
239
345
|
|
|
240
346
|
const owner = user;
|
|
241
347
|
const nftAta = getAssociatedTokenAddressSync(
|
|
242
348
|
nftMint,
|
|
243
349
|
owner,
|
|
244
|
-
|
|
350
|
+
true,
|
|
245
351
|
TOKEN_2022_PROGRAM_ID,
|
|
246
352
|
);
|
|
247
353
|
|
|
248
354
|
// Bucket token account (same bucket used by deposit/distribution)
|
|
249
|
-
const bucketAuthority = deriveBucketAuthorityPda();
|
|
355
|
+
const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
|
|
250
356
|
const bucketTokenAccount = getAssociatedTokenAddressSync(
|
|
251
357
|
liqsolMint,
|
|
252
358
|
bucketAuthority,
|
|
@@ -289,4 +395,124 @@ export class DepositClient {
|
|
|
289
395
|
|
|
290
396
|
return new Transaction().add(ix);
|
|
291
397
|
}
|
|
292
|
-
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Internal helper: build the liqsol_core::deposit instruction for a specific `user`.
|
|
405
|
+
* This is the exact same account wiring as buildDepositTx(), but returns the IX
|
|
406
|
+
* plus useful this.pgs.derived addresses/seed for Squads flows.
|
|
407
|
+
*/
|
|
408
|
+
private async buildDepositIxForUser(
|
|
409
|
+
amount: bigint,
|
|
410
|
+
user: PublicKey,
|
|
411
|
+
): Promise<{
|
|
412
|
+
ix: TransactionInstruction;
|
|
413
|
+
seed: number;
|
|
414
|
+
userAta: PublicKey;
|
|
415
|
+
ephemeralStake: PublicKey;
|
|
416
|
+
}> {
|
|
417
|
+
if (!user) {
|
|
418
|
+
throw new Error("buildDepositIxForUser: user is required");
|
|
419
|
+
}
|
|
420
|
+
if (!amount || amount <= BigInt(0)) {
|
|
421
|
+
throw new Error("buildDepositIxForUser: amount must be > 0");
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// -------------------------------------------------------------
|
|
425
|
+
// PDAs
|
|
426
|
+
// -------------------------------------------------------------
|
|
427
|
+
const depositAuthority = this.pgs.deriveDepositAuthorityPda();
|
|
428
|
+
const liqsolMint = this.pgs.deriveLiqsolMintPda();
|
|
429
|
+
const liqsolMintAuthority = this.pgs.deriveLiqsolMintAuthorityPda();
|
|
430
|
+
const reservePool = this.pgs.deriveReservePoolPda();
|
|
431
|
+
const vault = this.pgs.deriveVaultPda();
|
|
432
|
+
const controllerState = this.pgs.deriveStakeControllerStatePda();
|
|
433
|
+
const payoutState = this.pgs.derivePayoutStatePda();
|
|
434
|
+
const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
|
|
435
|
+
const payRateHistory = this.pgs.derivePayRateHistoryPda();
|
|
436
|
+
const globalConfig = this.pgs.deriveGlobalConfigPda();
|
|
437
|
+
|
|
438
|
+
// -------------------------------------------------------------
|
|
439
|
+
// Token-2022 ATAs
|
|
440
|
+
// -------------------------------------------------------------
|
|
441
|
+
const userAta = getAssociatedTokenAddressSync(
|
|
442
|
+
liqsolMint,
|
|
443
|
+
user,
|
|
444
|
+
true,
|
|
445
|
+
TOKEN_2022_PROGRAM_ID,
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
// -------------------------------------------------------------
|
|
449
|
+
// Distribution state + user_record (KEYED BY TOKEN ACCOUNT)
|
|
450
|
+
// -------------------------------------------------------------
|
|
451
|
+
const distributionState = this.pgs.deriveDistributionStatePda();
|
|
452
|
+
const userRecord = this.pgs.deriveUserRecordPda(userAta);
|
|
453
|
+
|
|
454
|
+
const bucketTokenAccount = getAssociatedTokenAddressSync(
|
|
455
|
+
liqsolMint,
|
|
456
|
+
bucketAuthority,
|
|
457
|
+
true,
|
|
458
|
+
TOKEN_2022_PROGRAM_ID,
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
// -------------------------------------------------------------
|
|
462
|
+
// Ephemeral stake
|
|
463
|
+
// -------------------------------------------------------------
|
|
464
|
+
const seed = Math.floor(Math.random() * 2 ** 32);
|
|
465
|
+
const ephemeralStake = await this.pgs.deriveEphemeralStakeAddress(user, seed);
|
|
466
|
+
|
|
467
|
+
// -------------------------------------------------------------
|
|
468
|
+
// BUILD IX (MUST MATCH IDL)
|
|
469
|
+
// -------------------------------------------------------------
|
|
470
|
+
const ix: TransactionInstruction = await this.program.methods
|
|
471
|
+
.deposit(new BN(amount.toString()), seed)
|
|
472
|
+
.accounts({
|
|
473
|
+
user,
|
|
474
|
+
depositAuthority,
|
|
475
|
+
systemProgram: SystemProgram.programId,
|
|
476
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
477
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
478
|
+
liqsolProgram: this.pgs.PROGRAM_IDS.LIQSOL_TOKEN,
|
|
479
|
+
stakeProgram: StakeProgram.programId,
|
|
480
|
+
liqsolMint,
|
|
481
|
+
userAta,
|
|
482
|
+
liqsolMintAuthority,
|
|
483
|
+
reservePool,
|
|
484
|
+
vault,
|
|
485
|
+
ephemeralStake,
|
|
486
|
+
controllerState,
|
|
487
|
+
payoutState,
|
|
488
|
+
bucketAuthority,
|
|
489
|
+
bucketTokenAccount,
|
|
490
|
+
userRecord,
|
|
491
|
+
distributionState,
|
|
492
|
+
payRateHistory,
|
|
493
|
+
instructionsSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
494
|
+
clock: SYSVAR_CLOCK_PUBKEY,
|
|
495
|
+
stakeHistory: SYSVAR_STAKE_HISTORY_PUBKEY,
|
|
496
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
497
|
+
globalConfig,
|
|
498
|
+
})
|
|
499
|
+
.instruction();
|
|
500
|
+
|
|
501
|
+
return { ix, seed, userAta, ephemeralStake };
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// A “wallet-adapter-like” shape (AnchorProvider.wallet matches this)
|
|
507
|
+
type WalletLikeSigner = {
|
|
508
|
+
publicKey: PublicKey;
|
|
509
|
+
signTransaction: (tx: Transaction) => Promise<Transaction>;
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
function isKeypairSigner(x: any): x is { publicKey: PublicKey; secretKey: Uint8Array } {
|
|
513
|
+
return !!x && x.publicKey instanceof PublicKey && x.secretKey instanceof Uint8Array;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function isWalletLikeSigner(x: any): x is WalletLikeSigner {
|
|
517
|
+
return !!x && x.publicKey instanceof PublicKey && typeof x.signTransaction === "function";
|
|
518
|
+
}
|