@wireio/stake 0.4.3 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/lib/stake.browser.js +12820 -6787
  2. package/lib/stake.browser.js.map +1 -1
  3. package/lib/stake.d.ts +353 -209
  4. package/lib/stake.js +12940 -6886
  5. package/lib/stake.js.map +1 -1
  6. package/lib/stake.m.js +12820 -6787
  7. package/lib/stake.m.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/assets/ethereum/ABI/common/Base58.sol/Base58.dbg.json +4 -0
  10. package/src/assets/ethereum/ABI/common/Base58.sol/Base58.json +164 -0
  11. package/src/assets/ethereum/ABI/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.dbg.json +4 -0
  12. package/src/assets/ethereum/ABI/common/OpenZepArtifacts.sol/__Dummy_OZ_UUPS__.json +76 -0
  13. package/src/assets/ethereum/ABI/common/RestrictedCallers.sol/RestrictedCallers.dbg.json +4 -0
  14. package/src/assets/ethereum/ABI/common/RestrictedCallers.sol/RestrictedCallers.json +10 -0
  15. package/src/assets/ethereum/ABI/common/iodata.sol/iodata.dbg.json +4 -0
  16. package/src/assets/ethereum/ABI/common/iodata.sol/iodata.json +618 -0
  17. package/src/assets/ethereum/ABI/common/iodata_util.sol/iodata_util.dbg.json +4 -0
  18. package/src/assets/ethereum/ABI/common/iodata_util.sol/iodata_util.json +40 -0
  19. package/src/assets/ethereum/ABI/common/sysio_data.sol/sysio_data.dbg.json +4 -0
  20. package/src/assets/ethereum/ABI/common/sysio_data.sol/sysio_data.json +10 -0
  21. package/src/assets/ethereum/ABI/common/sysio_errors.sol/sysio_errors.dbg.json +4 -0
  22. package/src/assets/ethereum/ABI/common/sysio_errors.sol/sysio_errors.json +10 -0
  23. package/src/assets/ethereum/ABI/common/sysio_merkle.sol/sysio_merkle.dbg.json +4 -0
  24. package/src/assets/ethereum/ABI/common/sysio_merkle.sol/sysio_merkle.json +233 -0
  25. package/src/assets/ethereum/ABI/common/sysio_name.sol/sysio_name.dbg.json +4 -0
  26. package/src/assets/ethereum/ABI/common/sysio_name.sol/sysio_name.json +49 -0
  27. package/src/assets/ethereum/ABI/common/sysio_pubkey.sol/sysio_pubkey.dbg.json +4 -0
  28. package/src/assets/ethereum/ABI/common/sysio_pubkey.sol/sysio_pubkey.json +64 -0
  29. package/src/assets/ethereum/ABI/common/sysio_read.sol/sysio_read.dbg.json +4 -0
  30. package/src/assets/ethereum/ABI/common/sysio_read.sol/sysio_read.json +1458 -0
  31. package/src/assets/ethereum/ABI/common/sysio_tester.sol/SysioTester.dbg.json +4 -0
  32. package/src/assets/ethereum/ABI/common/sysio_tester.sol/SysioTester.json +1532 -0
  33. package/src/assets/ethereum/ABI/common/sysio_verify.sol/sysio_verify.dbg.json +4 -0
  34. package/src/assets/ethereum/ABI/common/sysio_verify.sol/sysio_verify.json +1525 -0
  35. package/src/assets/ethereum/ABI/common/sysio_write.sol/sysio_write.dbg.json +4 -0
  36. package/src/assets/ethereum/ABI/common/sysio_write.sol/sysio_write.json +1076 -0
  37. package/src/assets/ethereum/ABI/liqEth/BeaconState.sol/BeaconState.dbg.json +1 -1
  38. package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.dbg.json +1 -1
  39. package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json +28 -2
  40. package/src/assets/ethereum/ABI/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +1 -1
  41. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +1 -1
  42. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +1 -1
  43. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +1 -1
  44. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +1 -1
  45. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +1 -1
  46. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +1 -1
  47. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +1 -1
  48. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +1 -1
  49. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +1 -1
  50. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +1 -1
  51. package/src/assets/ethereum/ABI/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +1 -1
  52. package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +1 -1
  53. package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +1 -1
  54. package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.dbg.json +1 -1
  55. package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json +2 -2
  56. package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.dbg.json +1 -1
  57. package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json +2 -15
  58. package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.dbg.json +1 -1
  59. package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.dbg.json +1 -1
  60. package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json +6 -25
  61. package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +1 -1
  62. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +1 -1
  63. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.json +2 -2
  64. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +1 -1
  65. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.json +6 -25
  66. package/src/assets/ethereum/ABI/outpost/BAR.sol/BAR.dbg.json +1 -1
  67. package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.dbg.json +1 -1
  68. package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.json +26 -26
  69. package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +1 -1
  70. package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +1 -1
  71. package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.dbg.json +1 -1
  72. package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPP.dbg.json +1 -1
  73. package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +1 -1
  74. package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPInbound.dbg.json +1 -1
  75. package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +1 -1
  76. package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPSender.dbg.json +1 -1
  77. package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/OPPCommon.dbg.json +1 -1
  78. package/src/assets/ethereum/ABI/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +1 -1
  79. package/src/assets/ethereum/ABI/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +1 -1
  80. package/src/assets/ethereum/ABI/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +1 -1
  81. package/src/assets/ethereum/ABI/outpost/OPPErrors.sol/OPPErrors.dbg.json +1 -1
  82. package/src/assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.dbg.json +1 -1
  83. package/src/assets/ethereum/ABI/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +1 -1
  84. package/src/assets/ethereum/ABI/outpost/OPPSender.sol/OPPSender.dbg.json +1 -1
  85. package/src/assets/ethereum/ABI/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +1 -1
  86. package/src/assets/ethereum/ABI/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +1 -1
  87. package/src/assets/ethereum/ABI/outpost/OutpostManager.sol/OutpostManager.dbg.json +1 -1
  88. package/src/assets/ethereum/ABI/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +1 -1
  89. package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +1 -1
  90. package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +1 -1
  91. package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +1 -1
  92. package/src/assets/ethereum/ABI/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +1 -1
  93. package/src/assets/ethereum/ABI/outpost/Pool.sol/Pool.dbg.json +1 -1
  94. package/src/assets/ethereum/ABI/outpost/Pool.sol/Pool.json +2 -2
  95. package/src/assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.dbg.json +1 -1
  96. package/src/assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.json +9 -9
  97. package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +1 -1
  98. package/src/assets/ethereum/ABI/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +1 -1
  99. package/src/assets/ethereum/ABI/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +1 -1
  100. package/src/assets/ethereum/ABI/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +1 -1
  101. package/src/assets/ethereum/ABI/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +1 -1
  102. package/src/assets/solana/idl/liqsol_core.json +132 -182
  103. package/src/assets/solana/types/liqsol_core.ts +132 -182
  104. package/src/networks/ethereum/clients/convert.client.ts +2 -2
  105. package/src/networks/ethereum/clients/pretoken.client.ts +8 -9
  106. package/src/networks/ethereum/clients/stake.client.ts +4 -7
  107. package/src/networks/ethereum/contract.ts +112 -59
  108. package/src/networks/ethereum/ethereum.ts +144 -56
  109. package/src/networks/ethereum/types.ts +26 -17
  110. package/src/networks/ethereum/utils.ts +8 -8
  111. package/src/networks/solana/clients/deposit.client.ts +25 -7
  112. package/src/networks/solana/clients/distribution.client.ts +119 -1
  113. package/src/networks/solana/clients/outpost.client.ts +34 -28
  114. package/src/networks/solana/constants.ts +0 -3
  115. package/src/networks/solana/solana.ts +145 -12
  116. package/src/networks/solana/types.ts +132 -9
  117. package/src/networks/solana/utils.ts +14 -7
  118. package/src/types.ts +19 -11
  119. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.dbg.json +0 -4
  120. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.json +0 -10
  121. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.dbg.json +0 -4
  122. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.json +0 -10
  123. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZExtras.dbg.json +0 -4
  124. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZExtras.json +0 -10
  125. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZVec48.dbg.json +0 -4
  126. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZVec48.json +0 -10
  127. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.dbg.json +0 -4
  128. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json +0 -291
  129. package/src/staker/types.ts +0 -62
