@wireio/stake 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/lib/stake.browser.js +18509 -11887
  2. package/lib/stake.browser.js.map +1 -1
  3. package/lib/stake.d.ts +899 -140
  4. package/lib/stake.js +18524 -11890
  5. package/lib/stake.js.map +1 -1
  6. package/lib/stake.m.js +18509 -11887
  7. package/lib/stake.m.js.map +1 -1
  8. package/package.json +2 -2
  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 +760 -150
  103. package/src/assets/solana/idl/liqsol_token.json +1 -1
  104. package/src/assets/solana/idl/transfer_hook.json +6 -1
  105. package/src/assets/solana/idl/validator_leaderboard.json +4 -1
  106. package/src/assets/solana/types/liqsol_core.ts +760 -150
  107. package/src/assets/solana/types/liqsol_token.ts +1 -1
  108. package/src/assets/solana/types/transfer_hook.ts +6 -1
  109. package/src/assets/solana/types/validator_leaderboard.ts +4 -1
  110. package/src/networks/ethereum/clients/convert.client.ts +2 -2
  111. package/src/networks/ethereum/clients/pretoken.client.ts +6 -4
  112. package/src/networks/ethereum/clients/stake.client.ts +2 -2
  113. package/src/networks/ethereum/contract.ts +102 -49
  114. package/src/networks/ethereum/ethereum.ts +117 -58
  115. package/src/networks/ethereum/types.ts +26 -17
  116. package/src/networks/ethereum/utils.ts +8 -8
  117. package/src/networks/solana/clients/deposit.client.ts +5 -4
  118. package/src/networks/solana/clients/distribution.client.ts +36 -1
  119. package/src/networks/solana/constants.ts +14 -0
  120. package/src/networks/solana/solana.ts +148 -17
  121. package/src/networks/solana/types.ts +129 -0
  122. package/src/types.ts +21 -11
  123. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.dbg.json +0 -4
  124. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.json +0 -10
  125. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.dbg.json +0 -4
  126. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.json +0 -10
  127. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZExtras.dbg.json +0 -4
  128. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZExtras.json +0 -10
  129. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZVec48.dbg.json +0 -4
  130. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZVec48.json +0 -10
  131. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.dbg.json +0 -4
  132. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json +0 -291
  133. package/src/assets/ethereum/ABI/outpost/Aggregator.sol/Aggregator.json +0 -82
@@ -5,7 +5,7 @@
5
5
  * IDL can be found at `target/idl/liqsol_token.json`.
6
6
  */
