@wireio/stake 0.2.5 → 0.2.69
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/README.md +185 -243
- package/lib/stake.browser.js +59089 -13470
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +16734 -3223
- package/lib/stake.js +58790 -13055
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +59089 -13470
- package/lib/stake.m.js.map +1 -1
- package/package.json +6 -3
- package/src/assets/ethereum/hoodi/common/Base58.sol/Base58.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/Base58.sol/Base58.json +164 -0
- package/src/assets/ethereum/hoodi/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.json +76 -0
- package/src/assets/ethereum/hoodi/common/RestrictedCallers.sol/RestrictedCallers.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/RestrictedCallers.sol/RestrictedCallers.json +10 -0
- package/src/assets/ethereum/hoodi/common/iodata.sol/iodata.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/iodata.sol/iodata.json +618 -0
- package/src/assets/ethereum/hoodi/common/iodata_util.sol/iodata_util.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/iodata_util.sol/iodata_util.json +40 -0
- package/src/assets/ethereum/hoodi/common/sysio_data.sol/sysio_data.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/sysio_data.sol/sysio_data.json +10 -0
- package/src/assets/ethereum/hoodi/common/sysio_errors.sol/sysio_errors.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/sysio_errors.sol/sysio_errors.json +10 -0
- package/src/assets/ethereum/hoodi/common/sysio_merkle.sol/sysio_merkle.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/sysio_merkle.sol/sysio_merkle.json +233 -0
- package/src/assets/ethereum/hoodi/common/sysio_name.sol/sysio_name.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/sysio_name.sol/sysio_name.json +49 -0
- package/src/assets/ethereum/hoodi/common/sysio_pubkey.sol/sysio_pubkey.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/sysio_pubkey.sol/sysio_pubkey.json +64 -0
- package/src/assets/ethereum/hoodi/common/sysio_read.sol/sysio_read.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/sysio_read.sol/sysio_read.json +1458 -0
- package/src/assets/ethereum/hoodi/common/sysio_tester.sol/SysioTester.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/sysio_tester.sol/SysioTester.json +1532 -0
- package/src/assets/ethereum/hoodi/common/sysio_verify.sol/sysio_verify.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/sysio_verify.sol/sysio_verify.json +1525 -0
- package/src/assets/ethereum/hoodi/common/sysio_write.sol/sysio_write.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/common/sysio_write.sol/sysio_write.json +1076 -0
- package/src/assets/ethereum/hoodi/liqEth/BeaconState.sol/BeaconState.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/BeaconState.sol/BeaconState.json +807 -0
- package/src/assets/ethereum/hoodi/liqEth/DepositManager.sol/DepositManagerV2.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/DepositManager.sol/DepositManagerV2.json +985 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +1289 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IAccounting.json +182 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20.json +319 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +333 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IStakingModule.json +344 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
- package/src/assets/ethereum/{ABI → hoodi}/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +59 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
- package/src/assets/ethereum/{ABI → hoodi}/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +14 -12
- package/src/assets/ethereum/hoodi/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
- package/src/assets/ethereum/{ABI → hoodi}/liqEth/LiqEthCommon.sol/LiqEthCommon.json +2 -2
- package/src/assets/ethereum/hoodi/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.json +236 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/LiqEthManaged.sol/LiqEthManaged.json +229 -0
- package/src/assets/ethereum/hoodi/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.json +957 -0
- package/src/assets/ethereum/hoodi/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.json +1020 -0
- package/src/assets/ethereum/hoodi/liqEth/Yield.sol/YieldOracle.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/Yield.sol/YieldOracle.json +1376 -0
- package/src/assets/ethereum/hoodi/liqEth/accounting.sol/AccountingV2.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/accounting.sol/AccountingV2.json +629 -0
- package/src/assets/ethereum/hoodi/liqEth/liqEth.sol/LiqEthTokenV2.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/liqEth.sol/LiqEthTokenV2.json +1323 -0
- package/src/assets/ethereum/hoodi/liqEth/stakingModule.sol/StakingModuleV2.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/stakingModule.sol/StakingModuleV2.json +1779 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/DepositManager.sol/DepositManager.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/DepositManager.sol/DepositManager.json +978 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IAccounting.dbg.json +4 -0
- package/src/assets/ethereum/{ABI/liqEth → hoodi/liqEth/v1}/LiqEthCommon.sol/IAccounting.json +1 -1
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositContract.json +39 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IDepositManager.json +64 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
- package/src/assets/ethereum/{ABI/liqEth → hoodi/liqEth/v1}/LiqEthCommon.sol/IRewardsERC20.json +37 -1
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.json +263 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IStakingModule.json +344 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.json +129 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.json +66 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.json +10 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +4 -0
- package/src/assets/ethereum/{ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20Pausable.json → hoodi/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.json} +140 -78
- package/src/assets/ethereum/hoodi/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json +937 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/accounting.sol/Accounting.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/accounting.sol/Accounting.json +548 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/liqEth.sol/LiqEthToken.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/liqEth.sol/LiqEthToken.json +1233 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/stakingModule.sol/StakingModule.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/v1/stakingModule.sol/StakingModule.json +1772 -0
- package/src/assets/ethereum/hoodi/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +973 -0
- package/src/assets/ethereum/hoodi/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +4 -0
- package/src/assets/ethereum/{ABI → hoodi}/liqEth/withdrawalVault.sol/Uint64BE.json +2 -2
- package/src/assets/ethereum/hoodi/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/liqEth/withdrawalVault.sol/WithdrawalVault.json +441 -0
- package/src/assets/ethereum/hoodi/outpost/BAR.sol/BAR.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/BAR.sol/BAR.json +1111 -0
- package/src/assets/ethereum/hoodi/outpost/Depositor.sol/Depositor.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/Depositor.sol/Depositor.json +1696 -0
- package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +274 -0
- package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeDepositCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeDepositCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawConfirmCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/BridgeWithdrawConfirmCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/InstaswapBridgeAttestationTypeLib.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/InstaswapBridgeAttestations.sol/InstaswapBridgeAttestationTypeLib.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/LiqEthBridge.sol/LiqEthBridge.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/LiqEthBridge.sol/LiqEthBridge.json +1044 -0
- package/src/assets/ethereum/hoodi/outpost/OPP.sol/OPP.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPP.sol/OPP.json +1055 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPP.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPP.json +81 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPInbound.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPInbound.json +330 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPReceiver.json +29 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPSender.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/IOPPSender.json +41 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/OPPCommon.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPCommon.sol/OPPCommon.json +287 -0
- package/src/assets/ethereum/hoodi/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPEndpoint.sol/OPPEndpoint.json +294 -0
- package/src/assets/ethereum/hoodi/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.json +415 -0
- package/src/assets/ethereum/hoodi/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.json +399 -0
- package/src/assets/ethereum/hoodi/outpost/OPPErrors.sol/OPPErrors.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPErrors.sol/OPPErrors.json +245 -0
- package/src/assets/ethereum/hoodi/outpost/OPPInbound.sol/OPPInbound.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPInbound.sol/OPPInbound.json +1204 -0
- package/src/assets/ethereum/hoodi/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPReceiver.sol/OPPReceiver.json +312 -0
- package/src/assets/ethereum/hoodi/outpost/OPPSender.sol/OPPSender.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OPPSender.sol/OPPSender.json +324 -0
- package/src/assets/ethereum/hoodi/outpost/OperatorRegistry.sol/OperatorRegistry.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OperatorRegistry.sol/OperatorRegistry.json +1068 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostErrors.sol/OutpostErrors.json +211 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManaged.sol/OutpostManaged.json +229 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManager.sol/OutpostManager.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManager.sol/OutpostManager.json +751 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json +1432 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostManager.json +130 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.json +141 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostOwnable.sol/OutpostOwnable.json +213 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostReserve.sol/OutpostReserve.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/OutpostReserve.sol/OutpostReserve.json +888 -0
- package/src/assets/ethereum/hoodi/outpost/Pool.sol/Pool.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/Pool.sol/Pool.json +659 -0
- package/src/assets/ethereum/hoodi/outpost/Pretoken.sol/Pretoken.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/Pretoken.sol/Pretoken.json +1393 -0
- package/src/assets/ethereum/hoodi/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/ReceiptNFT.sol/ReceiptNFT.json +1738 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapConfirmCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapConfirmCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapFailedCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapFailedCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapRequestCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapRequestCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapSettlementCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/InstaswapSettlementCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitConfirmCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitConfirmCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitFailedCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitFailedCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitRequestCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalExitRequestCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalStakeDeltaCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/PrincipalStakeDeltaCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAssetCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAssetCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestationTypeLib.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestationTypeLib.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestations.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/WireYieldHubAttestations.json +1437 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/YieldDepositCodec.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/WireYieldHubAttestations.sol/YieldDepositCodec.json +10 -0
- package/src/assets/ethereum/hoodi/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/interfaces/IPretoken.sol/IPretoken.json +29 -0
- package/src/assets/ethereum/hoodi/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/token/ERC1155Token.sol/ERC1155Token.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/token/ERC1155Token.sol/ERC1155Token.json +472 -0
- package/src/assets/ethereum/hoodi/token/ERC20Token.sol/ERC20Token.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/token/ERC20Token.sol/ERC20Token.json +330 -0
- package/src/assets/ethereum/hoodi/token/ERC721Token.sol/ERC721Token.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/token/ERC721Token.sol/ERC721Token.json +449 -0
- package/src/assets/ethereum/hoodi/token/Eman1155.sol/Eman1155.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/token/Eman1155.sol/Eman1155.json +560 -0
- package/src/assets/ethereum/hoodi/token/Eman20.sol/Eman20.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/token/Eman20.sol/Eman20.json +460 -0
- package/src/assets/ethereum/hoodi/token/Eman721.sol/Eman721.dbg.json +4 -0
- package/src/assets/ethereum/hoodi/token/Eman721.sol/Eman721.json +624 -0
- package/src/assets/ethereum/mainnet/common/Base58.sol/Base58.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/Base58.sol/Base58.json +164 -0
- package/src/assets/ethereum/mainnet/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.json +76 -0
- package/src/assets/ethereum/mainnet/common/RestrictedCallers.sol/RestrictedCallers.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/RestrictedCallers.sol/RestrictedCallers.json +10 -0
- package/src/assets/ethereum/mainnet/common/iodata.sol/iodata.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/iodata.sol/iodata.json +618 -0
- package/src/assets/ethereum/mainnet/common/iodata_util.sol/iodata_util.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/iodata_util.sol/iodata_util.json +40 -0
- package/src/assets/ethereum/mainnet/common/sysio_data.sol/sysio_data.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/sysio_data.sol/sysio_data.json +10 -0
- package/src/assets/ethereum/mainnet/common/sysio_errors.sol/sysio_errors.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/sysio_errors.sol/sysio_errors.json +10 -0
- package/src/assets/ethereum/mainnet/common/sysio_merkle.sol/sysio_merkle.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/sysio_merkle.sol/sysio_merkle.json +233 -0
- package/src/assets/ethereum/mainnet/common/sysio_name.sol/sysio_name.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/sysio_name.sol/sysio_name.json +49 -0
- package/src/assets/ethereum/mainnet/common/sysio_pubkey.sol/sysio_pubkey.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/sysio_pubkey.sol/sysio_pubkey.json +64 -0
- package/src/assets/ethereum/mainnet/common/sysio_read.sol/sysio_read.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/sysio_read.sol/sysio_read.json +1458 -0
- package/src/assets/ethereum/mainnet/common/sysio_tester.sol/SysioTester.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/sysio_tester.sol/SysioTester.json +1532 -0
- package/src/assets/ethereum/mainnet/common/sysio_verify.sol/sysio_verify.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/sysio_verify.sol/sysio_verify.json +1525 -0
- package/src/assets/ethereum/mainnet/common/sysio_write.sol/sysio_write.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/common/sysio_write.sol/sysio_write.json +1076 -0
- package/src/assets/ethereum/mainnet/liqEth/BeaconState.sol/BeaconState.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/BeaconState.sol/BeaconState.json +807 -0
- package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/DepositManagerV2.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/DepositManagerV2.json +1004 -0
- package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/IStakingModuleBondLocker.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/DepositManager.sol/IStakingModuleBondLocker.json +29 -0
- package/src/assets/ethereum/mainnet/liqEth/KeyBondManager.sol/KeyBondManager.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/KeyBondManager.sol/KeyBondManager.json +897 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +1289 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositContract.json +39 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IDepositManager.json +64 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IKeyBondManager.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IKeyBondManager.json +189 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20.json +319 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +333 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IStakingModule.json +279 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +129 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +66 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthCommon.sol/LiqEthCommon.json +10 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthDeepFreeze.sol/LiqEthDeepFreeze.json +236 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/LiqEthManaged.sol/LiqEthManaged.json +229 -0
- package/src/assets/ethereum/mainnet/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/RewardsERC20.sol/RewardsERC20UpgradeableV2.json +957 -0
- package/src/assets/ethereum/mainnet/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeableV2.json +1020 -0
- package/src/assets/ethereum/mainnet/liqEth/StakingLib.sol/StakingLib.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/StakingLib.sol/StakingLib.json +89 -0
- package/src/assets/ethereum/mainnet/liqEth/Yield.sol/YieldOracle.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/Yield.sol/YieldOracle.json +1376 -0
- package/src/assets/ethereum/mainnet/liqEth/liqEth.sol/LiqEthTokenV2.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/liqEth.sol/LiqEthTokenV2.json +1323 -0
- package/src/assets/ethereum/mainnet/liqEth/stakingModule.sol/StakingModuleV2.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/stakingModule.sol/StakingModuleV2.json +1896 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/DepositManager.sol/DepositManager.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/DepositManager.sol/DepositManager.json +978 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IAccounting.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IAccounting.json +176 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositContract.json +39 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IDepositManager.json +64 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20.json +249 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IRewardsERC20Pausable.json +263 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IStakingModule.json +344 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IValidatorBalanceVerifier.json +129 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/IWithdrawalRecord.json +66 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/LiqEthCommon.sol/LiqEthCommon.json +10 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +4 -0
- package/src/assets/ethereum/{ABI/liqEth/RewardsERC20.sol/RewardsERC20.json → mainnet/liqEth/v1/RewardsERC20.sol/RewardsERC20Upgradeable.json} +159 -34
- package/src/assets/ethereum/mainnet/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json +937 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/accounting.sol/Accounting.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/accounting.sol/Accounting.json +542 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/liqEth.sol/LiqEthToken.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/liqEth.sol/LiqEthToken.json +1233 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/stakingModule.sol/StakingModule.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/v1/stakingModule.sol/StakingModule.json +1772 -0
- package/src/assets/ethereum/mainnet/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +973 -0
- package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/Uint64BE.json +10 -0
- package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/liqEth/withdrawalVault.sol/WithdrawalVault.json +441 -0
- package/src/assets/ethereum/mainnet/outpost/BAR.sol/BARV2.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/BAR.sol/BARV2.json +1915 -0
- package/src/assets/ethereum/mainnet/outpost/Depositor.sol/DepositorV2.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/Depositor.sol/DepositorV2.json +1845 -0
- package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +122 -0
- package/src/assets/ethereum/mainnet/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +4 -0
- package/src/assets/ethereum/{ABI → mainnet}/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +31 -81
- package/src/assets/ethereum/mainnet/outpost/OPP.sol/OPP.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPP.sol/OPP.json +948 -0
- package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPP.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPEndpoint.json +29 -0
- package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPInbound.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/IOPPSender.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPCommon.sol/OPPCommon.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPErrors.sol/OPPErrors.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPInbound.sol/OPPInbound.dbg.json +4 -0
- package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPInbound.sol/OPPInbound.json +2 -2
- package/src/assets/ethereum/mainnet/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OPPSender.sol/OPPSender.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +4 -0
- package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostErrors.sol/OutpostErrors.json +33 -18
- package/src/assets/ethereum/mainnet/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OutpostManager.sol/OutpostManagerV2.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OutpostManager.sol/OutpostManagerV2.json +737 -0
- package/src/assets/ethereum/mainnet/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +29 -0
- package/src/assets/ethereum/mainnet/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/Pool.sol/PoolV2.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/Pool.sol/PoolV2.json +943 -0
- package/src/assets/ethereum/mainnet/outpost/Pretoken.sol/PretokenV2.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/Pretoken.sol/PretokenV2.json +1703 -0
- package/src/assets/ethereum/mainnet/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/ReceiptNFT.sol/ReceiptNFT.json +2015 -0
- package/src/assets/ethereum/mainnet/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/interfaces/IPretoken.sol/IPretoken.json +29 -0
- package/src/assets/ethereum/mainnet/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/interfaces/IWarrant.sol/IWarrant.json +29 -0
- package/src/assets/ethereum/mainnet/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +858 -0
- package/src/assets/ethereum/mainnet/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.json +30 -0
- package/src/assets/ethereum/mainnet/outpost/v1/BAR.sol/BAR.dbg.json +4 -0
- package/src/assets/ethereum/{ABI/outpost → mainnet/outpost/v1}/BAR.sol/BAR.json +34 -19
- package/src/assets/ethereum/mainnet/outpost/v1/Depositor.sol/Depositor.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/v1/Depositor.sol/Depositor.json +1653 -0
- package/src/assets/ethereum/mainnet/outpost/v1/OutpostManager.sol/OutpostManager.dbg.json +4 -0
- package/src/assets/ethereum/{ABI/outpost → mainnet/outpost/v1}/OutpostManager.sol/OutpostManager.json +3 -3
- package/src/assets/ethereum/mainnet/outpost/v1/Pool.sol/Pool.dbg.json +4 -0
- package/src/assets/ethereum/{ABI/outpost → mainnet/outpost/v1}/Pool.sol/Pool.json +34 -19
- package/src/assets/ethereum/mainnet/outpost/v1/Pretoken.sol/Pretoken.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/outpost/v1/Pretoken.sol/Pretoken.json +1665 -0
- package/src/assets/ethereum/mainnet/token/ERC1155Token.sol/ERC1155Token.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/token/ERC1155Token.sol/ERC1155Token.json +472 -0
- package/src/assets/ethereum/mainnet/token/ERC20Token.sol/ERC20Token.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/token/ERC20Token.sol/ERC20Token.json +330 -0
- package/src/assets/ethereum/mainnet/token/ERC721Token.sol/ERC721Token.dbg.json +4 -0
- package/src/assets/ethereum/mainnet/token/ERC721Token.sol/ERC721Token.json +449 -0
- package/src/assets/solana/devnet/idl/liqsol_core.json +8566 -0
- package/src/assets/solana/{idl → devnet/idl}/liqsol_token.json +35 -1
- package/src/assets/solana/devnet/idl/transfer_hook.json +490 -0
- package/src/assets/solana/devnet/idl/validator_leaderboard.json +735 -0
- package/src/assets/solana/devnet/types/liqsol_core.ts +8572 -0
- package/src/assets/solana/{types → devnet/types}/liqsol_token.ts +35 -1
- package/src/assets/solana/devnet/types/transfer_hook.ts +496 -0
- package/src/assets/solana/devnet/types/validator_leaderboard.ts +741 -0
- package/src/assets/solana/{idl → mainnet/idl}/liqsol_core.json +3816 -1567
- package/src/assets/solana/mainnet/idl/liqsol_token.json +217 -0
- package/src/assets/solana/mainnet/idl/transfer_hook.json +479 -0
- package/src/assets/solana/{idl → mainnet/idl}/validator_leaderboard.json +4 -4
- package/src/assets/solana/{types → mainnet/types}/liqsol_core.ts +3816 -1567
- package/src/assets/solana/mainnet/types/liqsol_token.ts +223 -0
- package/src/assets/solana/mainnet/types/transfer_hook.ts +485 -0
- package/src/assets/solana/{types → mainnet/types}/validator_leaderboard.ts +4 -4
- package/src/assets/solana/realdevnet/idl/liqsol_core.json +7112 -0
- package/src/assets/solana/realdevnet/idl/liqsol_token.json +217 -0
- package/src/assets/solana/realdevnet/idl/transfer_hook.json +479 -0
- package/src/assets/solana/realdevnet/idl/validator_leaderboard.json +735 -0
- package/src/assets/solana/realdevnet/types/liqsol_core.ts +7118 -0
- package/src/assets/solana/realdevnet/types/liqsol_token.ts +223 -0
- package/src/assets/solana/realdevnet/types/transfer_hook.ts +485 -0
- package/src/assets/solana/realdevnet/types/validator_leaderboard.ts +741 -0
- package/src/index.ts +2 -2
- package/src/networks/ethereum/clients/{deposit.client.ts → convert.client.ts} +76 -11
- package/src/networks/ethereum/clients/opp.client.ts +389 -0
- package/src/networks/ethereum/clients/pretoken.client.ts +81 -46
- package/src/networks/ethereum/clients/receipt.client.ts +199 -0
- package/src/networks/ethereum/clients/stake.client.ts +86 -161
- package/src/networks/ethereum/clients/validator.client.ts +61 -0
- package/src/networks/ethereum/contract.ts +424 -178
- package/src/networks/ethereum/ethereum.ts +461 -274
- package/src/networks/ethereum/types.ts +71 -32
- package/src/networks/ethereum/utils.ts +104 -78
- package/src/networks/solana/clients/convert.client.ts +341 -0
- package/src/networks/solana/clients/distribution.client.ts +269 -263
- package/src/networks/solana/clients/leaderboard.client.ts +68 -26
- package/src/networks/solana/clients/outpost.client.ts +224 -357
- package/src/networks/solana/clients/token.client.ts +96 -107
- package/src/networks/solana/constants.ts +88 -216
- package/src/networks/solana/program.ts +432 -28
- package/src/networks/solana/solana.ts +1070 -399
- package/src/networks/solana/types.ts +688 -75
- package/src/networks/solana/utils.ts +160 -359
- package/src/staker.ts +25 -4
- package/src/types.ts +247 -39
- package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json +0 -1114
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.json +0 -118
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20Pausable.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.json +0 -10
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.json +0 -10
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json +0 -225
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.json +0 -10
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.json +0 -10
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json +0 -813
- package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json +0 -573
- package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json +0 -1087
- package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json +0 -1183
- package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +0 -927
- package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.json +0 -447
- package/src/assets/ethereum/ABI/outpost/Aggregator.sol/Aggregator.json +0 -82
- package/src/assets/ethereum/ABI/outpost/BAR.sol/BAR.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.json +0 -1753
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.json +0 -930
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPP.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPInbound.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPSender.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/OPPCommon.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPErrors.sol/OPPErrors.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OPPSender.sol/OPPSender.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OutpostManager.sol/OutpostManager.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/Pool.sol/Pool.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.json +0 -2020
- package/src/assets/ethereum/ABI/outpost/Warrant.sol/Warrant.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/Warrant.sol/Warrant.json +0 -1650
- package/src/assets/ethereum/ABI/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +0 -4
- package/src/assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.dbg.json +0 -4
- package/src/assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.json +0 -472
- package/src/assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.dbg.json +0 -4
- package/src/assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.json +0 -330
- package/src/assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.dbg.json +0 -4
- package/src/assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.json +0 -449
- package/src/networks/solana/clients/deposit.client.ts +0 -127
- package/src/staker/types.ts +0 -62
- /package/src/assets/ethereum/{ABI → hoodi}/liqEth/LiqEthCommon.sol/IDepositContract.json +0 -0
- /package/src/assets/ethereum/{ABI → hoodi}/liqEth/LiqEthCommon.sol/IDepositManager.json +0 -0
- /package/src/assets/ethereum/{ABI → hoodi}/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +0 -0
- /package/src/assets/ethereum/{ABI → hoodi}/outpost/OPPCommon.sol/IOPPEndpoint.json +0 -0
- /package/src/assets/ethereum/{ABI → hoodi}/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +0 -0
- /package/src/assets/ethereum/{ABI → hoodi}/outpost/interfaces/IWarrant.sol/IWarrant.json +0 -0
- /package/src/assets/ethereum/{ABI → hoodi}/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +0 -0
- /package/src/assets/ethereum/{ABI → hoodi}/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.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/IOPPInbound.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.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.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.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OPPErrors.sol/OPPErrors.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.json +0 -0
- /package/src/assets/ethereum/{ABI → mainnet}/outpost/OutpostManaged.sol/OutpostManaged.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.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.json +0 -0
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AddressLookupTableAccount,
|
|
2
3
|
Commitment,
|
|
4
|
+
ComputeBudgetProgram,
|
|
3
5
|
Connection,
|
|
4
6
|
ConnectionConfig,
|
|
5
|
-
|
|
7
|
+
PerfSample,
|
|
8
|
+
SendTransactionError,
|
|
6
9
|
PublicKey as SolPubKey,
|
|
10
|
+
SystemProgram,
|
|
7
11
|
Transaction,
|
|
8
12
|
TransactionInstruction,
|
|
13
|
+
TransactionMessage,
|
|
9
14
|
TransactionSignature,
|
|
15
|
+
VersionedTransaction,
|
|
10
16
|
} from '@solana/web3.js';
|
|
11
|
-
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
17
|
+
import { AnchorProvider, BN } from '@coral-xyz/anchor';
|
|
12
18
|
import { BaseSignerWalletAdapter } from '@solana/wallet-adapter-base';
|
|
13
19
|
import {
|
|
14
20
|
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
21
|
+
createAssociatedTokenAccountInstruction,
|
|
15
22
|
getAssociatedTokenAddressSync,
|
|
16
23
|
TOKEN_2022_PROGRAM_ID,
|
|
17
24
|
} from '@solana/spl-token';
|
|
18
25
|
|
|
26
|
+
import * as multisig from "@sqds/multisig";
|
|
27
|
+
|
|
19
28
|
import {
|
|
29
|
+
Base58,
|
|
20
30
|
ChainID,
|
|
21
31
|
ExternalNetwork,
|
|
22
32
|
KeyType,
|
|
@@ -27,52 +37,61 @@ import {
|
|
|
27
37
|
import {
|
|
28
38
|
IStakingClient,
|
|
29
39
|
Portfolio,
|
|
30
|
-
|
|
31
|
-
PurchaseQuote,
|
|
40
|
+
SquadsXConfig,
|
|
32
41
|
StakerConfig,
|
|
33
42
|
TrancheSnapshot,
|
|
34
43
|
} from '../../types';
|
|
35
44
|
|
|
36
|
-
import {
|
|
45
|
+
import { ConvertClient } from './clients/convert.client';
|
|
37
46
|
import { DistributionClient } from './clients/distribution.client';
|
|
38
47
|
import { LeaderboardClient } from './clients/leaderboard.client';
|
|
39
48
|
import { OutpostClient } from './clients/outpost.client';
|
|
40
49
|
import { TokenClient } from './clients/token.client';
|
|
41
50
|
|
|
42
51
|
import {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
DEFAULT_AVERAGE_PAY_RATE,
|
|
53
|
+
INDEX_SCALE,
|
|
54
|
+
PAY_RATE_SCALE_FACTOR,
|
|
46
55
|
} from './constants';
|
|
47
56
|
|
|
48
|
-
import { buildSolanaTrancheSnapshot } from './utils';
|
|
49
|
-
import { SolanaTransaction } from './types';
|
|
57
|
+
import { buildSolanaTrancheSnapshot, ceilDiv } from './utils';
|
|
58
|
+
import { GlobalConfig, PayRateEntry, SolanaTransaction } from './types';
|
|
59
|
+
import { WithdrawReceipt } from '../../types';
|
|
60
|
+
import { SolanaProgramService } from './program';
|
|
61
|
+
import bs58 from 'bs58';
|
|
50
62
|
|
|
51
63
|
const commitment: Commitment = 'confirmed';
|
|
52
64
|
|
|
65
|
+
export const SCALE = new BN('1000000000000');
|
|
66
|
+
|
|
53
67
|
/**
|
|
54
68
|
* Solana implementation of IStakingClient.
|
|
55
69
|
*
|
|
56
70
|
* Responsibilities:
|
|
57
|
-
* -
|
|
58
|
-
* -
|
|
59
|
-
* -
|
|
60
|
-
* - Unified portfolio + tranche snapshot +
|
|
71
|
+
* - liqSOL deposit (SOL -> liqSOL)
|
|
72
|
+
* - withdraw requests (liqSOL -> NFT receipt / encumbered SOL)
|
|
73
|
+
* - Pretoken (WIRE) buys via liqSOL
|
|
74
|
+
* - Unified portfolio + tranche snapshot + balance correction (later)
|
|
61
75
|
*
|
|
62
|
-
* This
|
|
76
|
+
* This composes lower-level clients; it does not know about UI.
|
|
63
77
|
*/
|
|
64
78
|
export class SolanaStakingClient implements IStakingClient {
|
|
65
|
-
public pubKey
|
|
79
|
+
public pubKey?: PublicKey; // Wire ED key (optional → read-only)
|
|
66
80
|
public connection: Connection;
|
|
67
81
|
public anchor: AnchorProvider;
|
|
68
82
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
public convertClient: ConvertClient;
|
|
84
|
+
public distributionClient: DistributionClient;
|
|
85
|
+
public leaderboardClient: LeaderboardClient;
|
|
86
|
+
public outpostClient: OutpostClient;
|
|
87
|
+
public tokenClient: TokenClient;
|
|
88
|
+
public program: SolanaProgramService
|
|
89
|
+
|
|
90
|
+
private smartAccount?: SolPubKey; // PDA (off-curve)
|
|
91
|
+
private signer?: SolPubKey; // on-curve signer
|
|
74
92
|
|
|
75
93
|
get solPubKey(): SolPubKey {
|
|
94
|
+
if (!this.pubKey) throw new Error('pubKey is undefined');
|
|
76
95
|
return new SolPubKey(this.pubKey.data.array);
|
|
77
96
|
}
|
|
78
97
|
|
|
@@ -80,17 +99,66 @@ export class SolanaStakingClient implements IStakingClient {
|
|
|
80
99
|
return this.config.network;
|
|
81
100
|
}
|
|
82
101
|
|
|
102
|
+
get feePayer(): SolPubKey {
|
|
103
|
+
if (this.signer) return this.signer;
|
|
104
|
+
// fallback for normal wallets
|
|
105
|
+
if (this.anchor.wallet.publicKey) return this.anchor.wallet.publicKey;
|
|
106
|
+
throw new Error('No signing authority available');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get squadsX(): SquadsXConfig | null {
|
|
110
|
+
const config = this.config.extras?.squadsX;
|
|
111
|
+
return config ?? null;
|
|
112
|
+
}
|
|
113
|
+
|
|
83
114
|
constructor(private config: StakerConfig) {
|
|
84
|
-
const adapter = config.provider as BaseSignerWalletAdapter;
|
|
85
|
-
if (!adapter?.publicKey) throw new Error('Solana wallet adapter not connected');
|
|
86
|
-
if (!config.network.rpcUrls.length) throw new Error('No RPC URLs provided');
|
|
115
|
+
const adapter = config.provider as BaseSignerWalletAdapter | undefined;
|
|
87
116
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!wirePub.equals(config.pubKey)) {
|
|
91
|
-
throw new Error("Passed-in pubKey doesn't match adapter.publicKey");
|
|
117
|
+
if (!config.network.rpcUrls.length) {
|
|
118
|
+
throw new Error('No RPC URLs provided');
|
|
92
119
|
}
|
|
93
120
|
|
|
121
|
+
// -------------------------------------------------------------
|
|
122
|
+
// Resolve Solana wallet pubkey (or dummy in read-only mode)
|
|
123
|
+
// -------------------------------------------------------------
|
|
124
|
+
let solWalletPubkey: SolPubKey;
|
|
125
|
+
if (adapter?.publicKey) {
|
|
126
|
+
solWalletPubkey = adapter.publicKey;
|
|
127
|
+
} else {
|
|
128
|
+
// Zeroed pubkey when no wallet (read-only usage)
|
|
129
|
+
solWalletPubkey = new SolPubKey(new Uint8Array(32));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// -------------------------------------------------------------
|
|
133
|
+
// Resolve Wire pubKey
|
|
134
|
+
// -------------------------------------------------------------
|
|
135
|
+
if (config.pubKey) {
|
|
136
|
+
const wirePub = config.pubKey;
|
|
137
|
+
|
|
138
|
+
if (adapter?.publicKey) {
|
|
139
|
+
const derived = new PublicKey(
|
|
140
|
+
KeyType.ED,
|
|
141
|
+
adapter.publicKey.toBytes(),
|
|
142
|
+
);
|
|
143
|
+
if (!derived.equals(wirePub)) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
"Passed-in pubKey doesn't match adapter.publicKey",
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
this.pubKey = wirePub;
|
|
151
|
+
} else if (adapter?.publicKey) {
|
|
152
|
+
// Derive Wire pubKey from adapter when not explicitly passed
|
|
153
|
+
this.pubKey = new PublicKey(
|
|
154
|
+
KeyType.ED,
|
|
155
|
+
adapter.publicKey.toBytes(),
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// -------------------------------------------------------------
|
|
160
|
+
// Connection + AnchorProvider
|
|
161
|
+
// -------------------------------------------------------------
|
|
94
162
|
const opts: ConnectionConfig = { commitment };
|
|
95
163
|
if (
|
|
96
164
|
config.network.rpcUrls.length > 1 &&
|
|
@@ -99,28 +167,55 @@ export class SolanaStakingClient implements IStakingClient {
|
|
|
99
167
|
opts.wsEndpoint = config.network.rpcUrls[1];
|
|
100
168
|
}
|
|
101
169
|
|
|
102
|
-
const anchorWallet =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
170
|
+
const anchorWallet = adapter
|
|
171
|
+
? {
|
|
172
|
+
publicKey: solWalletPubkey,
|
|
173
|
+
async signTransaction<T extends SolanaTransaction>(
|
|
174
|
+
tx: T,
|
|
175
|
+
): Promise<T> {
|
|
176
|
+
return adapter.signTransaction(tx);
|
|
177
|
+
},
|
|
178
|
+
async signAllTransactions<T extends SolanaTransaction>(
|
|
179
|
+
txs: T[],
|
|
180
|
+
): Promise<T[]> {
|
|
181
|
+
if (adapter.signAllTransactions) {
|
|
182
|
+
return adapter.signAllTransactions(txs);
|
|
183
|
+
}
|
|
184
|
+
return Promise.all(
|
|
185
|
+
txs.map((tx) => adapter.signTransaction(tx)),
|
|
186
|
+
);
|
|
187
|
+
},
|
|
188
|
+
}
|
|
189
|
+
: {
|
|
190
|
+
publicKey: solWalletPubkey,
|
|
191
|
+
async signTransaction<T extends SolanaTransaction>(
|
|
192
|
+
_tx: T,
|
|
193
|
+
): Promise<T> {
|
|
194
|
+
throw new Error(
|
|
195
|
+
'Wallet not connected: signTransaction not available',
|
|
196
|
+
);
|
|
197
|
+
},
|
|
198
|
+
async signAllTransactions<T extends SolanaTransaction>(
|
|
199
|
+
_txs: T[],
|
|
200
|
+
): Promise<T[]> {
|
|
201
|
+
throw new Error(
|
|
202
|
+
'Wallet not connected: signAllTransactions not available',
|
|
203
|
+
);
|
|
204
|
+
},
|
|
205
|
+
};
|
|
113
206
|
|
|
114
|
-
this.pubKey = wirePub;
|
|
115
207
|
this.connection = new Connection(config.network.rpcUrls[0], opts);
|
|
116
|
-
this.anchor = new AnchorProvider(this.connection, anchorWallet, {
|
|
208
|
+
this.anchor = new AnchorProvider(this.connection, anchorWallet, {
|
|
209
|
+
commitment,
|
|
210
|
+
});
|
|
117
211
|
|
|
118
|
-
this.
|
|
119
|
-
|
|
120
|
-
this.
|
|
121
|
-
this.
|
|
122
|
-
this.
|
|
123
|
-
this.
|
|
212
|
+
this.program = new SolanaProgramService(this.anchor, config.network.chainId as SolChainID);
|
|
213
|
+
|
|
214
|
+
this.convertClient = new ConvertClient(this.anchor, this.program);
|
|
215
|
+
this.distributionClient = new DistributionClient(this.anchor, this.program);
|
|
216
|
+
this.leaderboardClient = new LeaderboardClient(this.anchor, this.program);
|
|
217
|
+
this.outpostClient = new OutpostClient(this.anchor, this.program);
|
|
218
|
+
this.tokenClient = new TokenClient(this.anchor, this.program);
|
|
124
219
|
}
|
|
125
220
|
|
|
126
221
|
// ---------------------------------------------------------------------
|
|
@@ -132,358 +227,386 @@ export class SolanaStakingClient implements IStakingClient {
|
|
|
132
227
|
* Handles tx build, sign, send, and confirmation.
|
|
133
228
|
*/
|
|
134
229
|
async deposit(amountLamports: bigint): Promise<string> {
|
|
135
|
-
|
|
230
|
+
this.ensureUser();
|
|
231
|
+
if (amountLamports <= BigInt(0))
|
|
136
232
|
throw new Error('Deposit amount must be greater than zero.');
|
|
137
|
-
}
|
|
138
233
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
234
|
+
try {
|
|
235
|
+
const ix = await this.convertClient.buildDepositTx(amountLamports, this.squadsVaultPDA)
|
|
236
|
+
return !!this.squadsX
|
|
237
|
+
? await this.sendSquadsIxs(ix)
|
|
238
|
+
: await this.buildAndSendIx(ix)
|
|
239
|
+
|
|
240
|
+
} catch (err) {
|
|
241
|
+
console.log(`Failed to deposit Solana: ${err}`);
|
|
242
|
+
throw err;
|
|
243
|
+
}
|
|
148
244
|
}
|
|
149
245
|
|
|
150
246
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
247
|
+
* Request a withdraw from liqSOL to SOL (liqsol_core::requestWithdraw).
|
|
248
|
+
*
|
|
249
|
+
* This:
|
|
250
|
+
* - burns liqSOL from the user ATA
|
|
251
|
+
* - mints an NFT withdrawal receipt
|
|
252
|
+
* - increases totalEncumberedFunds in global state
|
|
253
|
+
*
|
|
254
|
+
* Actual SOL payout happens later via the operator-side flow.
|
|
153
255
|
*/
|
|
154
|
-
async withdraw(
|
|
155
|
-
|
|
256
|
+
async withdraw(amountLamports: bigint): Promise<string> {
|
|
257
|
+
this.ensureUser();
|
|
258
|
+
if (amountLamports <= BigInt(0))
|
|
259
|
+
throw new Error('Withdraw amount must be greater than zero.');
|
|
260
|
+
|
|
261
|
+
try {
|
|
262
|
+
const ix = await this.convertClient.buildWithdrawTx(amountLamports, this.squadsVaultPDA)
|
|
263
|
+
return !!this.squadsX
|
|
264
|
+
? await this.sendSquadsIxs(ix)
|
|
265
|
+
: await this.buildAndSendIx(ix)
|
|
266
|
+
|
|
267
|
+
} catch (err) {
|
|
268
|
+
console.log(`Failed to withdraw Solana: ${err}`);
|
|
269
|
+
throw err;
|
|
270
|
+
}
|
|
156
271
|
}
|
|
157
272
|
|
|
158
273
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
274
|
+
* Enumerate withdrawal receipt NFTs held by the user (queued/ready/claimed).
|
|
275
|
+
* Mirrors the ETH getPendingWithdraws helper for UI parity.
|
|
161
276
|
*/
|
|
162
|
-
async
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const preIxs = await this.outpostClient.maybeBuildCreateUserAtaIx(
|
|
168
|
-
this.solPubKey,
|
|
169
|
-
);
|
|
170
|
-
const stakeIx = await this.outpostClient.buildStakeLiqsolIx(amountLamports);
|
|
171
|
-
const tx = new Transaction().add(...preIxs, stakeIx);
|
|
172
|
-
|
|
173
|
-
const prepared = await this.prepareTx(tx);
|
|
174
|
-
const signed = await this.signTransaction(prepared.tx);
|
|
175
|
-
return await this.sendAndConfirmHttp(signed, prepared);
|
|
277
|
+
async getPendingWithdraws(address?: string): Promise<WithdrawReceipt[]> {
|
|
278
|
+
this.ensureUser();
|
|
279
|
+
const owner = address ? new SolPubKey(address) :
|
|
280
|
+
this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
|
|
281
|
+
return await this.convertClient.fetchWithdrawReceipts(owner);
|
|
176
282
|
}
|
|
177
283
|
|
|
178
284
|
/**
|
|
179
|
-
*
|
|
180
|
-
* Mirrors stake() but calls withdrawStake.
|
|
285
|
+
* Claim a withdrawal receipt (burn NFT + receive SOL) via claim_withdraw.
|
|
181
286
|
*/
|
|
182
|
-
async
|
|
183
|
-
|
|
184
|
-
|
|
287
|
+
async claimWithdraw(tokenId: bigint): Promise<string> {
|
|
288
|
+
this.ensureUser();
|
|
289
|
+
const owner = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
|
|
290
|
+
|
|
291
|
+
try {
|
|
292
|
+
const ix = await this.convertClient.buildClaimWithdrawTx(tokenId, owner);
|
|
293
|
+
return !!this.squadsX
|
|
294
|
+
? await this.sendSquadsIxs(ix)
|
|
295
|
+
: await this.buildAndSendIx(ix);
|
|
296
|
+
} catch (err) {
|
|
297
|
+
console.log(`Failed to claim withdraw on Solana: ${err}`);
|
|
298
|
+
throw err;
|
|
185
299
|
}
|
|
186
|
-
|
|
187
|
-
const user = this.solPubKey;
|
|
188
|
-
const preIxs = await this.outpostClient.maybeBuildCreateUserAtaIx(user);
|
|
189
|
-
const withdrawIx =
|
|
190
|
-
await this.outpostClient.buildWithdrawStakeIx(amountLamports);
|
|
191
|
-
const tx = new Transaction().add(...preIxs, withdrawIx);
|
|
192
|
-
|
|
193
|
-
const prepared = await this.prepareTx(tx);
|
|
194
|
-
const signed = await this.signTransaction(prepared.tx);
|
|
195
|
-
return await this.sendAndConfirmHttp(signed, prepared);
|
|
196
300
|
}
|
|
197
301
|
|
|
198
302
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* - SOL: uses purchase_with_sol
|
|
202
|
-
* - LIQSOL: uses purchase_with_liqsol
|
|
203
|
-
* - YIELD: uses purchase_warrants_from_yield
|
|
204
|
-
*
|
|
205
|
-
* ETH / LIQETH are not valid on Solana.
|
|
303
|
+
* Claim accrued liqSOL distribution rewards (liqsol_core::claim_rewards).
|
|
206
304
|
*/
|
|
207
|
-
async
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
user,
|
|
220
|
-
);
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
case PurchaseAsset.LIQSOL: {
|
|
225
|
-
if (!amountLamports || amountLamports <= BigInt(0)) {
|
|
226
|
-
throw new Error(
|
|
227
|
-
'liqSOL pretoken purchase requires a positive amount.',
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
preIxs = await this.outpostClient.maybeBuildCreateUserAtaIx(user);
|
|
231
|
-
ix = await this.tokenClient.buildPurchaseWithLiqsolIx(
|
|
232
|
-
amountLamports,
|
|
233
|
-
user,
|
|
234
|
-
);
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
case PurchaseAsset.YIELD: {
|
|
239
|
-
// Amount is ignored by the on-chain program; it consumes tracked yield.
|
|
240
|
-
ix = await this.tokenClient.buildPurchaseFromYieldIx(user);
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
case PurchaseAsset.ETH:
|
|
245
|
-
case PurchaseAsset.LIQETH: {
|
|
246
|
-
throw new Error(
|
|
247
|
-
'ETH / LIQETH pretoken purchases are not supported on Solana.',
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
default:
|
|
252
|
-
throw new Error(`Unsupported pretoken purchase asset: ${String(
|
|
253
|
-
purchaseAsset,
|
|
254
|
-
)}`);
|
|
305
|
+
async claimLiqsolRewards(): Promise<string> {
|
|
306
|
+
this.ensureUser();
|
|
307
|
+
const owner = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
|
|
308
|
+
|
|
309
|
+
try {
|
|
310
|
+
const ix = await this.distributionClient.buildClaimRewardsIx(owner);
|
|
311
|
+
return !!this.squadsX
|
|
312
|
+
? await this.sendSquadsIxs(ix)
|
|
313
|
+
: await this.buildAndSendIx(ix);
|
|
314
|
+
} catch (err) {
|
|
315
|
+
console.log(`Failed to claim liqSOL rewards on Solana: ${err}`);
|
|
316
|
+
throw err;
|
|
255
317
|
}
|
|
256
|
-
|
|
257
|
-
const tx = new Transaction().add(...preIxs, ix);
|
|
258
|
-
const prepared = await this.prepareTx(tx);
|
|
259
|
-
const signed = await this.signTransaction(prepared.tx);
|
|
260
|
-
return await this.sendAndConfirmHttp(signed, prepared);
|
|
261
318
|
}
|
|
262
319
|
|
|
263
320
|
/**
|
|
264
|
-
*
|
|
265
|
-
* - native: SOL wallet balance
|
|
266
|
-
* - liq: liqSOL token balance (Token-2022 ATA)
|
|
267
|
-
* - staked: Outpost-staked liqSOL principal
|
|
268
|
-
* - tracked: distribution program trackedBalance (liqSOL)
|
|
269
|
-
* - wire: total prelaunch WIRE shares (warrants/pretokens, 1e8)
|
|
270
|
-
* - extras: useful internal addresses and raw state for debugging/UX
|
|
321
|
+
* Stake liqSOL into Outpost (liqSOL → pool) via liqsol_core::synd.
|
|
271
322
|
*/
|
|
272
|
-
async
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const vaultPDA = deriveVaultPda();
|
|
277
|
-
const liqsolMint = deriveLiqsolMintPda();
|
|
278
|
-
|
|
279
|
-
const userLiqsolAta = getAssociatedTokenAddressSync(
|
|
280
|
-
liqsolMint,
|
|
281
|
-
user,
|
|
282
|
-
false,
|
|
283
|
-
TOKEN_2022_PROGRAM_ID,
|
|
284
|
-
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
const [
|
|
288
|
-
nativeLamports,
|
|
289
|
-
actualBalResp,
|
|
290
|
-
userRecord,
|
|
291
|
-
snapshot,
|
|
292
|
-
] = await Promise.all([
|
|
293
|
-
this.connection.getBalance(user, 'confirmed'),
|
|
294
|
-
this.connection
|
|
295
|
-
.getTokenAccountBalance(userLiqsolAta, 'confirmed')
|
|
296
|
-
.catch(() => null),
|
|
297
|
-
this.distributionClient.getUserRecord(user).catch(() => null),
|
|
298
|
-
this.outpostClient.getWireStateSnapshot(user).catch(() => null),
|
|
299
|
-
]);
|
|
323
|
+
async stake(amountLamports: bigint, wireAccount?: string): Promise<string> {
|
|
324
|
+
this.ensureUser();
|
|
325
|
+
if (!amountLamports || amountLamports <= BigInt(0))
|
|
326
|
+
throw new Error('Stake amount must be greater than zero.');
|
|
300
327
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const wireSharesStr =
|
|
316
|
-
userWarrantRecord?.totalWarrantsPurchased?.toString() ?? '0';
|
|
317
|
-
|
|
318
|
-
return {
|
|
319
|
-
native: {
|
|
320
|
-
amount: BigInt(nativeLamports),
|
|
321
|
-
symbol: "SOL",
|
|
322
|
-
decimals: 9,
|
|
323
|
-
},
|
|
324
|
-
liq: {
|
|
325
|
-
amount: BigInt(actualAmountStr),
|
|
326
|
-
symbol: "LiqSOL",
|
|
327
|
-
decimals: LIQSOL_DECIMALS,
|
|
328
|
-
ata: userLiqsolAta,
|
|
329
|
-
},
|
|
330
|
-
staked: {
|
|
331
|
-
amount: BigInt(stakedAmountStr),
|
|
332
|
-
symbol: "LiqSOL",
|
|
333
|
-
decimals: LIQSOL_DECIMALS,
|
|
334
|
-
},
|
|
335
|
-
wire: {
|
|
336
|
-
// Prelaunch pretokens / WIRE shares (1e8)
|
|
337
|
-
amount: BigInt(wireSharesStr),
|
|
338
|
-
symbol: "$WIRE",
|
|
339
|
-
decimals: 8,
|
|
340
|
-
},
|
|
341
|
-
tracked: {
|
|
342
|
-
amount: BigInt(trackedAmountStr),
|
|
343
|
-
symbol: "LiqSOL",
|
|
344
|
-
decimals: LIQSOL_DECIMALS,
|
|
345
|
-
},
|
|
346
|
-
extras: {
|
|
347
|
-
userLiqsolAta: userLiqsolAta.toBase58(),
|
|
348
|
-
reservePoolPDA: reservePoolPDA.toBase58(),
|
|
349
|
-
vaultPDA: vaultPDA.toBase58(),
|
|
350
|
-
wireReceipt,
|
|
351
|
-
userWarrantRecord,
|
|
352
|
-
globalIndex: globalState?.currentIndex?.toString(),
|
|
353
|
-
totalShares: globalState?.totalShares?.toString(),
|
|
354
|
-
currentTrancheNumber: trancheState?.currentTrancheNumber?.toString(),
|
|
355
|
-
currentTranchePriceUsd: trancheState?.currentTranchePriceUsd?.toString(), // 1e8 USD
|
|
356
|
-
},
|
|
357
|
-
chainID: this.network.chainId,
|
|
358
|
-
};
|
|
328
|
+
try {
|
|
329
|
+
const ix = await this.outpostClient.buildStakeIx(
|
|
330
|
+
amountLamports,
|
|
331
|
+
this.squadsVaultPDA,
|
|
332
|
+
wireAccount,
|
|
333
|
+
)
|
|
334
|
+
return !!this.squadsX
|
|
335
|
+
? await this.sendSquadsIxs(ix)
|
|
336
|
+
: await this.buildAndSendIx(ix)
|
|
337
|
+
|
|
338
|
+
} catch (err) {
|
|
339
|
+
console.log(`Failed to stake Solana: ${err}`);
|
|
340
|
+
throw err;
|
|
341
|
+
}
|
|
359
342
|
}
|
|
360
343
|
|
|
361
344
|
/**
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
* Uses:
|
|
365
|
-
* - liqsol_core.globalState (currentIndex, totalShares, etc.)
|
|
366
|
-
* - liqsol_core.trancheState (price, supply, total sold, etc.)
|
|
367
|
-
* - Chainlink/PriceHistory for SOL/USD (via TokenClient.getSolPriceUsdSafe)
|
|
368
|
-
*
|
|
369
|
-
* windowBefore/windowAfter control how many ladder rows we precompute
|
|
370
|
-
* around the current tranche for UI, but you can pass nothing if you
|
|
371
|
-
* only need current tranche info.
|
|
345
|
+
* Unstake liqSOL from Outpost (pool → liqSOL) via liqsol_core::desynd.
|
|
372
346
|
*/
|
|
373
|
-
async
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}): Promise<TrancheSnapshot> {
|
|
378
|
-
const {
|
|
379
|
-
chainID = SolChainID.WireTestnet,
|
|
380
|
-
windowBefore,
|
|
381
|
-
windowAfter,
|
|
382
|
-
} = options ?? {};
|
|
383
|
-
|
|
384
|
-
// Canonical program state
|
|
385
|
-
const [globalState, trancheState] = await Promise.all([
|
|
386
|
-
this.tokenClient.fetchGlobalState(),
|
|
387
|
-
this.tokenClient.fetchTrancheState(),
|
|
388
|
-
]);
|
|
347
|
+
async unstake(amountLamports: bigint): Promise<string> {
|
|
348
|
+
this.ensureUser();
|
|
349
|
+
if (!amountLamports || amountLamports <= BigInt(0))
|
|
350
|
+
throw new Error('Unstake amount must be greater than zero.');
|
|
389
351
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
ladderWindowBefore: windowBefore,
|
|
401
|
-
ladderWindowAfter: windowAfter,
|
|
402
|
-
});
|
|
352
|
+
try {
|
|
353
|
+
const ix = await this.outpostClient.buildUnstakeIx(amountLamports, this.squadsVaultPDA)
|
|
354
|
+
return !!this.squadsX
|
|
355
|
+
? await this.sendSquadsIxs(ix)
|
|
356
|
+
: await this.buildAndSendIx(ix)
|
|
357
|
+
}
|
|
358
|
+
catch (err) {
|
|
359
|
+
console.log(`Failed to unstake Solana: ${err}`);
|
|
360
|
+
throw err;
|
|
361
|
+
}
|
|
403
362
|
}
|
|
404
363
|
|
|
405
364
|
/**
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
* Uses TrancheSnapshot + SOL/USD price for:
|
|
409
|
-
* - SOL: amount is lamports
|
|
410
|
-
* - LIQSOL: amount is liqSOL base units (decimals = 9)
|
|
411
|
-
* - YIELD: amount is treated as SOL lamports-equivalent of yield
|
|
365
|
+
* Buy prelaunch WIRE “pretokens” using liqSOL.
|
|
412
366
|
*
|
|
413
|
-
*
|
|
367
|
+
* This delegates to TokenClient, which uses the `purchase`-style
|
|
368
|
+
* instruction under the new IDL (no more native-SOL purchase).
|
|
414
369
|
*/
|
|
415
|
-
async
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const snapshot = await this.getTrancheSnapshot({
|
|
426
|
-
chainID: opts?.chainID,
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
const wirePriceUsd = snapshot.currentPriceUsd; // 1e8
|
|
430
|
-
const solPriceUsd = snapshot.nativePriceUsd; // 1e8
|
|
431
|
-
|
|
432
|
-
if (!wirePriceUsd || wirePriceUsd <= BigInt(0)) {
|
|
433
|
-
throw new Error('Invalid WIRE price in tranche snapshot');
|
|
370
|
+
async buy(amountLamports: bigint): Promise<string> {
|
|
371
|
+
this.ensureUser();
|
|
372
|
+
if (!amountLamports || amountLamports <= BigInt(0))
|
|
373
|
+
throw new Error('liqSOL pretoken purchase requires a positive amount.');
|
|
374
|
+
|
|
375
|
+
try {
|
|
376
|
+
const ix = await this.tokenClient.buildPurchaseIx(amountLamports, this.squadsVaultPDA)
|
|
377
|
+
return !!this.squadsX
|
|
378
|
+
? await this.sendSquadsIxs(ix)
|
|
379
|
+
: await this.buildAndSendIx(ix)
|
|
434
380
|
}
|
|
435
|
-
|
|
436
|
-
|
|
381
|
+
catch (err) {
|
|
382
|
+
console.log(`Failed to buy liqSOL pretokens: ${err}`);
|
|
383
|
+
throw err;
|
|
437
384
|
}
|
|
385
|
+
}
|
|
438
386
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
387
|
+
/** Deposit SOL to liqSOL, then syndicate that liqSOL in one transaction. Requires enough SOL for the deposit fee. */
|
|
388
|
+
async depositAndStake(amountLamports: bigint, wireAccount?: string): Promise<string> {
|
|
389
|
+
this.ensureUser();
|
|
390
|
+
if (!amountLamports || amountLamports <= BigInt(0))
|
|
391
|
+
throw new Error('Amount must be greater than zero.');
|
|
392
|
+
|
|
393
|
+
try {
|
|
394
|
+
const user = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
|
|
395
|
+
const depositIx = await this.convertClient.buildDepositTx(amountLamports, user);
|
|
396
|
+
const stakeIx = await this.outpostClient.buildStakeIx(
|
|
397
|
+
amountLamports,
|
|
398
|
+
user,
|
|
399
|
+
wireAccount,
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
return !!this.squadsX
|
|
403
|
+
? await this.sendSquadsIxs([depositIx, stakeIx])
|
|
404
|
+
: await this.buildAndSendIx([depositIx, stakeIx]);
|
|
405
|
+
} catch (err) {
|
|
406
|
+
console.log(`Failed to deposit and stake: ${err}`);
|
|
407
|
+
throw err;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
443
410
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
411
|
+
/** Deposit SOL to liqSOL, then buy pretokens with that liqSOL in one transaction. Requires enough SOL for the deposit fee. */
|
|
412
|
+
async depositAndBuy(amountLamports: bigint): Promise<string> {
|
|
413
|
+
this.ensureUser();
|
|
414
|
+
if (!amountLamports || amountLamports <= BigInt(0))
|
|
415
|
+
throw new Error('Amount must be greater than zero.');
|
|
416
|
+
|
|
417
|
+
try {
|
|
418
|
+
const user = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
|
|
419
|
+
const depositIx = await this.convertClient.buildDepositTx(amountLamports, user);
|
|
420
|
+
const purchaseIx = await this.tokenClient.buildPurchaseIx(amountLamports, user);
|
|
421
|
+
|
|
422
|
+
return !!this.squadsX
|
|
423
|
+
? await this.sendSquadsIxs([depositIx, purchaseIx])
|
|
424
|
+
: await this.buildAndSendIx([depositIx, purchaseIx]);
|
|
425
|
+
} catch (err) {
|
|
426
|
+
console.log(`Failed to deposit and buy: ${err}`);
|
|
427
|
+
throw err;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
450
430
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
431
|
+
/** Desyndicate liqSOL, then request withdraw in one transaction. */
|
|
432
|
+
async unstakeAndWithdraw(amountLamports: bigint): Promise<string> {
|
|
433
|
+
this.ensureUser();
|
|
434
|
+
if (!amountLamports || amountLamports <= BigInt(0))
|
|
435
|
+
throw new Error('Amount must be greater than zero.');
|
|
436
|
+
|
|
437
|
+
try {
|
|
438
|
+
const user = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
|
|
439
|
+
const unstakeIx = await this.outpostClient.buildUnstakeIx(amountLamports, user);
|
|
440
|
+
const withdrawIx = await this.convertClient.buildWithdrawTx(amountLamports, user);
|
|
441
|
+
|
|
442
|
+
return !!this.squadsX
|
|
443
|
+
? await this.sendSquadsIxs([unstakeIx, withdrawIx])
|
|
444
|
+
: await this.buildAndSendIx([unstakeIx, withdrawIx]);
|
|
445
|
+
} catch (err) {
|
|
446
|
+
console.log(`Failed to unstake and withdraw: ${err}`);
|
|
447
|
+
throw err;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
456
450
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
451
|
+
/**
|
|
452
|
+
* Aggregate view of the user’s balances on Solana:
|
|
453
|
+
* - native: SOL wallet balance
|
|
454
|
+
* - liq: liqSOL token balance (Token-2022 ATA)
|
|
455
|
+
* - staked: liqSOL staked in Outpost (synd/desynd) → outpostAccount.stakedLiqsol
|
|
456
|
+
* - wire: total WIRE pretokens purchased (1e8 scale)
|
|
457
|
+
* - yield: on-chain index/shares plus an estimated accrued liqSOL yield
|
|
458
|
+
* - extras: useful internal addresses and raw state for debugging/UX
|
|
459
|
+
*/
|
|
460
|
+
async getPortfolio(address?: string): Promise<Portfolio> {
|
|
461
|
+
// if (!this.pubKey) throw new Error('User pubKey is undefined');
|
|
462
|
+
try {
|
|
463
|
+
const user = address ? new SolPubKey(address) :
|
|
464
|
+
!!this.squadsX ? this.squadsVaultPDA! : this.solPubKey;
|
|
465
|
+
|
|
466
|
+
const reservePoolPDA = this.program.deriveReservePoolPda();
|
|
467
|
+
const vaultPDA = this.program.deriveVaultPda();
|
|
468
|
+
const liqsolMint = this.program.deriveLiqsolMintPda();
|
|
469
|
+
|
|
470
|
+
const userLiqsolAta = getAssociatedTokenAddressSync(
|
|
471
|
+
liqsolMint,
|
|
472
|
+
user,
|
|
473
|
+
true,
|
|
474
|
+
TOKEN_2022_PROGRAM_ID,
|
|
475
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
// NOTE:
|
|
479
|
+
// - nativeLamports: wallet SOL
|
|
480
|
+
// - actualBalResp: liqSOL balance in user ATA
|
|
481
|
+
// - snapshot: Outpost + pretokens + global index/shares
|
|
482
|
+
const [nativeLamports, actualBalResp, snapshot, claimableLamports] = await Promise.all([
|
|
483
|
+
this.connection.getBalance(user, 'confirmed'),
|
|
484
|
+
this.connection
|
|
485
|
+
.getTokenAccountBalance(userLiqsolAta, 'confirmed')
|
|
486
|
+
.catch(() => null),
|
|
487
|
+
this.outpostClient.fetchWireState(user).catch(() => null),
|
|
488
|
+
this.distributionClient.getClaimableLiqsol(user).catch(() => new BN(0)),
|
|
489
|
+
]);
|
|
490
|
+
|
|
491
|
+
const LIQSOL_DECIMALS = 9;
|
|
492
|
+
|
|
493
|
+
const actualAmountStr = actualBalResp?.value?.amount ?? '0';
|
|
494
|
+
|
|
495
|
+
const globalState = snapshot?.globalState ?? null;
|
|
496
|
+
const outpostAccount = snapshot?.outpostAccount ?? null;
|
|
497
|
+
const trancheState = snapshot?.trancheState ?? null;
|
|
498
|
+
const userPretokenRecord = snapshot?.userPretokenRecord ?? null;
|
|
499
|
+
|
|
500
|
+
// -----------------------------
|
|
501
|
+
// Staked liqSOL (Outpost)
|
|
502
|
+
// -----------------------------
|
|
503
|
+
// This is the liqSOL that has been syndicated into Outpost via `synd`.
|
|
504
|
+
// It lives on the outpost account as `stakedLiqsol`.
|
|
505
|
+
const stakedLiqsolStr =
|
|
506
|
+
outpostAccount?.stakedLiqsol?.toString?.() ?? '0';
|
|
507
|
+
|
|
508
|
+
// -----------------------------
|
|
509
|
+
// WIRE pretokens (1e8 scale)
|
|
510
|
+
// -----------------------------
|
|
511
|
+
// This is NOT stake — it’s the prelaunch WIRE position.
|
|
512
|
+
const wirePretokensStr =
|
|
513
|
+
userPretokenRecord?.totalPretokensPurchased?.toString?.() ??
|
|
514
|
+
'0';
|
|
515
|
+
|
|
516
|
+
// -----------------------------
|
|
517
|
+
// Yield view (index + shares)
|
|
518
|
+
// -----------------------------
|
|
519
|
+
// We expose:
|
|
520
|
+
// - currentIndex: globalState.currentIndex (1e12 scale)
|
|
521
|
+
// - totalShares: globalState.totalShares
|
|
522
|
+
// - userShares: outpostAccount.stakedShares
|
|
523
|
+
// - estimatedClaimLiqsol: floor(userShares * index / INDEX_SCALE)
|
|
524
|
+
// - estimatedYield: max(0, estimatedClaim - stakedLiqsol)
|
|
525
|
+
//
|
|
526
|
+
// This matches the capital-staking math:
|
|
527
|
+
// sharesToTokens(shares, index) = shares * index / INDEX_SCALE
|
|
528
|
+
const currentIndexStr =
|
|
529
|
+
globalState?.currentIndex?.toString?.() ?? '0';
|
|
530
|
+
const totalSharesStr =
|
|
531
|
+
globalState?.totalShares?.toString?.() ?? '0';
|
|
532
|
+
const userSharesStr =
|
|
533
|
+
outpostAccount?.stakedShares?.toString?.() ?? '0';
|
|
534
|
+
|
|
535
|
+
const stakedLiqsol = BigInt(stakedLiqsolStr);
|
|
536
|
+
const currentIndex = BigInt(currentIndexStr);
|
|
537
|
+
const totalShares = BigInt(totalSharesStr);
|
|
538
|
+
const userShares = BigInt(userSharesStr);
|
|
539
|
+
|
|
540
|
+
let estimatedClaim = BigInt(0);
|
|
541
|
+
let estimatedYield = BigInt(0);
|
|
542
|
+
|
|
543
|
+
if (userShares > BigInt(0) && currentIndex > BigInt(0)) {
|
|
544
|
+
// sharesToTokens(userShares, currentIndex)
|
|
545
|
+
estimatedClaim = (userShares * currentIndex) / INDEX_SCALE;
|
|
546
|
+
|
|
547
|
+
if (estimatedClaim > stakedLiqsol) {
|
|
548
|
+
estimatedYield = estimatedClaim - stakedLiqsol;
|
|
549
|
+
}
|
|
461
550
|
}
|
|
462
551
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
552
|
+
return {
|
|
553
|
+
native: {
|
|
554
|
+
amount: BigInt(nativeLamports),
|
|
555
|
+
symbol: 'SOL',
|
|
556
|
+
decimals: 9,
|
|
557
|
+
},
|
|
558
|
+
liq: {
|
|
559
|
+
amount: BigInt(actualAmountStr),
|
|
560
|
+
symbol: 'LiqSOL',
|
|
561
|
+
decimals: LIQSOL_DECIMALS,
|
|
562
|
+
ata: userLiqsolAta,
|
|
563
|
+
},
|
|
564
|
+
claimable: {
|
|
565
|
+
amount: BigInt(claimableLamports.toString()),
|
|
566
|
+
symbol: 'LiqSOL',
|
|
567
|
+
decimals: LIQSOL_DECIMALS,
|
|
568
|
+
ata: userLiqsolAta,
|
|
569
|
+
},
|
|
570
|
+
staked: {
|
|
571
|
+
// liqSOL staked in Outpost via `synd`
|
|
572
|
+
amount: stakedLiqsol,
|
|
573
|
+
symbol: 'LiqSOL',
|
|
574
|
+
decimals: LIQSOL_DECIMALS,
|
|
575
|
+
},
|
|
576
|
+
wire: {
|
|
577
|
+
// Prelaunch WIRE pretokens (1e8 scale)
|
|
578
|
+
amount: BigInt(wirePretokensStr),
|
|
579
|
+
symbol: '$WIRE',
|
|
580
|
+
decimals: 8,
|
|
581
|
+
},
|
|
582
|
+
yield: {
|
|
583
|
+
// Raw primitives so the frontend can display curves, charts, etc.
|
|
584
|
+
currentIndex,
|
|
585
|
+
indexScale: INDEX_SCALE,
|
|
586
|
+
totalShares,
|
|
587
|
+
userShares,
|
|
588
|
+
// liqSOL amounts (lamports) implied by index/shares
|
|
589
|
+
estimatedClaim,
|
|
590
|
+
estimatedYield,
|
|
591
|
+
},
|
|
592
|
+
extras: {
|
|
593
|
+
userLiqsolAta: userLiqsolAta.toBase58(),
|
|
594
|
+
reservePoolPDA: reservePoolPDA.toBase58(),
|
|
595
|
+
vaultPDA: vaultPDA.toBase58(),
|
|
596
|
+
globalIndex: globalState?.currentIndex?.toString(),
|
|
597
|
+
totalShares: globalState?.totalShares?.toString(),
|
|
598
|
+
currentTrancheNumber:
|
|
599
|
+
trancheState?.currentTrancheNumber?.toString(),
|
|
600
|
+
currentTranchePriceUsd:
|
|
601
|
+
trancheState?.currentTranchePriceUsd?.toString(), // 1e8 USD
|
|
602
|
+
},
|
|
603
|
+
chainID: this.network.chainId,
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
catch (err) {
|
|
607
|
+
console.log(`Failed to get Solana portfolio: ${err}`);
|
|
608
|
+
throw err;
|
|
609
|
+
}
|
|
487
610
|
}
|
|
488
611
|
|
|
489
612
|
/**
|
|
@@ -491,72 +614,197 @@ export class SolanaStakingClient implements IStakingClient {
|
|
|
491
614
|
* Used by balance-correction flows and debugging.
|
|
492
615
|
*/
|
|
493
616
|
async getUserRecord() {
|
|
617
|
+
if (!this.pubKey) throw new Error('User pubKey is undefined');
|
|
494
618
|
return this.distributionClient.getUserRecord(this.solPubKey);
|
|
495
619
|
}
|
|
496
620
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
* - signs and sends the transaction if it can succeed
|
|
501
|
-
*/
|
|
502
|
-
async correctBalance(amount?: bigint): Promise<string> {
|
|
503
|
-
const build = await this.distributionClient.buildCorrectRegisterTx({ amount });
|
|
504
|
-
if (!build.canSucceed || !build.transaction) {
|
|
505
|
-
throw new Error(build.reason ?? 'Unable to build Correct&Register transaction');
|
|
506
|
-
}
|
|
621
|
+
// ---------------------------------------------------------------------
|
|
622
|
+
// SquadsX Helpers
|
|
623
|
+
// ---------------------------------------------------------------------
|
|
507
624
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
625
|
+
get squadsMultisigPDA(): SolPubKey | undefined {
|
|
626
|
+
if (!this.squadsX) return undefined;
|
|
627
|
+
return new SolPubKey(this.squadsX.multisigPDA);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
get squadsVaultPDA(): SolPubKey | undefined {
|
|
631
|
+
if (!this.squadsX || !this.squadsMultisigPDA) return undefined;
|
|
632
|
+
const multisigPda = this.squadsMultisigPDA;
|
|
633
|
+
const index = this.squadsX.vaultIndex ?? 0;
|
|
634
|
+
const pda = multisig.getVaultPda({ multisigPda, index });
|
|
635
|
+
return pda[0];
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/** Create a Squads vault transaction/proposal for one or more instructions. */
|
|
639
|
+
private async sendSquadsIxs(ix: TransactionInstruction | TransactionInstruction[]): Promise<string> {
|
|
640
|
+
if (!this.squadsX) throw new Error('Attempting to wrap Squads instruction without SquadsX config');
|
|
641
|
+
|
|
642
|
+
const ixs = Array.isArray(ix) ? ix : [ix];
|
|
643
|
+
const multisigPda = this.squadsMultisigPDA!;
|
|
644
|
+
const vaultPda = this.squadsVaultPDA!;
|
|
645
|
+
const vaultIndex = this.squadsX?.vaultIndex ?? 0;
|
|
646
|
+
const creator = this.solPubKey;
|
|
647
|
+
|
|
648
|
+
const ms = await multisig.accounts.Multisig.fromAccountAddress(this.connection, multisigPda);
|
|
649
|
+
const current = BigInt(ms.transactionIndex?.toString() ?? 0);
|
|
650
|
+
const transactionIndex = current + BigInt(1);
|
|
651
|
+
|
|
652
|
+
const altAddress = this.program.PROGRAM_IDS.ALT;
|
|
653
|
+
const altAccount = await this.connection.getAddressLookupTable(altAddress);
|
|
654
|
+
if (!altAccount.value) throw new Error("ALT not found on-chain or not yet active.");
|
|
655
|
+
|
|
656
|
+
const lookupTable: AddressLookupTableAccount = altAccount.value;
|
|
657
|
+
const computeLimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 });
|
|
658
|
+
const computePriceIx = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 2000 });
|
|
659
|
+
|
|
660
|
+
const { blockhash } = await this.connection.getLatestBlockhash("confirmed");
|
|
661
|
+
const transactionMessage = new TransactionMessage({
|
|
662
|
+
payerKey: vaultPda,
|
|
663
|
+
recentBlockhash: blockhash,
|
|
664
|
+
instructions: [computeLimitIx, computePriceIx, ...ixs],
|
|
515
665
|
});
|
|
516
|
-
|
|
666
|
+
|
|
667
|
+
const createVaultTxIx = await multisig.instructions.vaultTransactionCreate({
|
|
668
|
+
multisigPda,
|
|
669
|
+
transactionIndex,
|
|
670
|
+
creator,
|
|
671
|
+
vaultIndex,
|
|
672
|
+
transactionMessage,
|
|
673
|
+
ephemeralSigners: 0,
|
|
674
|
+
addressLookupTableAccounts: [lookupTable],
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
const vaultTransactionCreate = await this.buildAndSendIx(createVaultTxIx)
|
|
678
|
+
console.log('SQUADSX: vaultTransactionCreate', vaultTransactionCreate);
|
|
679
|
+
|
|
680
|
+
const createProposalIx = await multisig.instructions.proposalCreate({
|
|
681
|
+
multisigPda,
|
|
682
|
+
transactionIndex,
|
|
683
|
+
creator,
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
const proposalCreate = await this.buildAndSendIx(createProposalIx)
|
|
687
|
+
console.log('SQUADSX: proposalCreate', proposalCreate);
|
|
688
|
+
|
|
689
|
+
return proposalCreate;
|
|
517
690
|
}
|
|
518
691
|
|
|
692
|
+
// async finish(multisigPda: string, transactionIndex: number): Promise<void> {
|
|
693
|
+
// const vaultExecute = await multisig.instructions.vaultTransactionExecute({
|
|
694
|
+
// connection: this.connection,
|
|
695
|
+
// multisigPda: new SolPubKey(multisigPda),
|
|
696
|
+
// transactionIndex: BigInt(transactionIndex),
|
|
697
|
+
// member: this.solPubKey
|
|
698
|
+
// });
|
|
699
|
+
|
|
700
|
+
// const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 400_000 });
|
|
701
|
+
// const tx1 = new Transaction().add(cuIx, vaultExecute.instruction);
|
|
702
|
+
// const prepared1 = await this.prepareTx(tx1);
|
|
703
|
+
// const signed1 = await this.signTransaction(prepared1.tx);
|
|
704
|
+
// const sent1 = await this.sendAndConfirmHttp(signed1, prepared1);
|
|
705
|
+
// console.log('SENT FINISH', sent1);
|
|
706
|
+
// }
|
|
707
|
+
|
|
519
708
|
// ---------------------------------------------------------------------
|
|
520
709
|
// Tx helpers
|
|
521
710
|
// ---------------------------------------------------------------------
|
|
522
711
|
|
|
712
|
+
async buildAndSendIx(ix: TransactionInstruction | TransactionInstruction[]): Promise<string> {
|
|
713
|
+
const ixs = Array.isArray(ix) ? ix : [ix];
|
|
714
|
+
const computeLimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 });
|
|
715
|
+
const computePriceIx = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 2000 });
|
|
716
|
+
const { blockhash, lastValidBlockHeight } =
|
|
717
|
+
await this.connection.getLatestBlockhash('confirmed');
|
|
718
|
+
|
|
719
|
+
const altAddress = this.program.PROGRAM_IDS.ALT;
|
|
720
|
+
const altAccount = await this.connection.getAddressLookupTable(altAddress);
|
|
721
|
+
const lookupTable = altAccount.value;
|
|
722
|
+
|
|
723
|
+
const instructions = [computeLimitIx, computePriceIx, ...ixs];
|
|
724
|
+
|
|
725
|
+
const tx = lookupTable
|
|
726
|
+
? new VersionedTransaction(
|
|
727
|
+
new TransactionMessage({
|
|
728
|
+
payerKey: this.feePayer,
|
|
729
|
+
recentBlockhash: blockhash,
|
|
730
|
+
instructions,
|
|
731
|
+
}).compileToV0Message([lookupTable]),
|
|
732
|
+
)
|
|
733
|
+
: new Transaction().add(...instructions);
|
|
734
|
+
|
|
735
|
+
const prepared =
|
|
736
|
+
tx instanceof Transaction
|
|
737
|
+
? await this.prepareTx(tx)
|
|
738
|
+
: { tx, blockhash, lastValidBlockHeight };
|
|
739
|
+
|
|
740
|
+
const signed = await this.signTransaction(prepared.tx);
|
|
741
|
+
|
|
742
|
+
return this.sendAndConfirmHttp(signed, prepared);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
|
|
523
746
|
/**
|
|
524
|
-
* Send a signed transaction over HTTP RPC
|
|
525
|
-
*
|
|
747
|
+
* Send a signed transaction over HTTP RPC.
|
|
748
|
+
*
|
|
749
|
+
* - Returns immediately on successful sendRawTransaction.
|
|
750
|
+
* - If sendRawTransaction throws a SendTransactionError with
|
|
751
|
+
* "already been processed", we treat it as success and
|
|
752
|
+
* just return a derived signature.
|
|
753
|
+
* - No confirmTransaction / polling / blockheight handling.
|
|
526
754
|
*/
|
|
527
755
|
private async sendAndConfirmHttp(
|
|
528
756
|
signed: SolanaTransaction,
|
|
529
|
-
|
|
757
|
+
_ctx: { blockhash: string; lastValidBlockHeight: number },
|
|
530
758
|
): Promise<string> {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
759
|
+
this.ensureUser();
|
|
760
|
+
|
|
761
|
+
const rawTx = signed.serialize();
|
|
762
|
+
|
|
763
|
+
try {
|
|
764
|
+
// Normal happy path: RPC accepts the tx and returns a signature
|
|
765
|
+
const signature = await this.connection.sendRawTransaction(rawTx, {
|
|
534
766
|
skipPreflight: false,
|
|
535
767
|
preflightCommitment: commitment,
|
|
536
768
|
maxRetries: 3,
|
|
537
|
-
}
|
|
538
|
-
|
|
769
|
+
});
|
|
770
|
+
return signature;
|
|
771
|
+
} catch (e: any) {
|
|
772
|
+
const msg = e?.message ?? '';
|
|
773
|
+
const isSendTxError =
|
|
774
|
+
e instanceof SendTransactionError || e?.name === 'SendTransactionError';
|
|
775
|
+
|
|
776
|
+
// Benign duplicate case: tx is already in the ledger / cache
|
|
777
|
+
if (isSendTxError && msg.includes('already been processed')) {
|
|
778
|
+
console.warn(
|
|
779
|
+
'sendRawTransaction reports "already been processed"; ' +
|
|
780
|
+
'treating as success without further confirmation.',
|
|
781
|
+
);
|
|
539
782
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
lastValidBlockHeight: ctx.lastValidBlockHeight,
|
|
545
|
-
},
|
|
546
|
-
commitment,
|
|
547
|
-
);
|
|
783
|
+
// Try to derive a signature from the signed Transaction.
|
|
784
|
+
// If SolanaTransaction is a legacy Transaction, this works.
|
|
785
|
+
const legacy = signed as unknown as Transaction;
|
|
786
|
+
const first = legacy.signatures?.[0]?.signature;
|
|
548
787
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
788
|
+
if (first) {
|
|
789
|
+
return bs58.encode(first);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// Fallback: return a dummy string
|
|
793
|
+
return 'already-processed';
|
|
794
|
+
}
|
|
552
795
|
|
|
553
|
-
|
|
796
|
+
// Any other send error is a real failure
|
|
797
|
+
throw e;
|
|
798
|
+
}
|
|
554
799
|
}
|
|
555
800
|
|
|
556
801
|
/**
|
|
557
802
|
* Sign a single Solana transaction using the connected wallet adapter.
|
|
558
803
|
*/
|
|
559
|
-
async signTransaction(
|
|
804
|
+
async signTransaction(
|
|
805
|
+
tx: SolanaTransaction,
|
|
806
|
+
): Promise<SolanaTransaction> {
|
|
807
|
+
this.ensureUser();
|
|
560
808
|
return this.anchor.wallet.signTransaction(tx);
|
|
561
809
|
}
|
|
562
810
|
|
|
@@ -564,7 +812,10 @@ export class SolanaStakingClient implements IStakingClient {
|
|
|
564
812
|
* Generic "fire and forget" send helper if the caller already
|
|
565
813
|
* prepared and signed the transaction.
|
|
566
814
|
*/
|
|
567
|
-
async sendTransaction(
|
|
815
|
+
async sendTransaction(
|
|
816
|
+
signed: SolanaTransaction,
|
|
817
|
+
): Promise<TransactionSignature> {
|
|
818
|
+
this.ensureUser();
|
|
568
819
|
return this.anchor.sendAndConfirm(signed);
|
|
569
820
|
}
|
|
570
821
|
|
|
@@ -574,11 +825,431 @@ export class SolanaStakingClient implements IStakingClient {
|
|
|
574
825
|
*/
|
|
575
826
|
async prepareTx(
|
|
576
827
|
tx: Transaction,
|
|
577
|
-
): Promise<{
|
|
828
|
+
): Promise<{
|
|
829
|
+
tx: Transaction;
|
|
830
|
+
blockhash: string;
|
|
831
|
+
lastValidBlockHeight: number;
|
|
832
|
+
}> {
|
|
578
833
|
const { blockhash, lastValidBlockHeight } =
|
|
579
834
|
await this.connection.getLatestBlockhash('confirmed');
|
|
580
835
|
tx.recentBlockhash = blockhash;
|
|
581
|
-
tx.feePayer = this.
|
|
836
|
+
tx.feePayer = this.feePayer;
|
|
582
837
|
return { tx, blockhash, lastValidBlockHeight };
|
|
583
838
|
}
|
|
584
|
-
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Guard for all write operations (deposit/withdraw/stake/unstake/buy).
|
|
842
|
+
* Ensures we have a Wire pubKey and an Anchor wallet pubKey, and that they match.
|
|
843
|
+
*/
|
|
844
|
+
ensureUser() {
|
|
845
|
+
if (!this.pubKey) throw new Error('User pubKey is undefined');
|
|
846
|
+
|
|
847
|
+
const wallet = this.anchor?.wallet as any;
|
|
848
|
+
const pk = wallet?.publicKey as SolPubKey | undefined;
|
|
849
|
+
|
|
850
|
+
if (!pk) throw new Error('Wallet not connected');
|
|
851
|
+
if (typeof wallet.signTransaction !== 'function') {
|
|
852
|
+
throw new Error('Wallet does not support signTransaction');
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// if (!this.pubKey || !this.anchor.wallet.publicKey) {
|
|
856
|
+
// throw new Error('User Authorization required: pubKey is undefined');
|
|
857
|
+
// }
|
|
858
|
+
// if (
|
|
859
|
+
// this.solPubKey.toBase58() !==
|
|
860
|
+
// this.anchor.wallet.publicKey.toBase58()
|
|
861
|
+
// ) {
|
|
862
|
+
// throw new Error(
|
|
863
|
+
// 'Write access requires connected wallet to match pubKey',
|
|
864
|
+
// );
|
|
865
|
+
// }
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
// ---------------------------------------------------------------------
|
|
869
|
+
// READ-ONLY Public Methods
|
|
870
|
+
// ---------------------------------------------------------------------
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Unified, chain-agnostic tranche snapshot for Solana.
|
|
874
|
+
*
|
|
875
|
+
* Uses:
|
|
876
|
+
* - liqsol_core.globalState (currentIndex, totalShares, etc.)
|
|
877
|
+
* - liqsol_core.trancheState (price, supply, total sold, etc.)
|
|
878
|
+
* - PriceHistory/Chainlink SOL/USD via TokenClient.getSolPriceUsdSafe()
|
|
879
|
+
*
|
|
880
|
+
* This is READ-ONLY and works even with no connected wallet.
|
|
881
|
+
*/
|
|
882
|
+
async getTrancheSnapshot(chainID: ChainID): Promise<TrancheSnapshot> {
|
|
883
|
+
try {
|
|
884
|
+
const [globalState, trancheState] = await Promise.all([
|
|
885
|
+
this.tokenClient.fetchGlobalState(),
|
|
886
|
+
this.tokenClient.fetchTrancheState(),
|
|
887
|
+
]);
|
|
888
|
+
|
|
889
|
+
const { price: solPriceUsd, timestamp } =
|
|
890
|
+
await this.tokenClient.getSolPriceUsdSafe();
|
|
891
|
+
|
|
892
|
+
return buildSolanaTrancheSnapshot({
|
|
893
|
+
chainID,
|
|
894
|
+
globalState,
|
|
895
|
+
trancheState,
|
|
896
|
+
solPriceUsd,
|
|
897
|
+
nativePriceTimestamp: timestamp,
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
catch (err) {
|
|
901
|
+
console.log(`Failed to build Solana tranche snapshot: ${err}`);
|
|
902
|
+
throw err;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Returns the system APY (percent) for Solana,
|
|
908
|
+
* using compound interest per epoch and a
|
|
909
|
+
* cluster-derived epochs-per-year.
|
|
910
|
+
*/
|
|
911
|
+
async getSystemAPY(): Promise<number> {
|
|
912
|
+
try {
|
|
913
|
+
// 1) Per-epoch rate (decimal) from on-chain stakeMetrics
|
|
914
|
+
const ratePerEpoch = await this.getEpochRateDecimalFromProgram();
|
|
915
|
+
// 2) Live epochs-per-year estimate from cluster
|
|
916
|
+
const epochsPerYear = await this.getEpochsPerYearFromCluster();
|
|
917
|
+
// 3) Compound: (1 + r)^N - 1
|
|
918
|
+
const apyDecimal = Math.pow(1 + ratePerEpoch, epochsPerYear) - 1;
|
|
919
|
+
// 4) Convert to percent
|
|
920
|
+
const apyPercent = apyDecimal * 100;
|
|
921
|
+
|
|
922
|
+
return apyPercent;
|
|
923
|
+
} catch (err) {
|
|
924
|
+
console.log(`Failed to compute Solana system APY: ${err}`);
|
|
925
|
+
throw err;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Reads the liqsol_core stakeMetrics account and returns the
|
|
931
|
+
* Solana per-epoch system rate as a **decimal** (not BPS),
|
|
932
|
+
* de-scaled using PAY_RATE_SCALE_FACTOR (1e12).
|
|
933
|
+
*/
|
|
934
|
+
private async getEpochRateDecimalFromProgram(): Promise<number> {
|
|
935
|
+
const liqSolCoreProgram = this.program.getProgram('liqsolCore');
|
|
936
|
+
const payRateHistoryPda = this.program.derivePayRateHistoryPda();
|
|
937
|
+
|
|
938
|
+
const payRateHistory =
|
|
939
|
+
await liqSolCoreProgram.account.payRateHistory.fetch(payRateHistoryPda);
|
|
940
|
+
|
|
941
|
+
const totalEntriesAdded = Number(payRateHistory.totalEntriesAdded);
|
|
942
|
+
const maxEntries = Number(payRateHistory.maxEntries);
|
|
943
|
+
|
|
944
|
+
if (totalEntriesAdded === 0) {
|
|
945
|
+
// No real entries yet, fall back to default
|
|
946
|
+
return Number(DEFAULT_AVERAGE_PAY_RATE) / Number(PAY_RATE_SCALE_FACTOR);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
const currentIndex = Number(payRateHistory.currentIndex);
|
|
950
|
+
|
|
951
|
+
// Only average entries that have actually been processed (written by add_entry),
|
|
952
|
+
// not the default-initialized slots. After 10+ entries, processedCount === maxEntries.
|
|
953
|
+
const processedCount = Math.min(totalEntriesAdded, maxEntries);
|
|
954
|
+
|
|
955
|
+
let sum = BigInt(0);
|
|
956
|
+
let validCount = 0;
|
|
957
|
+
// Walk backward from most recent entry
|
|
958
|
+
let idx = (currentIndex - 1 + maxEntries) % maxEntries;
|
|
959
|
+
|
|
960
|
+
for (let i = 0; i < processedCount; i++) {
|
|
961
|
+
const entry = payRateHistory.entries[idx];
|
|
962
|
+
const scaledRate = BigInt(entry.scaledRate.toString());
|
|
963
|
+
if (scaledRate > BigInt(0)) {
|
|
964
|
+
sum += scaledRate;
|
|
965
|
+
validCount++;
|
|
966
|
+
}
|
|
967
|
+
idx = (idx - 1 + maxEntries) % maxEntries;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
if (validCount === 0) {
|
|
971
|
+
return Number(DEFAULT_AVERAGE_PAY_RATE) / Number(PAY_RATE_SCALE_FACTOR);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// Average the processed entries
|
|
975
|
+
const average = Number(sum / BigInt(validCount));
|
|
976
|
+
return average / Number(PAY_RATE_SCALE_FACTOR);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// Simple cache so we don’t hammer RPC
|
|
980
|
+
private epochsPerYearCache?: { value: number; fetchedAt: number };
|
|
981
|
+
private static readonly EPOCHS_PER_YEAR_TTL_MS = 10 * 60 * 1000; // 10 minutes
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* Derive "epochs per year" from the live Solana cluster.
|
|
985
|
+
*
|
|
986
|
+
* Uses:
|
|
987
|
+
* - getRecentPerformanceSamples() to estimate slots/second
|
|
988
|
+
* - getEpochInfo() to read slotsInEpoch
|
|
989
|
+
*/
|
|
990
|
+
private async getEpochsPerYearFromCluster(): Promise<number> {
|
|
991
|
+
const now = Date.now();
|
|
992
|
+
|
|
993
|
+
if (
|
|
994
|
+
this.epochsPerYearCache &&
|
|
995
|
+
now - this.epochsPerYearCache.fetchedAt <
|
|
996
|
+
SolanaStakingClient.EPOCHS_PER_YEAR_TTL_MS
|
|
997
|
+
) {
|
|
998
|
+
return this.epochsPerYearCache.value;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
const connection = this.anchor.connection;
|
|
1002
|
+
|
|
1003
|
+
// 1) Estimate slots/second from recent performance samples
|
|
1004
|
+
const samples: PerfSample[] = await connection.getRecentPerformanceSamples(
|
|
1005
|
+
60,
|
|
1006
|
+
);
|
|
1007
|
+
if (!samples.length) {
|
|
1008
|
+
throw new Error('No performance samples available from cluster');
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
const totalSlots = samples.reduce((acc, s) => acc + s.numSlots, 0);
|
|
1012
|
+
const totalSecs = samples.reduce((acc, s) => acc + s.samplePeriodSecs, 0);
|
|
1013
|
+
|
|
1014
|
+
if (totalSecs === 0) {
|
|
1015
|
+
throw new Error(
|
|
1016
|
+
'Cluster returned zero samplePeriodSecs in performance samples',
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
const slotsPerSecond = totalSlots / totalSecs;
|
|
1021
|
+
|
|
1022
|
+
// 2) Slots per epoch from cluster
|
|
1023
|
+
const epochInfo = await connection.getEpochInfo(); // finalized commitment by default
|
|
1024
|
+
const slotsPerEpoch = epochInfo.slotsInEpoch;
|
|
1025
|
+
|
|
1026
|
+
const secondsPerEpoch = slotsPerEpoch / slotsPerSecond;
|
|
1027
|
+
const secondsPerYear = 365 * 24 * 60 * 60;
|
|
1028
|
+
|
|
1029
|
+
const epochsPerYear = secondsPerYear / secondsPerEpoch;
|
|
1030
|
+
|
|
1031
|
+
this.epochsPerYearCache = {
|
|
1032
|
+
value: epochsPerYear,
|
|
1033
|
+
fetchedAt: now,
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
return epochsPerYear;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// ---------------------------------------------
|
|
1040
|
+
// Deposit fee calculation (SOL -> liqSOL)
|
|
1041
|
+
// ---------------------------------------------
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* Estimate the protocol deposit fee in lamports for a given SOL amount,
|
|
1045
|
+
* based on recent pay rates and globalConfig.depositFeeMultiplier.
|
|
1046
|
+
*
|
|
1047
|
+
* - amountLamports: deposit notional in lamports
|
|
1048
|
+
* - windowSize: how many recent payRate entries to average (default 5)
|
|
1049
|
+
*
|
|
1050
|
+
* Returns 0n if payRateHistory or globalConfig is missing, or if
|
|
1051
|
+
* there are no valid pay-rate entries yet.
|
|
1052
|
+
*/
|
|
1053
|
+
async getDepositFee(
|
|
1054
|
+
amountLamports: bigint,
|
|
1055
|
+
windowSize = 5,
|
|
1056
|
+
): Promise<bigint> {
|
|
1057
|
+
if (amountLamports <= BigInt(0)) {
|
|
1058
|
+
return BigInt(0);
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
const [avgPayRate, globalConfig]: [BN, GlobalConfig | null] = await Promise.all([
|
|
1062
|
+
this.distributionClient.getAverageScaledPayRate(windowSize),
|
|
1063
|
+
this.distributionClient.getGlobalConfig(),
|
|
1064
|
+
]);
|
|
1065
|
+
|
|
1066
|
+
if (!globalConfig || avgPayRate.isZero()) {
|
|
1067
|
+
return BigInt(0);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// depositFeeMultiplier may be BN or number depending on your type
|
|
1071
|
+
const rawMultiplier = globalConfig.depositFeeMultiplier;
|
|
1072
|
+
const multiplier = new BN(
|
|
1073
|
+
rawMultiplier?.toString?.() ?? rawMultiplier ?? 0,
|
|
1074
|
+
);
|
|
1075
|
+
if (multiplier.isZero()) {
|
|
1076
|
+
return BigInt(0);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
const amountBn = new BN(amountLamports.toString());
|
|
1080
|
+
|
|
1081
|
+
// 10^12 scale (matches scaledRate / index scale)
|
|
1082
|
+
|
|
1083
|
+
const feeBn = ceilDiv(
|
|
1084
|
+
avgPayRate.mul(multiplier).mul(amountBn),
|
|
1085
|
+
SCALE,
|
|
1086
|
+
);
|
|
1087
|
+
|
|
1088
|
+
return BigInt(feeBn.toString());
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* Compute a conservative "deposit buffer" in lamports that should be left
|
|
1093
|
+
* in the wallet so that a MAX deposit (balance - buffer) will succeed.
|
|
1094
|
+
*
|
|
1095
|
+
* It accounts for:
|
|
1096
|
+
* - Runtime tx fees (via cached dummy self-transfer fee)
|
|
1097
|
+
* - Protocol deposit fee (via getDepositFee(amount))
|
|
1098
|
+
*
|
|
1099
|
+
* Intended UI usage:
|
|
1100
|
+
* const buffer = await client.getDepositBuffer();
|
|
1101
|
+
* const balance = portfolio.native.amount;
|
|
1102
|
+
* const maxDeposit = balance > buffer ? balance - buffer : BigInt(0);
|
|
1103
|
+
*/
|
|
1104
|
+
async getDepositBuffer(options?: {
|
|
1105
|
+
txCount?: number; // how many txs to cover in gas buffer (default 2)
|
|
1106
|
+
safetyMultiplier?: number; // safety multiplier on per-tx fee (default 3x)
|
|
1107
|
+
minBufferLamports?: bigint; // minimum gas buffer (default ~0.01 SOL)
|
|
1108
|
+
balanceOverrideLamports?: bigint; // for tests/custom callers
|
|
1109
|
+
}): Promise<bigint> {
|
|
1110
|
+
this.ensureUser();
|
|
1111
|
+
|
|
1112
|
+
// -------------------------------------------------------------
|
|
1113
|
+
// 1) Current wallet balance (prefer caller override)
|
|
1114
|
+
// -------------------------------------------------------------
|
|
1115
|
+
const balanceLamports: bigint =
|
|
1116
|
+
options?.balanceOverrideLamports ??
|
|
1117
|
+
BigInt(await this.connection.getBalance(this.feePayer, commitment));
|
|
1118
|
+
|
|
1119
|
+
if (balanceLamports <= BigInt(0)) {
|
|
1120
|
+
return BigInt(0);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
// -------------------------------------------------------------
|
|
1124
|
+
// 2) Estimate gas buffer (using cached single-tx fee)
|
|
1125
|
+
// -------------------------------------------------------------
|
|
1126
|
+
let gasBuffer = BigInt(0);
|
|
1127
|
+
|
|
1128
|
+
try {
|
|
1129
|
+
const singleTxFeeLamports = await this.getSingleTxFeeLamports();
|
|
1130
|
+
|
|
1131
|
+
const txCount = BigInt(options?.txCount ?? 2);
|
|
1132
|
+
const safetyMultiplier = options?.safetyMultiplier ?? 3;
|
|
1133
|
+
const safetyScaled = BigInt(Math.round(safetyMultiplier * 100)); // e.g. 300
|
|
1134
|
+
|
|
1135
|
+
let buf =
|
|
1136
|
+
(singleTxFeeLamports * txCount * safetyScaled) /
|
|
1137
|
+
BigInt(100);
|
|
1138
|
+
|
|
1139
|
+
const defaultMinBufferLamports = BigInt(10_000_000); // ~0.01 SOL
|
|
1140
|
+
const minBufferLamports =
|
|
1141
|
+
options?.minBufferLamports ?? defaultMinBufferLamports;
|
|
1142
|
+
|
|
1143
|
+
if (buf < minBufferLamports) {
|
|
1144
|
+
buf = minBufferLamports;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
gasBuffer = buf;
|
|
1148
|
+
} catch {
|
|
1149
|
+
// If fee estimation fails, just fall back to "no gas buffer".
|
|
1150
|
+
gasBuffer = BigInt(0);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
// If gas buffer alone eats the whole balance, we just keep everything.
|
|
1154
|
+
if (balanceLamports <= gasBuffer) {
|
|
1155
|
+
return balanceLamports;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
const spendable = balanceLamports - gasBuffer;
|
|
1159
|
+
|
|
1160
|
+
// -------------------------------------------------------------
|
|
1161
|
+
// 3) If we can't compute deposit fee, buffer == gasBuffer
|
|
1162
|
+
// -------------------------------------------------------------
|
|
1163
|
+
if (typeof this.getDepositFee !== 'function') {
|
|
1164
|
+
return gasBuffer;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
// -------------------------------------------------------------
|
|
1168
|
+
// 4) Approximate principal using linear fee model from ONE RPC call
|
|
1169
|
+
//
|
|
1170
|
+
// fee(a) ≈ k * a
|
|
1171
|
+
// want: a + k*a <= spendable → a <= spendable / (1 + k)
|
|
1172
|
+
//
|
|
1173
|
+
// We estimate k from fee(spendable) / spendable.
|
|
1174
|
+
// -------------------------------------------------------------
|
|
1175
|
+
let feeAtSpendable: bigint;
|
|
1176
|
+
|
|
1177
|
+
try {
|
|
1178
|
+
feeAtSpendable = await this.getDepositFee(spendable);
|
|
1179
|
+
} catch {
|
|
1180
|
+
// If protocol fee lookup fails, fall back to gas-only buffer
|
|
1181
|
+
return gasBuffer;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// If there is effectively no protocol fee, keep only gas buffer.
|
|
1185
|
+
if (feeAtSpendable <= BigInt(0)) {
|
|
1186
|
+
return gasBuffer;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
const s = spendable;
|
|
1190
|
+
const f = feeAtSpendable;
|
|
1191
|
+
|
|
1192
|
+
// denom = s + f = s * (1 + k) (since f ≈ k*s)
|
|
1193
|
+
const denom = s + f;
|
|
1194
|
+
if (denom === BigInt(0)) {
|
|
1195
|
+
return gasBuffer;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// a ≈ floor( s^2 / (s + f) )
|
|
1199
|
+
let a = (s * s) / denom;
|
|
1200
|
+
|
|
1201
|
+
// Tiny safety haircut to avoid edge off-by-one lamports
|
|
1202
|
+
const fudge = BigInt(10_000); // ≈ 0.00001 SOL
|
|
1203
|
+
let effectivePrincipal =
|
|
1204
|
+
a > fudge ? a - fudge : a;
|
|
1205
|
+
|
|
1206
|
+
if (effectivePrincipal < BigInt(0)) {
|
|
1207
|
+
effectivePrincipal = BigInt(0);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
const buffer = balanceLamports > effectivePrincipal
|
|
1211
|
+
? balanceLamports - effectivePrincipal
|
|
1212
|
+
: balanceLamports;
|
|
1213
|
+
|
|
1214
|
+
// Ensure we never under-reserve gas.
|
|
1215
|
+
return buffer < gasBuffer ? gasBuffer : buffer;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
private cachedTxFee?: { value: bigint; fetchedAt: number };
|
|
1219
|
+
private static readonly FEE_CACHE_TTL_MS = 60_000; // 60s
|
|
1220
|
+
|
|
1221
|
+
private async getSingleTxFeeLamports(): Promise<bigint> {
|
|
1222
|
+
const now = Date.now();
|
|
1223
|
+
|
|
1224
|
+
if (this.cachedTxFee && now - this.cachedTxFee.fetchedAt < SolanaStakingClient.FEE_CACHE_TTL_MS) {
|
|
1225
|
+
return this.cachedTxFee.value;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
const payer = this.feePayer;
|
|
1229
|
+
|
|
1230
|
+
const dummyIx = SystemProgram.transfer({
|
|
1231
|
+
fromPubkey: payer,
|
|
1232
|
+
toPubkey: payer,
|
|
1233
|
+
lamports: 0,
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
const tx = new Transaction().add(dummyIx);
|
|
1237
|
+
const { blockhash } = await this.connection.getLatestBlockhash(commitment);
|
|
1238
|
+
tx.recentBlockhash = blockhash;
|
|
1239
|
+
tx.feePayer = payer;
|
|
1240
|
+
|
|
1241
|
+
const message = tx.compileMessage();
|
|
1242
|
+
const feeInfo = await this.connection.getFeeForMessage(message, commitment);
|
|
1243
|
+
|
|
1244
|
+
const singleTxFeeLamports = BigInt(feeInfo.value ?? 5000);
|
|
1245
|
+
|
|
1246
|
+
this.cachedTxFee = {
|
|
1247
|
+
value: singleTxFeeLamports,
|
|
1248
|
+
fetchedAt: now,
|
|
1249
|
+
};
|
|
1250
|
+
|
|
1251
|
+
return singleTxFeeLamports;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
}
|