@@ -3,12 +3,16 @@
3
3
  *
4
4
  * Provides a unified service for interacting with Ethereum smart contracts using ethers.js.
5
5
  */
6
+
7
+ // LiqETH Artifacts
6
8
  import AccountingArtifact from '../../assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json';
7
9
  import DepositManagerArtifact from '../../assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json';
8
10
  import LiqEthArtifact from '../../assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json';
9
11
  import StakingModuleArtifact from '../../assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json';
10
12
  import WithdrawalQueueArtifact from '../../assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.json';
11
13
  import WithdrawalVaultArtifact from '../../assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.json';
14
+ import BeaconStateArtifact from '../../assets/ethereum/ABI/liqEth/BeaconState.sol/BeaconState.json';
15
+ import YieldOracleArtifact from '../../assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json';
12
16
 
13
17
  // Outpost Artifacts
14
18
  import DepositorArtifact from '../../assets/ethereum/ABI/outpost/Depositor.sol/Depositor.json';
@@ -22,7 +26,15 @@ import PretokenArtifact from '../../assets/ethereum/ABI/outpost/Pretoken.sol/Pre
22
26
  import AggregatorArtifact from '../../assets/ethereum/ABI/outpost/Aggregator.sol/Aggregator.json';
23
27
  import EthUsdPriceConsumerArtifact from '../../assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json';
24
28
  import PoolArtifact from '../../assets/ethereum/ABI/outpost/Pool.sol/Pool.json';
29
+ import OutpostManagerAuthorityArtifact from '../../assets/ethereum/ABI/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json';
30
+
31
+ // Common Artifacts
32
+ import IodataArtifact from '../../assets/ethereum/ABI/common/iodata.sol/iodata.json';
33
+ import Base58Artifact from '../../assets/ethereum/ABI/common/Base58.sol/Base58.json';
34
+ import sysio_merkleArtifact from '../../assets/ethereum/ABI/common/sysio_merkle.sol/sysio_merkle.json';
35
+ import sysio_writeArtifact from '../../assets/ethereum/ABI/common/sysio_write.sol/sysio_write.json';
25
36
 