7
7
  export type LiqsolToken = {
8
- "address": "6hiJ8PrSyYLr7H9MA9VYh9fvGoHxZ2TXdDAMzjeUVSXZ",
8
+ "address": "5MRFSLCkXPEzfR6gkcZCVttq9g83mMUHyTZ85Z3TSpvU",
9
9
  "metadata": {
10
10
  "name": "liqsolToken",
11
11
  "version": "0.1.0",
@@ -5,7 +5,7 @@
5
5
  * IDL can be found at `target/idl/transfer_hook.json`.
6
6
  */
7
7
  export type TransferHook = {
8
- "address": "EtqCLddkPNGjkgiH9rVUmK3M5X2FKFprQvgscBJ8g6hX",
8
+ "address": "HbBpH9opFW9gcYVanHLweKuHhWQ8P3Kcc1mbpAx1vojz",
9
9
  "metadata": {
10
10
  "name": "transferHook",
11
11
  "version": "0.1.0",
@@ -129,6 +129,11 @@ export type TransferHook = {
129
129
  {
130
130
  "code": 6002,
131
131
  "name": "tlvAccountResolutionError"
132
+ },
133
+ {
134
+ "code": 6003,
135
+ "name": "cannotTransferToBucket",
136
+ "msg": "Cannot transfer liqSOL directly to bucket - only protocol minting is allowed"
132
137
  }
133
138
  ],
134
139
  "types": [
@@ -5,7 +5,7 @@
5
5
  * IDL can be found at `target/idl/validator_leaderboard.json`.
6
6
  */
7
7
  export type ValidatorLeaderboard = {
8
- "address": "H6CWj2PgxCE9Z5dPi9nMrR2VxT1C4DQcqR1QjmLeon47",
8
+ "address": "5v7mWL1735qp2Th9B5WNf7spGynR5ZaxwyCYoQw13DP2",
9
9
  "metadata": {
10
10
  "name": "validatorLeaderboard",
11
11
  "version": "0.1.0",
@@ -124,6 +124,9 @@ export type ValidatorLeaderboard = {
124
124
  },
125
125
  {
126
126
  "name": "systemProgram"
127
+ },
128
+ {
129
+ "name": "clock"
127
130
  }
128
131
  ],
129
132
  "args": [
@@ -86,7 +86,7 @@ export class ConvertClient {
86
86
  public async performWithdraw(signerAddress: string, amountWei: BigNumber): Promise<any> {
87
87
  let tx, receipt;
88
88
  try {
89
- tx = await this.contract.LiqEth.safeBurn(signerAddress, amountWei);
89
+ tx = await this.contract.LiqEthToken.safeBurn(signerAddress, amountWei);
90
90
  receipt = await tx.wait(1);
91
91
  } catch (err: any) {
92
92
  let errorObj = formatContractErrors(err);
@@ -129,7 +129,7 @@ export class ConvertClient {
129
129
  name: await liqEth.name(),
130
130
  version: '1',
131
131
  chainId,
132
- verifyingContract: this.contract.LiqEth.address,
132
+ verifyingContract: this.contract.LiqEthToken.address,
133
133
  } as any;
134
134
 
135
135
  const types = {
@@ -19,7 +19,7 @@ export class PretokenClient {
19
19
  */
20
20
  async purchasePretokensWithLiqETH(amountLiq: bigint, buyer: string): Promise<any> {
21
21
 
22
- const bal = await this.contract.LiqEth.balanceOf(buyer);
22
+ const bal = await this.contract.LiqEthToken.balanceOf(buyer);
23
23
  const paused = await this.contract.Depositor.paused();
24
24
  if(paused) {
25
25
  throw new Error("Error - Depositor is in a paused state");
@@ -32,11 +32,11 @@ export class PretokenClient {
32
32
 
33
33
  //check that the contract has allowance for the token
34
34
  const depositorAddr = this.contract.Depositor.address;
35
- const allowance = await this.contract.LiqEth.allowance(buyer, depositorAddr);
35
+ const allowance = await this.contract.LiqEthToken.allowance(buyer, depositorAddr);
36
36
 
37
37
  // if allowance is less than the requested stake amount, request permission to spend LiqEth
38
38
  if (allowance.lt(amountLiq)) {
39
- const liqWrite = this.contractService.getWrite('LiqEth');
39
+ const liqWrite = this.contractService.getWrite('LiqEthToken');
40
40
 
41
41
  // currently requested unlimited amount - potentially change to only request up to the current amount?
42
42
  const approveAmount = ethers.constants.MaxUint256;
@@ -47,7 +47,7 @@ export class PretokenClient {
47
47
  await approveTx.wait(1);
48
48
 
49
49
  // re-read allowance to ensure approval succeeded
50
- const newAllowance = await this.contract.LiqEth.allowance(buyer, depositorAddr);
50
+ const newAllowance = await this.contract.LiqEthToken.allowance(buyer, depositorAddr);
51
51
  if (newAllowance.lt(amountLiq)) {
52
52
  throw new Error('Approval failed or allowance still insufficient after approve');
53
53
  }
@@ -58,6 +58,8 @@ export class PretokenClient {
58
58
  const amountLiqBN = BigNumber.from(amountLiq)
59
59
  await this.contract.Depositor.callStatic.purchasePretokensWithLiqETH(amountLiqBN, buyer);
60
60
  } catch (err: any) {
61
+ console.log('err', err);
62
+
61
63
  let errorObj = formatContractErrors(err);
62
64
 
63
65
  // ! TEMP for testing
@@ -36,7 +36,7 @@ export class StakeClient {
36
36
  */
37
37
  async performStake(amountWei: BigNumber, signerAddress: string): Promise<any> {
38
38
  const depositor = this.contract.Depositor.address;
39
- const liqRead = this.contract.LiqEth;
39
+ const liqRead = this.contract.LiqEthToken;
40
40
  const bal = await liqRead.balanceOf(signerAddress);
41
41
  const allowance = await liqRead.allowance(signerAddress, depositor);
42
42
 
@@ -48,7 +48,7 @@ export class StakeClient {
48
48
 
49
49
  // if allowance is less than the requested stake amount, request permission to spend LiqEth
50
50
  if (allowance.lt(amountWei)) {
51
- const liqWrite = this.contractService.getWrite('LiqEth');
51
+ const liqWrite = this.contractService.getWrite('LiqEthToken');
52
52
 
53
53
  // currently requested unlimited amount - potentially change to only request up to the current amount?
54
54
  const approveAmount = ethers.constants.MaxUint256;
@@ -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';
@@ -19,10 +23,18 @@ import OPPArtifact from '../../assets/ethereum/ABI/outpost/OPP.sol/OPP.json';
19
23
  import OPPCommonArtifact from '../../assets/ethereum/ABI/outpost/OPPCommon.sol/OPPCommon.json';
20
24
  import OPPInboundArtifact from '../../assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.json';
21
25
  import PretokenArtifact from '../../assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.json';
22
- import AggregatorArtifact from '../../assets/ethereum/ABI/outpost/Aggregator.sol/Aggregator.json';
26
+ import AggregatorArtifact from '../../assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.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: "0xD721d15Ae1D1bF58DF1B9471198d968A16B8e58D",
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 {
@@ -165,7 +165,7 @@ export class EthereumStakingClient implements IStakingClient {
165
165
  const nativeSymbol = this.network?.nativeCurrency?.symbol ?? 'ETH';
166
166
 
167
167
  // 2) liqETH ERC-20 balance (actual)
168
- const liqBalance: ethers.BigNumber = await this.contract.LiqEth.balanceOf(walletAddress);
168
+ const liqBalance: ethers.BigNumber = await this.contract.LiqEthToken.balanceOf(walletAddress);
169
169
  const liqSymbol = 'Liq' + (this.network?.nativeCurrency?.symbol ?? 'ETH');
170
170
 
171
171
  // 3) staked liqEth ERC-20 balance (calculate from receipts)
@@ -174,10 +174,48 @@ export class EthereumStakingClient implements IStakingClient {
174
174
  for (let r of stakeReceipts) {
175
175
  stakeBalanceBN = stakeBalanceBN.add(BigNumber.from(r.receipt.principal.amount));
176
176
  }
177
+ let stakeSharesBN = BigNumber.from(0);
178
+ for (let r of stakeReceipts) {
179
+ stakeSharesBN = stakeSharesBN.add(BigNumber.from(r.receipt.shares.amount));
180
+ }
177
181
 
178
182
  // 4) WIRE pretoken balance
179
183
  const wireBalance: ethers.BigNumber = await this.contract.Pretoken.balanceOf(walletAddress);
180
184
 
185
+
186
+ // 5) Calculate staking yield
187
+ let currentIndex = BigInt(0);
188
+ let totalShares = BigInt(0);
189
+ let userShares = BigInt(0);
190
+ const indexScale = BigInt(1e27);
191
+ try {
192
+ // These may throw if not implemented on contract
193
+ const [indexBn, totalSharesBn] = await Promise.all([
194
+ this.contract.Depositor.index().catch(() => BigNumber.from(0)),
195
+ this.contract.Depositor.totalShares().catch(() => BigNumber.from(0)),
196
+ ]);
197
+
198
+ const userSharesBn = stakeSharesBN;
199
+ currentIndex = BigInt(indexBn.toString());
200
+ totalShares = BigInt(totalSharesBn.toString());
201
+ userShares = BigInt(userSharesBn.toString());
202
+ } catch {}
203
+
204
+ // sharesToTokens(userShares, currentIndex) = userShares * currentIndex / indexScale
205
+ let estimatedClaim = BigInt(0);
206
+ let estimatedYield = BigInt(0);
207
+
208
+ // started work on estimating the user's personal APY - not necessary at the moment
209
+ // let estimatedAPY: number | null = null;
210
+ // if (userShares > BigInt(0) && currentIndex > BigInt(0)) {
211
+ // estimatedClaim = (userShares * currentIndex) / indexScale;
212
+ // if (estimatedClaim > stakeBalanceBN.toBigInt()) {
213
+ // estimatedYield = estimatedClaim - stakeBalanceBN.toBigInt();
214
+ // }
215
+
216
+ // estimatedAPY = null;
217
+ // }
218
+
181
219
  const portfolio: Portfolio = {
182
220
  native: {
183
221
  amount: nativeBalance.toBigInt(),
@@ -199,6 +237,15 @@ export class EthereumStakingClient implements IStakingClient {
199
237
  decimals: 18,
200
238
  symbol: '$WIRE',
201
239
  },
240
+
241
+ yield: {
242
+ currentIndex,
243
+ indexScale,
244
+ totalShares,
245
+ userShares,
246
+ estimatedClaim,
247
+ estimatedYield,
248
+ },
202
249
  chainID: this.network.chainId
203
250
  }
204
251
  return portfolio;
@@ -241,15 +288,15 @@ export class EthereumStakingClient implements IStakingClient {
241
288
  // ---------------------------------------------------------------------
242
289
 
243
290
  // Estimated total APY for staking yeild
244
- getSystemAPY(): Promise<number> {
245
- // TODO
246
- return Promise.resolve(0);
291
+ async getSystemAPY(): Promise<number> {
292
+ const annualBpsBn = await this.contract.DepositManager.dailyRateBPS();
293
+ return annualBpsBn.toNumber() / 10000; // 0.04 for 4%
247
294
  }
248
295
 
249
296
  // Protocol fee charged for deposit from Native to LIQ
250
- getDepositFee(amount: bigint): Promise<bigint> {
251
- // TODO
252
- return Promise.resolve(BigInt(0));
297
+ async getDepositFee(amountWei: bigint): Promise<bigint> {
298
+ const feeBn: BigNumber = await this.contract.DepositManager.procFee(amountWei);
299
+ return BigInt(feeBn.toString());
253
300
  }
254
301
 
255
302
  async getOPPStatus(): Promise<any> {
@@ -257,7 +304,7 @@ export class EthereumStakingClient implements IStakingClient {
257
304
  }
258
305
 
259
306
  async getEthStats(): Promise<any> {
260
- let withdrawDelay = await this.contract.DepositManager.withdrawDelay();
307
+ let withdrawDelay = await this.contract.WithdrawalQueue.withdrawDelay();
261
308
  let minDeposit = await this.contract.DepositManager.minDeposit();
262
309
  let rewardCooldown = await this.contract.DepositManager.rewardCooldown();
263
310
 
@@ -285,55 +332,67 @@ export class EthereumStakingClient implements IStakingClient {
285
332
  } = options ?? {};
286
333
 
287
334
 
288
- const blockNumber = await this.provider.getBlockNumber();
289
- const blockTag = { blockTag: blockNumber };
290
-
291
- // Fetch all required contract data
292
- const [totalSharesBn, indexBn, trancheNumberBn, trancheSupplyBn, tranchePriceWadBn, totalSupplyBn, supplyGrowthBps, priceGrowthBps, minPriceUsd, maxPriceUsd] = await Promise.all([
293
- this.contract.Depositor.totalShares(blockTag),
294
- this.contract.Depositor.index(blockTag),
295
- this.contract.Pretoken.trancheNumber(blockTag),
296
- this.contract.Pretoken.trancheSupply(blockTag),
297
- this.contract.Pretoken.tranchePriceUsd(blockTag),
298
- this.contract.Pretoken.totalSupply(blockTag),
299
- this.contract.Pretoken.supplyGrowthBps(blockTag),
300
- this.contract.Pretoken.priceGrowthBps(blockTag),
301
- this.contract.EthUsdPriceConsumer.MIN_PRICE(),
302
- this.contract.EthUsdPriceConsumer.MAX_PRICE(),
303
- ]);
304
-
305
-
306
- const totalTrancheSupply = BigInt(totalSupplyBn.toString()) / BigInt(1e10);
307
- const currentTrancheSupply = BigInt(trancheSupplyBn.toString()) / BigInt(1e10);
308
-
309
-
310
- // fetch price and timestamp from aggregator
311
- const [roundId, answer, startedAt, updatedAt, answeredInRound] = await this.contract.Aggregator.latestRoundData();
312
- let ethPriceUsd: bigint = BigInt(answer.toString());
313
- let nativePriceTimestamp: number = Number(updatedAt);
314
-
315
- // ! Placeholder from hoodi deployment - don't think this can be fetched dynamically
316
- const initialTrancheSupply = BigInt(60000) * BigInt(1e8);
317
-
318
- return buildEthereumTrancheSnapshot({
319
- chainID,
320
- totalSharesBn,
321
- indexBn,
322
- trancheNumberBn,
323
- currentTrancheSupply,
324
- tranchePriceWadBn,
325
- totalTrancheSupply,
326
- initialTrancheSupply,
327
- supplyGrowthBps,
328
- priceGrowthBps,
329
- minPriceUsd,
330
- maxPriceUsd,
331
-
332
- ethPriceUsd,
333
- nativePriceTimestamp,
334
- ladderWindowBefore: windowBefore,
335
- ladderWindowAfter: windowAfter,
336
- });
335
+ try {
336
+
337
+ const blockNumber = await this.provider.getBlockNumber();
338
+ const blockTag = { blockTag: blockNumber };
339
+
340
+
341
+ // Fetch all required contract data
342
+ const [totalSharesBn, indexBn, trancheNumberBn, trancheSupplyBn, tranchePriceWadBn, totalSupplyBn, supplyGrowthBps, priceIncrementUsd, minPriceUsd, maxPriceUsd] = await Promise.all([
343
+ this.contract.Depositor.totalShares(blockTag),
344
+ this.contract.Depositor.index(blockTag),
345
+ this.contract.Pretoken.trancheNumber(blockTag),
346
+ this.contract.Pretoken.trancheSupply(blockTag),
347
+ this.contract.Pretoken.tranchePriceUsd(blockTag),
348
+ this.contract.Pretoken.totalSupply(blockTag),
349
+ this.contract.Pretoken.supplyGrowthBps(blockTag),
350
+ this.contract.Pretoken.priceIncrementUsd(blockTag),
351
+ this.contract.EthUsdPriceConsumer.MIN_PRICE(),
352
+ this.contract.EthUsdPriceConsumer.MAX_PRICE(),
353
+ ]);
354
+
355
+
356
+ const totalTrancheSupply = BigInt(totalSupplyBn.toString()) / BigInt(1e10);
357
+ const currentTrancheSupply = BigInt(trancheSupplyBn.toString()) / BigInt(1e10);
358
+
359
+
360
+ // fetch price and timestamp from aggregator
361
+ const [roundId, answer, startedAt, updatedAt, answeredInRound] = await this.contract.MockAggregator.latestRoundData();
362
+ let ethPriceUsd: bigint = BigInt(answer.toString());
363
+ let nativePriceTimestamp: number = Number(updatedAt);
364
+
365
+ // ! Placeholder from hoodi deployment - don't think this can be fetched dynamically
366
+ const initialTrancheSupply = BigInt(70000) * BigInt(1e8);
367
+
368
+ console.log('priceIncrementUsd',priceIncrementUsd);
369
+
370
+
371
+ return buildEthereumTrancheSnapshot({
372
+ chainID,
373
+ totalSharesBn,
374
+ indexBn,
375
+ trancheNumberBn,
376
+ currentTrancheSupply,
377
+ tranchePriceWadBn,
378
+ totalTrancheSupply,
379
+ initialTrancheSupply,
380
+ supplyGrowthBps,
381
+ priceIncrementUsd,
382
+ minPriceUsd,
383
+ maxPriceUsd,
384
+
385
+ ethPriceUsd,
386
+ nativePriceTimestamp,
387
+ ladderWindowBefore: windowBefore,
388
+ ladderWindowAfter: windowAfter,
389
+ });
390
+ }
391
+ catch (err: any) {
392
+ console.log(err);
393
+
394
+ throw new Error(`Error fetching Ethereum tranche snapshot: ${err?.message || err}`);
395
+ }
337
396
  }
338
397
 
339
398
  // ---------------------------------------------------------------------
@@ -342,7 +401,7 @@ export class EthereumStakingClient implements IStakingClient {
342
401
 
343
402
  // ! This is a temporary measure for Hoodi testnet because there is no aggregator deployed
344
403
  private async updateMockAggregatorPrice() {
345
- const aggregator = this.contract.Aggregator;
404
+ const aggregator = this.contract.MockAggregator;
346
405
 
347
406
  // read latest round & compute age
348
407
  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