37
+ // ERC Token Artifacts
26
38
  import ERC20Artifact from '../../assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.json';
27
39
  import ERC721Artifact from '../../assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.json';
28
40
  import ERC1155Artifact from '../../assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.json';
@@ -43,25 +55,33 @@ export const ERC1155Abi = ERC1155Artifact.abi;
43
55
  // Make sure ContractName in ./types includes all of these keys.
44
56
  export const ADDRESSES: AddressBook = {
45
57
  // LiqETH contracts
46
- Accounting: "0xd333A03a44D5d602A98c1B7bcd7ED1f042DD0dEd",
47
- DepositManager: "0x601eaA31e8d33D8725786f1733f4cE6cCEf740D4",
48
- LiqEth: "0x08252e1Dcbaa86A2887927b02536CD3E67a802c8", // AKA LiqEthToken
49
- StakingModule: "0x7Aac2fCfc83d7F2f15eA53a10C1677CA377AFcF4",
50
- WithdrawalQueue: "0x951E413FC81a2CE133078ABE8B88677F5296abE7",
51
- WithdrawalVault: "0x0D2bf834DD560839e986d42D06DeE268A17c2d13",
58
+ LiqEthAuthority: "0x9686E04F30Fa93496B7d7fE0FBc2e4e0aD52891E",
59
+ BeaconState: "0x207b249d7a83F6E9FCa04a1CD9b484D4f4f9aD2D",
60
+ WithdrawalQueue: "0x9a575c7Acce9e616cD07A0BDb2D28866027b75Ae",
61
+ LiqEthToken: "0x5f7192fa756304b255F6F9C1123426Db6A1Db748",
62
+ Accounting: "0xBAbAd5219f022B29282b904ceEaeBB7ab1b069fC",
63
+ DepositManager: "0x2e1986508472805c1649e4BBB424879B89720741",
64
+ WithdrawalVault: "0xC82FAf3Fed135B70A7E797864F504819a98E96c4",
65
+ StakingModule: "0xdd24EffAa4B42f3273E2b44995639119c08daBea",
66
+ YieldOracle: "0x56A27E1d10d4aEc7402dC26693fb7c0Eb66eF802",
52
67
 
53
68
  //Outpost contracts
54
- Depositor: "0x69Aa53Ef02F124dB421AeDda509d6912341299Cc",
55
- ReceiptNFT: "0x13588fF41E2f47D047874162B1eD15AaF6818f5a",
56
- OutpostManager: "0x187f4fEDBCAD2f3150120B743b5d568F11dD3452",
57
- BAR: "0x27d4646abF638A13934c94f8bA9AC1Bda39F5dbb",
58
- OPP: "0x79CA2DE915C294593edc16b32CBA8B7866159205",
59
- OPPCommon: "0x8392ea945Cd8C03F5241d4964D20BB5A9c320c71",
60
- OPPInbound: "0xfDA9A2C7e395a9722d9fa506f5d67aba823298dd",
61
- Pretoken: "0xcf6A1209A7A391cc576174204386F4e5462323dC",
62
- EthUsdPriceConsumer: "0x1Ef180FF49313fCB8B5c0470268295d0d24CDE69",
63
- Aggregator: "0xFCfc3ddd4CBd9Ad3b3af3A374B8bdA1b66eE6FFF",
64
- Pool: "0x29DEf0fA009e02d108d9505018EAe0168F233e03",
69
+ OutpostManagerAuthority: "0xAEcd2aa6EeFa4Aa7Cb9368728aA89Ca59Aa9ea59",
70
+ iodata: "0x2c2ab53F6Bc146bd31B459E832Ce0B9Da78712d8",
71
+ Base58: "0x9F188Ec124c9ad9bF6D195650d8360Fd052F585A",
72
+ sysio_merkle: "0x6eDA3C4c34421Cd667800C17fe33E48f5698e004",
73
+ ReceiptNFT: "0xd083051d9bb8353875abCecAB50C6e4FB5e527a8",
74
+ MockAggregator: "0xFCfc3ddd4CBd9Ad3b3af3A374B8bdA1b66eE6FFF",
75
+ Pool: "0xee5F11aC9b104c18d2423f266c5E737fC95ebA92",
76
+ OutpostManager: "0xB1B6ba7FA156652849069aC7ADB281283D235B9f",
77
+ sysio_write: "0xEfA608136d372349C09a7aA57665C09Fb4a620Ca",
78
+ EthUsdPriceConsumer: "0x6337A23b61f98b1526faF2848385Abe9cB4cFF21",
79
+ BAR: "0x9264eAA449da94caF70Fc18522021a94C8DF32Fb",
80
+ OPPCommon: "0x86A8cA16ce521De3EBdd1C541fAf188795b59FD0",
81
+ OPP: "0x79e8395Bb5131FB285aCEE5329BB43E66f50F88C",
82
+ Pretoken: "0x62f98AF2f9C3EF4eF2fA7bc0245BD5a9315E7541",
83
+ OPPInbound: "0xC85f57Ff069711e0b3472De3963bd2fC2FEfF3e2",
84
+ Depositor: "0xb0BACAb6f13dd96281300be13a6346461b2f35F3"
65
85
  };
66
86
 
67
87
  export type Contracts<T extends string = ContractName> = Record<T, ContractConfig>;
@@ -76,76 +96,109 @@ export type ContractConfig = {
76
96
  // -----------------------------------------------------------------------------
77
97
 
78
98
  export const CONTRACTS: Contracts<ContractName> = {
99
+ // LiqETH Contracts
100
+ LiqEthAuthority: {
101
+ address: ADDRESSES.LiqEthAuthority,
102
+ abi: LiqEthArtifact.abi as JsonFragment[],
103
+ },
104
+ BeaconState: {
105
+ address: ADDRESSES.BeaconState,
106
+ abi: BeaconStateArtifact.abi as JsonFragment[]
107
+ },
108
+ WithdrawalQueue: {
109
+ address: ADDRESSES.WithdrawalQueue,
110
+ abi: WithdrawalQueueArtifact.abi as JsonFragment[],
111
+ },
112
+ LiqEthToken: {
113
+ address: ADDRESSES.LiqEthToken,
114
+ abi: LiqEthArtifact.abi as JsonFragment[],
115
+ },
79
116
  Accounting: {
80
117
  address: ADDRESSES.Accounting,
81
118
  abi: AccountingArtifact.abi as JsonFragment[],
82
119
  },
83
- LiqEth: {
84
- address: ADDRESSES.LiqEth,
85
- abi: LiqEthArtifact.abi as JsonFragment[],
86
- },
87
120
  DepositManager: {
88
121
  address: ADDRESSES.DepositManager,
89
122
  abi: DepositManagerArtifact.abi as JsonFragment[],
90
123
  },
124
+ WithdrawalVault: {
125
+ address: ADDRESSES.WithdrawalVault,
126
+ abi: WithdrawalVaultArtifact.abi as JsonFragment[],
127
+ },
91
128
  StakingModule: {
92
129
  address: ADDRESSES.StakingModule,
93
130
  abi: StakingModuleArtifact.abi as JsonFragment[],
94
131
  },
95
- WithdrawalQueue: {
96
- address: ADDRESSES.WithdrawalQueue,
97
- abi: WithdrawalQueueArtifact.abi as JsonFragment[],
98
- },
99
- WithdrawalVault: {
100
- address: ADDRESSES.WithdrawalVault,
101
- abi: WithdrawalVaultArtifact.abi as JsonFragment[],
132
+ YieldOracle: {
133
+ address: ADDRESSES.YieldOracle,
134
+ abi: YieldOracleArtifact.abi as JsonFragment[],
102
135
  },
103
136
 
104
137
  // Outpost Contracts
105
- Depositor: {
106
- address: ADDRESSES.Depositor,
107
- abi: DepositorArtifact.abi as JsonFragment[],
138
+ OutpostManagerAuthority: {
139
+ address: ADDRESSES.OutpostManagerAuthority,
140
+ abi: OutpostManagerAuthorityArtifact.abi as JsonFragment[],
141
+ },
142
+ iodata: {
143
+ address: ADDRESSES.iodata,
144
+ abi: IodataArtifact.abi as JsonFragment[],
145
+ },
146
+ Base58: {
147
+ address: ADDRESSES.Base58,
148
+ abi: Base58Artifact.abi as JsonFragment[],
149
+ },
150
+ sysio_merkle: {
151
+ address: ADDRESSES.sysio_merkle,
152
+ abi: sysio_merkleArtifact.abi as JsonFragment[],
108
153
  },
109
154
  ReceiptNFT: {
110
155
  address: ADDRESSES.ReceiptNFT,
111
156
  abi: ReceiptNFTArtifact.abi as JsonFragment[],
112
157
  },
158
+ MockAggregator: {
159
+ address: ADDRESSES.MockAggregator,
160
+ abi: AggregatorArtifact.abi as JsonFragment[],
161
+ },
162
+ Pool: {
163
+ address: ADDRESSES.Pool,
164
+ abi: PoolArtifact.abi as JsonFragment[],
165
+ },
113
166
  OutpostManager: {
114
167
  address: ADDRESSES.OutpostManager,
115
168
  abi: OutpostManagerArtifact.abi as JsonFragment[],
116
169
  },
170
+ sysio_write: {
171
+ address: ADDRESSES.sysio_write,
172
+ abi: sysio_writeArtifact.abi as JsonFragment[],
173
+ },
174
+ EthUsdPriceConsumer: {
175
+ address: ADDRESSES.EthUsdPriceConsumer,
176
+ abi: EthUsdPriceConsumerArtifact.abi as JsonFragment[],
177
+ },
117
178
  BAR: {
118
179
  address: ADDRESSES.BAR,
119
180
  abi: BARArtifact.abi as JsonFragment[],
120
181
  },
121
- OPP: {
122
- address: ADDRESSES.OPP,
123
- abi: OPPArtifact.abi as JsonFragment[],
124
- },
125
182
  OPPCommon: {
126
183
  address: ADDRESSES.OPPCommon,
127
184
  abi: OPPCommonArtifact.abi as JsonFragment[],
128
185
  },
129
- OPPInbound: {
130
- address: ADDRESSES.OPPInbound,
131
- abi: OPPInboundArtifact.abi as JsonFragment[],
186
+ OPP: {
187
+ address: ADDRESSES.OPP,
188
+ abi: OPPArtifact.abi as JsonFragment[],
132
189
  },
133
190
  Pretoken: {
134
191
  address: ADDRESSES.Pretoken,
135
192
  abi: PretokenArtifact.abi as JsonFragment[],
136
193
  },
137
- Aggregator: {
138
- address: ADDRESSES.Aggregator,
139
- abi: AggregatorArtifact.abi as JsonFragment[],
194
+ OPPInbound: {
195
+ address: ADDRESSES.OPPInbound,
196
+ abi: OPPInboundArtifact.abi as JsonFragment[],
140
197
  },
141
- EthUsdPriceConsumer: {
142
- address: ADDRESSES.EthUsdPriceConsumer,
143
- abi: EthUsdPriceConsumerArtifact.abi as JsonFragment[],
198
+ Depositor: {
199
+ address: ADDRESSES.Depositor,
200
+ abi: DepositorArtifact.abi as JsonFragment[],
144
201
  },
145
- Pool: {
146
- address: ADDRESSES.Pool,
147
- abi: PoolArtifact.abi as JsonFragment[],
148
- }
149
202
  };
150
203
 
151
204
  export interface ContractOptions {
@@ -228,17 +281,17 @@ export class EthereumContractService {
228
281
  ERC721Artifact,
229
282
  ERC1155Artifact,
230
283
 
231
- // liqETH suite
232
- AccountingArtifact,
233
- DepositManagerArtifact,
234
- LiqEthArtifact,
235
- // LiqEthBurnArtifact,
236
- // LiqEthMintArtifact,
237
- // RewardsERC20Artifact,
238
- StakingModuleArtifact,
239
- // ValidatorBalanceArtifact,
240
- WithdrawalQueueArtifact,
241
- WithdrawalVaultArtifact,
284
+ // // liqETH suite
285
+ // AccountingArtifact,
286
+ // DepositManagerArtifact,
287
+ // LiqEthArtifact,
288
+ // // LiqEthBurnArtifact,
289
+ // // LiqEthMintArtifact,
290
+ // // RewardsERC20Artifact,
291
+ // StakingModuleArtifact,
292
+ // // ValidatorBalanceArtifact,
293
+ // WithdrawalQueueArtifact,
294
+ // WithdrawalVaultArtifact,
242
295
  // YieldArtifact,
243
296
  ];
244
297
 
@@ -16,6 +16,8 @@ import { PretokenClient } from './clients/pretoken.client';
16
16
  import { OPPClient } from './clients/opp.client';
17
17
  import { ReceiptClient } from './clients/receipt.client';
18
18
 
19
+ export const INITIAL_TRANCHE_SUPPLY = 35000;
20
+
19
21
  export class EthereumStakingClient implements IStakingClient {
20
22
  private readonly provider: ethers.providers.Web3Provider | ethers.providers.JsonRpcProvider;
21
23
  public readonly pubKey?: WirePubKey;
@@ -154,8 +156,8 @@ export class EthereumStakingClient implements IStakingClient {
154
156
  * actual = liqETH token balance (ERC-20)
155
157
  * tracked = liqETH tracked balance (protocol/accounting view)
156
158
  */
157
- async getPortfolio(): Promise<Portfolio> {
158
- this.ensureUser();
159
+ async getPortfolio(): Promise<Portfolio | null> {
160
+ if (!this.signer) return Promise.resolve(null);
159
161
 
160
162
  const walletAddress = await this.signer!.getAddress();
161
163
 
@@ -165,7 +167,7 @@ export class EthereumStakingClient implements IStakingClient {
165
167
  const nativeSymbol = this.network?.nativeCurrency?.symbol ?? 'ETH';
166
168
 
167
169
  // 2) liqETH ERC-20 balance (actual)
168
- const liqBalance: ethers.BigNumber = await this.contract.LiqEth.balanceOf(walletAddress);
170
+ const liqBalance: ethers.BigNumber = await this.contract.LiqEthToken.balanceOf(walletAddress);
169
171
  const liqSymbol = 'Liq' + (this.network?.nativeCurrency?.symbol ?? 'ETH');
170
172
 
171
173
  // 3) staked liqEth ERC-20 balance (calculate from receipts)
@@ -199,7 +201,7 @@ export class EthereumStakingClient implements IStakingClient {
199
201
  currentIndex = BigInt(indexBn.toString());
200
202
  totalShares = BigInt(totalSharesBn.toString());
201
203
  userShares = BigInt(userSharesBn.toString());
202
- } catch {}
204
+ } catch { }
203
205
 
204
206
  // sharesToTokens(userShares, currentIndex) = userShares * currentIndex / indexScale
205
207
  let estimatedClaim = BigInt(0);
@@ -287,10 +289,18 @@ export class EthereumStakingClient implements IStakingClient {
287
289
  // READ-ONLY Public Methods
288
290
  // ---------------------------------------------------------------------
289
291
 
290
- // Estimated total APY for staking yeild
292
+ // Protocol-wide ETH staking APY in percent, e.g. 3.0 => "3.00%"
291
293
  async getSystemAPY(): Promise<number> {
294
+ // NOTE: despite the name, this value is effectively *annual* BPS on-chain.
295
+ // e.g. 300 => 3% APY
292
296
  const annualBpsBn = await this.contract.DepositManager.dailyRateBPS();
293
- return annualBpsBn.toNumber() / 10000; // 0.04 for 4%
297
+ const annualBps = annualBpsBn.toNumber(); // e.g. 300 for 3%
298
+
299
+ // Convert basis points (1/100 of 1%) to percent:
300
+ // 10,000 bps = 100% ⇒ 100 bps = 1% ⇒ divide by 100.
301
+ const apyPercent = annualBps / 100;
302
+
303
+ return apyPercent; // 3 => "3.00%"
294
304
  }
295
305
 
296
306
  // Protocol fee charged for deposit from Native to LIQ
@@ -304,7 +314,7 @@ export class EthereumStakingClient implements IStakingClient {
304
314
  }
305
315
 
306
316
  async getEthStats(): Promise<any> {
307
- let withdrawDelay = await this.contract.DepositManager.withdrawDelay();
317
+ let withdrawDelay = await this.contract.WithdrawalQueue.withdrawDelay();
308
318
  let minDeposit = await this.contract.DepositManager.minDeposit();
309
319
  let rewardCooldown = await this.contract.DepositManager.rewardCooldown();
310
320
 
@@ -332,55 +342,133 @@ export class EthereumStakingClient implements IStakingClient {
332
342
  } = options ?? {};
333
343
 
334
344
 
335
- const blockNumber = await this.provider.getBlockNumber();
336
- const blockTag = { blockTag: blockNumber };
337
-
338
- // Fetch all required contract data
339
- const [totalSharesBn, indexBn, trancheNumberBn, trancheSupplyBn, tranchePriceWadBn, totalSupplyBn, supplyGrowthBps, priceGrowthBps, minPriceUsd, maxPriceUsd] = await Promise.all([
340
- this.contract.Depositor.totalShares(blockTag),
341
- this.contract.Depositor.index(blockTag),
342
- this.contract.Pretoken.trancheNumber(blockTag),
343
- this.contract.Pretoken.trancheSupply(blockTag),
344
- this.contract.Pretoken.tranchePriceUsd(blockTag),
345
- this.contract.Pretoken.totalSupply(blockTag),
346
- this.contract.Pretoken.supplyGrowthBps(blockTag),
347
- this.contract.Pretoken.priceGrowthBps(blockTag),
348
- this.contract.EthUsdPriceConsumer.MIN_PRICE(),
349
- this.contract.EthUsdPriceConsumer.MAX_PRICE(),
350
- ]);
351
-
352
-
353
- const totalTrancheSupply = BigInt(totalSupplyBn.toString()) / BigInt(1e10);
354
- const currentTrancheSupply = BigInt(trancheSupplyBn.toString()) / BigInt(1e10);
355
-
356
-
357
- // fetch price and timestamp from aggregator
358
- const [roundId, answer, startedAt, updatedAt, answeredInRound] = await this.contract.Aggregator.latestRoundData();
359
- let ethPriceUsd: bigint = BigInt(answer.toString());
360
- let nativePriceTimestamp: number = Number(updatedAt);
361
-
362
- // ! Placeholder from hoodi deployment - don't think this can be fetched dynamically
363
- const initialTrancheSupply = BigInt(60000) * BigInt(1e8);
364
-
365
- return buildEthereumTrancheSnapshot({
366
- chainID,
367
- totalSharesBn,
368
- indexBn,
369
- trancheNumberBn,
370
- currentTrancheSupply,
371
- tranchePriceWadBn,
372
- totalTrancheSupply,
373
- initialTrancheSupply,
374
- supplyGrowthBps,
375
- priceGrowthBps,
376
- minPriceUsd,
377
- maxPriceUsd,
378
-
379
- ethPriceUsd,
380
- nativePriceTimestamp,
381
- ladderWindowBefore: windowBefore,
382
- ladderWindowAfter: windowAfter,
345
+ try {
346
+
347
+ const blockNumber = await this.provider.getBlockNumber();
348
+ const blockTag = { blockTag: blockNumber };
349
+
350
+
351
+ // Fetch all required contract data
352
+ const [totalSharesBn, indexBn, trancheNumberBn, trancheSupplyBn, tranchePriceWadBn, totalSupplyBn, supplyGrowthBps, priceGrowthCents, minPriceUsd, maxPriceUsd] = await Promise.all([
353
+ this.contract.Depositor.totalShares(blockTag),
354
+ this.contract.Depositor.index(blockTag),
355
+ this.contract.Pretoken.trancheNumber(blockTag),
356
+ this.contract.Pretoken.trancheSupply(blockTag),
357
+ this.contract.Pretoken.tranchePriceUsd(blockTag),
358
+ this.contract.Pretoken.totalSupply(blockTag),
359
+ this.contract.Pretoken.supplyGrowthBps(blockTag),
360
+ this.contract.Pretoken.priceIncrementUsd(blockTag),
361
+ this.contract.EthUsdPriceConsumer.MIN_PRICE(),
362
+ this.contract.EthUsdPriceConsumer.MAX_PRICE(),
363
+ ]);
364
+
365
+
366
+ const totalTrancheSupply = BigInt(totalSupplyBn.toString()) / BigInt(1e10);
367
+ const currentTrancheSupply = BigInt(trancheSupplyBn.toString()) / BigInt(1e10);
368
+
369
+
370
+ // fetch price and timestamp from aggregator
371
+ const [roundId, answer, startedAt, updatedAt, answeredInRound] = await this.contract.MockAggregator.latestRoundData();
372
+ let ethPriceUsd: bigint = BigInt(answer.toString());
373
+ let nativePriceTimestamp: number = Number(updatedAt);
374
+
375
+ const initialTrancheSupply = BigInt(INITIAL_TRANCHE_SUPPLY) * BigInt(1e8);
376
+
377
+ return buildEthereumTrancheSnapshot({
378
+ chainID,
379
+ totalSharesBn,
380
+ indexBn,
381
+ trancheNumberBn,
382
+ currentTrancheSupply,
383
+ tranchePriceWadBn,
384
+ totalTrancheSupply,
385
+ initialTrancheSupply,
386
+ supplyGrowthBps,
387
+ priceGrowthCents,
388
+ minPriceUsd,
389
+ maxPriceUsd,
390
+
391
+ ethPriceUsd,
392
+ nativePriceTimestamp,
393
+ ladderWindowBefore: windowBefore,
394
+ ladderWindowAfter: windowAfter,
395
+ });
396
+ }
397
+ catch (err: any) {
398
+ console.log(err);
399
+
400
+ throw new Error(`Error fetching Ethereum tranche snapshot: ${err?.message || err}`);
401
+ }
402
+ }
403
+
404
+ /**
405
+ * Estimate a conservative native ETH buffer (in wei) to leave in the wallet
406
+ * so the user can pay gas for the current deposit and at least one more tx.
407
+ *
408
+ * Typical usage in UI:
409
+ * const buffer = await client.estimateGasBuffer();
410
+ * const maxSpendable = balanceWei > buffer ? balanceWei - buffer : 0n;
411
+ *
412
+ * @param options.txCount How many transactions to cover (default 2: deposit + 1 more)
413
+ * @param options.safetyMultiplier Additional safety multiplier on top of txCount (default 1.5x)
414
+ * @param options.minBufferWei Optional override minimum buffer (defaults ~0.002 ETH)
415
+ */
416
+ async estimateGasBuffer(options?: {
417
+ txCount?: number;
418
+ safetyMultiplier?: number;
419
+ minBufferWei?: bigint;
420
+ }): Promise<bigint> {
421
+ this.ensureUser();
422
+
423
+ const walletAddress = await this.signer!.getAddress();
424
+
425
+ // 1) Estimate a baseline gas usage using a simple self-transfer.
426
+ // This is cheap and doesn't depend on your contract ABI at all.
427
+ const baseGas = await this.provider.estimateGas({
428
+ from: walletAddress,
429
+ to: walletAddress,
430
+ value: ethers.constants.Zero,
383
431
  });
432
+
433
+ // 2) Fetch current gas price / max fee per gas.
434
+ const feeData = await this.provider.getFeeData();
435
+ let gasPrice =
436
+ feeData.maxFeePerGas ??
437
+ feeData.gasPrice ??
438
+ ethers.utils.parseUnits('20', 'gwei'); // conservative fallback
439
+
440
+ // 3) How many txs do we want to cover?
441
+ // Default: 2 (deposit + one extra action such as stake or small follow-up).
442
+ const txCount = options?.txCount ?? 2;
443
+
444
+ // We also assume that contract interactions are more expensive than a simple transfer.
445
+ // Use a multiplier (e.g., 5x) on baseGas to approximate a more complex tx.
446
+ const COMPLEX_TX_MULTIPLIER = 5; // tuning knob
447
+ const totalGasUnits = baseGas
448
+ .mul(COMPLEX_TX_MULTIPLIER)
449
+ .mul(txCount);
450
+
451
+ const baseCost = totalGasUnits.mul(gasPrice);
452
+
453
+ // 4) Safety multiplier on top of that (e.g. 1.5x).
454
+ const safetyMultiplier = options?.safetyMultiplier ?? 1.5;
455
+ const safetyScaled = Math.round(safetyMultiplier * 100); // e.g. 150
456
+
457
+ const bufferedCost = baseCost
458
+ .mul(safetyScaled)
459
+ .div(100); // apply safety factor
460
+
461
+ let bufferWei = bufferedCost.toBigInt();
462
+
463
+ // 5) Enforce a minimum floor (e.g. ~0.002 ETH).
464
+ const defaultMinBufferWei = BigInt(2_000_000_000_000_000); // 0.002 ETH
465
+ const minBufferWei = options?.minBufferWei ?? defaultMinBufferWei;
466
+
467
+ if (bufferWei < minBufferWei) {
468
+ bufferWei = minBufferWei;
469
+ }
470
+
471
+ return bufferWei;
384
472
  }
385
473
 
386
474
  // ---------------------------------------------------------------------
@@ -389,7 +477,7 @@ export class EthereumStakingClient implements IStakingClient {
389
477
 
390
478
  // ! This is a temporary measure for Hoodi testnet because there is no aggregator deployed
391
479
  private async updateMockAggregatorPrice() {
392
- const aggregator = this.contract.Aggregator;
480
+ const aggregator = this.contract.MockAggregator;
393
481
 
394
482
  // read latest round & compute age
395
483
  const [roundId, answer, startedAt, updatedAt, answeredInRound] = await aggregator.latestRoundData();
@@ -2,25 +2,34 @@ import { BigNumber, ethers } from 'ethers';
2
2
  import { BalanceView } from '../../types';
3
3
 
4
4
  export const CONTRACT_NAMES = [
5
- 'Accounting',
6
- 'DepositManager',
7
- 'LiqEth',
8
- 'StakingModule',
9
- 'WithdrawalQueue',
10
- 'WithdrawalVault',
5
+ // LiqETH contracts
6
+ "LiqEthAuthority",
7
+ "BeaconState",
8
+ "WithdrawalQueue",
9
+ "LiqEthToken",
10
+ "Accounting",
11
+ "DepositManager",
12
+ "WithdrawalVault",
13
+ "StakingModule",
14
+ "YieldOracle",
11
15
 
12
16
  //Outpost contracts
13
- 'Depositor',
14
- 'ReceiptNFT',
15
- 'OutpostManager',
16
- 'BAR',
17
- 'OPP',
18
- 'OPPCommon',
19
- 'OPPInbound',
20
- 'Pretoken',
21
- 'Aggregator',
22
- 'EthUsdPriceConsumer',
23
- 'Pool',
17
+ "OutpostManagerAuthority",
18
+ "iodata",
19
+ "Base58",
20
+ "sysio_merkle",
21
+ "ReceiptNFT",
22
+ "MockAggregator",
23
+ "Pool",
24
+ "OutpostManager",
25
+ "sysio_write",
26
+ "EthUsdPriceConsumer",
27
+ "BAR",
28
+ "OPPCommon",
29
+ "OPP",
30
+ "Pretoken",
31
+ "OPPInbound",
32
+ "Depositor",
24
33
 
25
34
  ] as const;
26
35
 
@@ -157,7 +157,7 @@ export function buildEthereumTrancheLadder(options: {
157
157
  currentTrancheSupply: bigint;
158
158
  currentPriceUsd: bigint;
159
159
  supplyGrowthBps: number;
160
- priceGrowthBps: number;
160
+ priceGrowthCents: number;
161
161
  windowBefore?: number;
162
162
  windowAfter?: number;
163
163
  }): TrancheLadderItem[] {
@@ -167,7 +167,7 @@ export function buildEthereumTrancheLadder(options: {
167
167
  currentTrancheSupply,
168
168
  currentPriceUsd,
169
169
  supplyGrowthBps,
170
- priceGrowthBps,
170
+ priceGrowthCents,
171
171
  windowBefore = 5,
172
172
  windowAfter = 5,
173
173
  } = options;
@@ -190,7 +190,7 @@ export function buildEthereumTrancheLadder(options: {
190
190
  const prevCap = capacity.get(id - 1)!;
191
191
  const prevPrice = price.get(id - 1)!;
192
192
  capacity.set(id, growOnce(prevCap, supplyGrowthBps));
193
- price.set(id, growOnce(prevPrice, priceGrowthBps));
193
+ price.set(id, growOnce(prevPrice, priceGrowthCents));
194
194
  }
195
195
 
196
196
  // Backward (past tranches)
@@ -198,7 +198,7 @@ export function buildEthereumTrancheLadder(options: {
198
198
  const nextCap = capacity.get(id + 1)!;
199
199
  const nextPrice = price.get(id + 1)!;
200
200
  capacity.set(id, shrinkOnce(nextCap, supplyGrowthBps));
201
- price.set(id, shrinkOnce(nextPrice, priceGrowthBps));
201
+ price.set(id, shrinkOnce(nextPrice, priceGrowthCents));
202
202
  }
203
203
 
204
204
  const ladder: TrancheLadderItem[] = [];
@@ -240,7 +240,7 @@ export async function buildEthereumTrancheSnapshot(options: {
240
240
  totalTrancheSupply;
241
241
  initialTrancheSupply;
242
242
  supplyGrowthBps;
243
- priceGrowthBps;
243
+ priceGrowthCents;
244
244
  minPriceUsd;
245
245
  maxPriceUsd;
246
246
 
@@ -264,7 +264,7 @@ export async function buildEthereumTrancheSnapshot(options: {
264
264
  totalTrancheSupply,
265
265
  initialTrancheSupply,
266
266
  supplyGrowthBps,
267
- priceGrowthBps,
267
+ priceGrowthCents,
268
268
  minPriceUsd,
269
269
  maxPriceUsd,
270
270
  } = options;
@@ -284,7 +284,7 @@ export async function buildEthereumTrancheSnapshot(options: {
284
284
  currentTrancheSupply,
285
285
  currentPriceUsd,
286
286
  supplyGrowthBps,
287
- priceGrowthBps,
287
+ priceGrowthCents,
288
288
  windowBefore: ladderWindowBefore,
289
289
  windowAfter: ladderWindowAfter,
290
290
  });
@@ -297,7 +297,7 @@ export async function buildEthereumTrancheSnapshot(options: {
297
297
  currentTranche,
298
298
  currentPriceUsd,
299
299
  supplyGrowthBps,
300
- priceGrowthBps,
300
+ priceGrowthCents,
301
301
  currentTrancheSupply,
302
302
  initialTrancheSupply,
303
303
  totalPretokensSold: totalTrancheSupply,