@wireio/stake 0.2.5 → 0.3.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 (97) hide show
  1. package/lib/stake.browser.js +2461 -2074
  2. package/lib/stake.browser.js.map +1 -1
  3. package/lib/stake.d.ts +29 -55
  4. package/lib/stake.js +2615 -2211
  5. package/lib/stake.js.map +1 -1
  6. package/lib/stake.m.js +2461 -2074
  7. package/lib/stake.m.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/assets/ethereum/ABI/liqEth/BeaconState.sol/BeaconState.dbg.json +4 -0
  10. package/src/assets/ethereum/ABI/liqEth/BeaconState.sol/BeaconState.json +807 -0
  11. package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.dbg.json +1 -1
  12. package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json +184 -346
  13. package/src/assets/ethereum/ABI/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +4 -0
  14. package/src/assets/ethereum/ABI/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +1289 -0
  15. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +1 -1
  16. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +1 -1
  17. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +1 -1
  18. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
  19. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
  20. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +1 -1
  21. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.json +36 -0
  22. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
  23. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +263 -0
  24. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +1 -1
  25. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.json +226 -0
  26. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +1 -1
  27. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +59 -0
  28. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +1 -1
  29. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +14 -12
  30. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +1 -1
  31. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.json +2 -2
  32. package/src/assets/ethereum/ABI/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +4 -0
  33. package/src/assets/ethereum/ABI/liqEth/LiqEthManaged.sol/LiqEthManaged.json +229 -0
  34. package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +4 -0
  35. package/src/assets/ethereum/ABI/liqEth/{RewardsERC20Pausable.sol/RewardsERC20Pausable.json → RewardsERC20.sol/RewardsERC20Upgradeable.json} +140 -78
  36. package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +4 -0
  37. package/src/assets/ethereum/ABI/liqEth/{RewardsERC20.sol/RewardsERC20.json → RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json} +218 -30
  38. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.dbg.json +1 -1
  39. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.json +2 -2
  40. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.dbg.json +1 -1
  41. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.json +2 -2
  42. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZExtras.dbg.json +4 -0
  43. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZExtras.json +10 -0
  44. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZVec48.dbg.json +4 -0
  45. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZVec48.json +10 -0
  46. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.dbg.json +1 -1
  47. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json +121 -55
  48. package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.dbg.json +1 -1
  49. package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json +836 -273
  50. package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.dbg.json +1 -1
  51. package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json +150 -168
  52. package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.dbg.json +1 -1
  53. package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json +301 -186
  54. package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.dbg.json +1 -1
  55. package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json +814 -206
  56. package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +1 -1
  57. package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +244 -198
  58. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +1 -1
  59. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.json +2 -2
  60. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +1 -1
  61. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.json +165 -152
  62. package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.dbg.json +1 -1
  63. package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.json +167 -282
  64. package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +1 -1
  65. package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +1 -1
  66. package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +2 -54
  67. package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.dbg.json +1 -1
  68. package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.json +26 -8
  69. package/src/assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.dbg.json +1 -1
  70. package/src/assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.json +2 -2
  71. package/src/assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.dbg.json +4 -0
  72. package/src/assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.json +1650 -0
  73. package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +1 -1
  74. package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.json +2 -22
  75. package/src/assets/ethereum/ABI/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +4 -0
  76. package/src/assets/ethereum/ABI/outpost/interfaces/IPretoken.sol/IPretoken.json +29 -0
  77. package/src/assets/ethereum/ABI/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +1 -1
  78. package/src/networks/ethereum/clients/deposit.client.ts +11 -7
  79. package/src/networks/ethereum/clients/liq.client.ts +47 -0
  80. package/src/networks/ethereum/clients/pretoken.client.ts +47 -50
  81. package/src/networks/ethereum/contract.ts +24 -51
  82. package/src/networks/ethereum/ethereum.ts +29 -52
  83. package/src/networks/ethereum/types.ts +7 -6
  84. package/src/networks/ethereum/utils.ts +3 -9
  85. package/src/networks/solana/clients/token.client.ts +0 -1
  86. package/src/networks/solana/solana.ts +44 -146
  87. package/src/networks/solana/types.ts +6 -2
  88. package/src/networks/solana/utils.ts +4 -6
  89. package/src/types.ts +6 -34
  90. package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.dbg.json +0 -4
  91. package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20Pausable.dbg.json +0 -4
  92. package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.dbg.json +0 -4
  93. package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.json +0 -10
  94. package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.dbg.json +0 -4
  95. package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.json +0 -10
  96. package/src/assets/ethereum/ABI/outpost/Warrant.sol/Warrant.dbg.json +0 -4
  97. package/src/assets/ethereum/ABI/outpost/Warrant.sol/Warrant.json +0 -1650
@@ -1,9 +1,6 @@
1
1
  import { BigNumber, ethers } from "ethers";
2
2
  import { EthereumContractService } from "../contract";
3
3
  import { formatContractErrors, sendOPPFinalize } from "../utils";
4
- import { PurchaseAsset } from "../../../types";
5
-
6
-
7
4
 
8
5
  export class PretokenClient {
9
6
  private readonly contractService: EthereumContractService;
@@ -17,60 +14,60 @@ export class PretokenClient {
17
14
 
18
15
 
19
16
  /**
20
- * Purchase warrants by sending ETH to the Depositor.purchaseWarrantsWithETH(buyer) payable function.
17
+ * Purchase pretokens by sending ETH to the Depositor.purchasePretokensWithETH(buyer) payable function.
21
18
  * Returns txHash, receipt and parsed PurchasedWithETH event (if present).
22
19
  */
23
- async purchaseWarrantsWithETH(amountWei: BigNumber, buyer: string): Promise<any> {
24
- // attempt a simulation of the purchase call
25
- try {
26
- await this.contract.Depositor.callStatic.purchaseWarrantsWithETH(buyer, { value: amountWei });
27
- } catch (err: any) {
28
- let errorObj = formatContractErrors(err);
29
- throw new Error(errorObj.name ?? errorObj.raw)
30
- }
31
-
32
- // attempt the real purchase call
33
- let tx, receipt;
34
- try {
35
- tx = await this.contract.Depositor.purchaseWarrantsWithETH(buyer, { value: amountWei });
36
- receipt = await tx.wait(1);
37
- } catch (err: any) {
38
- let errorObj = formatContractErrors(err);
39
- throw new Error(errorObj.name ?? errorObj.raw)
40
- }
41
-
42
-
43
- // Attempt to parse PurchasedWithETH event
44
- let purchased: any | undefined;
45
- const ev = receipt.events?.find((e) => e.event === 'PurchasedWithETH' || e.event === 'PurchasedWithETH(address,uint256,uint256,uint256)');
46
-
47
- if (ev && ev.args) {
48
- // event signature: PurchasedWithETH(address indexed user, uint256 ethIn, uint256 shares, uint256 tokenId)
49
- const { user, ethIn, shares, tokenId } = ev.args as any;
50
-
51
- purchased = {
52
- buyer: user,
53
- amount: BigNumber.from(ethIn),
54
- shares: BigNumber.from(shares),
55
- tokenId: BigNumber.from(tokenId),
56
- };
57
- }
58
-
59
- return {
60
- txHash: tx.hash,
61
- receipt,
62
- purchased,
63
- };
64
- }
20
+ // async purchasePretokensWithETH(amountWei: BigNumber, buyer: string): Promise<any> {
21
+ // // attempt a simulation of the purchase call
22
+ // try {
23
+ // await this.contract.Depositor.callStatic.purchasePretokensWithETH(buyer, { value: amountWei });
24
+ // } catch (err: any) {
25
+ // let errorObj = formatContractErrors(err);
26
+ // throw new Error(errorObj.name ?? errorObj.raw)
27
+ // }
28
+
29
+ // // attempt the real purchase call
30
+ // let tx, receipt;
31
+ // try {
32
+ // tx = await this.contract.Depositor.purchasePretokensWithETH(buyer, { value: amountWei });
33
+ // receipt = await tx.wait(1);
34
+ // } catch (err: any) {
35
+ // let errorObj = formatContractErrors(err);
36
+ // throw new Error(errorObj.name ?? errorObj.raw)
37
+ // }
38
+
39
+
40
+ // // Attempt to parse PurchasedWithETH event
41
+ // let purchased: any | undefined;
42
+ // const ev = receipt.events?.find((e) => e.event === 'PurchasedWithETH' || e.event === 'PurchasedWithETH(address,uint256,uint256,uint256)');
43
+
44
+ // if (ev && ev.args) {
45
+ // // event signature: PurchasedWithETH(address indexed user, uint256 ethIn, uint256 shares, uint256 tokenId)
46
+ // const { user, ethIn, shares, tokenId } = ev.args as any;
47
+
48
+ // purchased = {
49
+ // buyer: user,
50
+ // amount: BigNumber.from(ethIn),
51
+ // shares: BigNumber.from(shares),
52
+ // tokenId: BigNumber.from(tokenId),
53
+ // };
54
+ // }
55
+
56
+ // return {
57
+ // txHash: tx.hash,
58
+ // receipt,
59
+ // purchased,
60
+ // };
61
+ // }
65
62
 
66
63
  /**
67
- * Purchase warrants by transferring liqETH into the pool (ERC-20) and calling Depositor.purchaseWarrantsWithLiqETH(amountLiq, buyer).
64
+ * Purchase pretokens by transferring liqETH into the pool (ERC-20) and calling Depositor.purchasePretokensWithLiqETH(amountLiq, buyer).
68
65
  * Returns txHash, receipt and parsed PurchasedWithLiqETH event (if present).
69
66
  */
70
- async purchaseWarrantsWithLiqETH(amountLiq: BigNumber, buyer: string): Promise<any> {
67
+ async purchasePretokensWithLiqETH(amountLiq: BigNumber, buyer: string): Promise<any> {
71
68
  // attempt a simulation of the purchase call
72
69
  try {
73
- await this.contract.Depositor.callStatic.purchaseWarrantsWithLiqETH(amountLiq, buyer);
70
+ await this.contract.Depositor.callStatic.purchasePretokensWithLiqETH(amountLiq, buyer);
74
71
  } catch (err: any) {
75
72
  let errorObj = formatContractErrors(err);
76
73
 
@@ -87,7 +84,7 @@ export class PretokenClient {
87
84
  // attempt the real purchase call
88
85
  let tx, receipt;
89
86
  try {
90
- tx = await this.contract.Depositor.purchaseWarrantsWithLiqETH(amountLiq, buyer);
87
+ tx = await this.contract.Depositor.purchasePretokensWithLiqETH(amountLiq, buyer);
91
88
  receipt = await tx.wait(1);
92
89
  } catch (err: any) {
93
90
  let errorObj = formatContractErrors(err);
@@ -6,8 +6,6 @@
6
6
  import AccountingArtifact from '../../assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json';
7
7
  import DepositManagerArtifact from '../../assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json';
8
8
  import LiqEthArtifact from '../../assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json';
9
- // import LiqEthBurnArtifact from '../../assets/ethereum/ABI/liqEth/liqEthBurn.sol/LiqEthBurn.json';
10
- // import LiqEthMintArtifact from '../../assets/ethereum/ABI/liqEth/liqEthMint.sol/LiqEthMint.json';
11
9
  import StakingModuleArtifact from '../../assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json';
12
10
  import WithdrawalQueueArtifact from '../../assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.json';
13
11
  import WithdrawalVaultArtifact from '../../assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.json';
@@ -20,16 +18,10 @@ import BARArtifact from '../../assets/ethereum/ABI/outpost/BAR.sol/BAR.json';
20
18
  import OPPArtifact from '../../assets/ethereum/ABI/outpost/OPP.sol/OPP.json';
21
19
  import OPPCommonArtifact from '../../assets/ethereum/ABI/outpost/OPPCommon.sol/OPPCommon.json';
22
20
  import OPPInboundArtifact from '../../assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.json';
23
- import WarrantArtifact from '../../assets/ethereum/ABI/outpost/Warrant.sol/Warrant.json';
21
+ import PretokenArtifact from '../../assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.json';
24
22
  import AggregatorArtifact from '../../assets/ethereum/ABI/outpost/Aggregator.sol/Aggregator.json';
25
23
  import EthUsdPriceConsumerArtifact from '../../assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json';
26
24
 
27
- // Currently Unused Artifacts
28
- // import LiqEthCommonArtifact from '../../assets/ethereum/ABI/liqEth/liqEthCommon.sol/liqEthCommon.json';
29
- // import RewardsERC20Artifact from '../../assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.json';
30
- // import ValidatorBalanceArtifact from '../../assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json';
31
- // import YieldArtifact from '../../assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json';
32
-
33
25
  import ERC20Artifact from '../../assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.json';
34
26
  import ERC721Artifact from '../../assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.json';
35
27
  import ERC1155Artifact from '../../assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.json';
@@ -49,26 +41,28 @@ export const ERC1155Abi = ERC1155Artifact.abi;
49
41
 
50
42
  // Make sure ContractName in ./types includes all of these keys.
51
43
  export const ADDRESSES: AddressBook = {
52
- Accounting: "0xDf9da63E9CD14c79bD9f0E8F2E797096A40B6031",
53
- DepositManager: "0x3fEd507e554cd0e973CeCAf2168526b1617418d3",
54
- LiqEth: "0x1dA6aB23c2E2fA0a52C74F7f4189F770ED1eF9B3",
55
- StakingModule: "0xBd13C85fdefBBc63904e7301aCdeFE87c9C93234",
56
- WithdrawalQueue: "0xD9A1D38ae4A636DEf20B02F35387a6b126D73fAe", //aka "queue"
57
- WithdrawalVault: "0x150334D09a1d3d30EE93d5e6009EB897B5dDF5b2", //aka withdrawVault
44
+ Accounting: "0xd333A03a44D5d602A98c1B7bcd7ED1f042DD0dEd",
45
+ DepositManager: "0x601eaA31e8d33D8725786f1733f4cE6cCEf740D4",
46
+ LiqEth: "0x08252e1Dcbaa86A2887927b02536CD3E67a802c8", // AKA LiqEthToken
47
+ StakingModule: "0x7Aac2fCfc83d7F2f15eA53a10C1677CA377AFcF4",
48
+ WithdrawalQueue: "0x951E413FC81a2CE133078ABE8B88677F5296abE7",
49
+ WithdrawalVault: "0x0D2bf834DD560839e986d42D06DeE268A17c2d13",
50
+
51
+ // LiqEthAuthority: "0x7A9cf59EC53F32577Cc8200466Cc7693713129D5",
52
+ // BeaconState: "0xD3860E5977C94b343341635a2dEEBD20B651c48f",
53
+ // YieldOracle: "0x307b35816674913cf122975B3CF912b5709653F3",
58
54
 
59
-
60
55
  //Outpost contracts
61
- Depositor: "0x6aE1D7095B81970654Bd51bCAD42825C6E579088",
62
- ReceiptNFT: "0x38eAEa05cB1FFD0c8426A3f9e77815a251DdC197",
63
- OutpostManager: "0x6512bB8E7f8418A8e3bB73c49E33EcC30F53f221",
64
- BAR: "0x00c128A37598d018Eb8ca4f516688695D83bD413",
65
- OPP: "0x8C5710103Ec6a7608dAC539DC232d3822bA3d14C",
66
- OPPCommon: "0x52C1d7F02B35176F79b03F6eF7E5b74b27d1dB8c",
67
- OPPInbound: "0x39feC7536BaEd4E376b1B5cf2f2e8182ab203418",
68
- Warrant: "0x9190bBcaB5cfeb4b7b6DE5Ae21105F3114753F10",
69
-
70
- Aggregator: "0xd89F85Ce867E523Dc3E58578B06Ee72cdaBc39ec",
71
- EthUsdPriceConsumer: "0xd02F512eAcCA4c713CA954DfD907DC6E8cFACf8e",
56
+ Depositor: "0x69Aa53Ef02F124dB421AeDda509d6912341299Cc",
57
+ ReceiptNFT: "0x13588fF41E2f47D047874162B1eD15AaF6818f5a",
58
+ OutpostManager: "0x187f4fEDBCAD2f3150120B743b5d568F11dD3452",
59
+ BAR: "0x27d4646abF638A13934c94f8bA9AC1Bda39F5dbb",
60
+ OPP: "0x79CA2DE915C294593edc16b32CBA8B7866159205",
61
+ OPPCommon: "0x8392ea945Cd8C03F5241d4964D20BB5A9c320c71",
62
+ OPPInbound: "0xfDA9A2C7e395a9722d9fa506f5d67aba823298dd",
63
+ Pretoken: "0xcf6A1209A7A391cc576174204386F4e5462323dC",
64
+ EthUsdPriceConsumer: "0x1Ef180FF49313fCB8B5c0470268295d0d24CDE69",
65
+ Aggregator: "0xFCfc3ddd4CBd9Ad3b3af3A374B8bdA1b66eE6FFF",
72
66
  };
73
67
 
74
68
  export type Contracts<T extends string = ContractName> = Record<T, ContractConfig>;
@@ -95,26 +89,10 @@ export const CONTRACTS: Contracts<ContractName> = {
95
89
  address: ADDRESSES.DepositManager,
96
90
  abi: DepositManagerArtifact.abi as JsonFragment[],
97
91
  },
98
- // LiqEthMint: {
99
- // address: ADDRESSES.LiqEthMint,
100
- // abi: LiqEthMintArtifact.abi as JsonFragment[],
101
- // },
102
- // LiqEthBurn: {
103
- // address: ADDRESSES.LiqEthBurn,
104
- // abi: LiqEthBurnArtifact.abi as JsonFragment[],
105
- // },
106
- // RewardsERC20: {
107
- // address: ADDRESSES.RewardsERC20,
108
- // abi: RewardsERC20Artifact.abi as JsonFragment[],
109
- // },
110
92
  StakingModule: {
111
93
  address: ADDRESSES.StakingModule,
112
94
  abi: StakingModuleArtifact.abi as JsonFragment[],
113
95
  },
114
- // ValidatorBalance: {
115
- // address: ADDRESSES.ValidatorBalance,
116
- // abi: ValidatorBalanceArtifact.abi as JsonFragment[],
117
- // },
118
96
  WithdrawalQueue: {
119
97
  address: ADDRESSES.WithdrawalQueue,
120
98
  abi: WithdrawalQueueArtifact.abi as JsonFragment[],
@@ -123,11 +101,6 @@ export const CONTRACTS: Contracts<ContractName> = {
123
101
  address: ADDRESSES.WithdrawalVault,
124
102
  abi: WithdrawalVaultArtifact.abi as JsonFragment[],
125
103
  },
126
- // Yield: {
127
- // address: ADDRESSES.Yield,
128
- // abi: YieldArtifact.abi as JsonFragment[],
129
- // },
130
-
131
104
 
132
105
  // Outpost Contracts
133
106
  Depositor: {
@@ -158,9 +131,9 @@ export const CONTRACTS: Contracts<ContractName> = {
158
131
  address: ADDRESSES.OPPInbound,
159
132
  abi: OPPInboundArtifact.abi as JsonFragment[],
160
133
  },
161
- Warrant: {
162
- address: ADDRESSES.Warrant,
163
- abi: WarrantArtifact.abi as JsonFragment[],
134
+ Pretoken: {
135
+ address: ADDRESSES.Pretoken,
136
+ abi: PretokenArtifact.abi as JsonFragment[],
164
137
  },
165
138
  Aggregator: {
166
139
  address: ADDRESSES.Aggregator,
@@ -1,43 +1,47 @@
1
1
  import { BigNumber, ethers } from 'ethers';
2
- import { IStakingClient, Portfolio, PurchaseAsset, PurchaseQuote, StakerConfig, TrancheSnapshot } from '../../types';
2
+ import { IStakingClient, Portfolio, StakerConfig, TrancheSnapshot } from '../../types';
3
3
  import { ChainID, EvmChainID, PublicKey as WirePubKey } from '@wireio/core';
4
4
  import { EthereumContractService } from './contract';
5
- import { preLaunchReceipt, WithdrawRequestedEvent, WithdrawResult } from './types';
5
+ import { preLaunchReceipt } from './types';
6
6
  import { DepositClient } from './clients/deposit.client';
7
7
  import { StakeClient } from './clients/stake.client';
8
8
  import { PretokenClient } from './clients/pretoken.client';
9
- import { buildEthereumTrancheSnapshot, sendOPPFinalize } from './utils';
9
+ import { buildEthereumTrancheSnapshot } from './utils';
10
+ import { LiqClient } from './clients/liq.client';
11
+
10
12
 
11
13
 
12
14
 
13
15
  export class EthereumStakingClient implements IStakingClient {
14
- public readonly pubKey: WirePubKey;
16
+ public readonly pubKey?: WirePubKey;
15
17
  private readonly provider: ethers.providers.Web3Provider;
16
18
  private readonly signer: ethers.Signer;
17
19
  private readonly contractService: EthereumContractService;
18
20
 
19
21
  private depositClient: DepositClient;
20
- private stakeClient: StakeClient;
22
+ private liqClient: LiqClient;
21
23
  private pretokenClient: PretokenClient;
24
+ private stakeClient: StakeClient;
22
25
 
23
26
 
24
27
  get contract() { return this.contractService.contract; }
25
28
  get network() { return this.config.network; }
26
29
 
27
-
28
30
  constructor(private config: StakerConfig) {
29
31
  try {
30
32
  this.provider = config.provider as ethers.providers.Web3Provider;
31
33
  this.signer = this.provider.getSigner();
32
- this.pubKey = config.pubKey as WirePubKey;
34
+ this.pubKey = config.pubKey;
33
35
 
34
36
  this.contractService = new EthereumContractService({
35
37
  provider: this.provider,
36
38
  signer: this.signer,
37
39
  });
40
+
38
41
  this.depositClient = new DepositClient(this.contractService);
39
- this.stakeClient = new StakeClient(this.contractService);
42
+ this.liqClient = new LiqClient(this.contractService);
40
43
  this.pretokenClient = new PretokenClient(this.contractService);
44
+ this.stakeClient = new StakeClient(this.contractService);
41
45
  }
42
46
  catch (error) {
43
47
  // console.error('Error initializing EthereumStakingClient:', error);
@@ -45,6 +49,8 @@ export class EthereumStakingClient implements IStakingClient {
45
49
  }
46
50
  }
47
51
 
52
+
53
+
48
54
  // ---------------------------------------------------------------------
49
55
  // Public IStakingClient Interface Methods
50
56
  // ---------------------------------------------------------------------
@@ -65,20 +71,21 @@ export class EthereumStakingClient implements IStakingClient {
65
71
  }
66
72
 
67
73
 
74
+
68
75
  /**
69
- * Withdraw native ETH from the liqETH protocol via DepositManager.
76
+ * Withdraw native ETH from the liqETH protocol via the liqeth safeBurn function, which burns the LiqETH and adds the user to the withdrawal queue.
70
77
  * @param amount Amount in wei (or something convertible to BigNumber).
71
- * Keep this as a bigint / string in the caller; avoid JS floats.
72
78
  * @returns transaction hash
73
79
  */
74
80
  async withdraw(amount: bigint): Promise<string> {
75
- // const amountWei = BigNumber.from(amount);
81
+ const address = await this.signer.getAddress();
82
+ const amountWei = BigNumber.from(amount);
76
83
  // const chainId = this.network?.chainId ?? (await this.provider.getNetwork()).chainId;
77
84
  // const result = await this.depositClient.requestWithdraw(amountWei, this.signer, chainId);
78
- // return result.txHash;
79
- throw new Error("Method not yet implemented.");
80
- }
81
85
 
86
+ const result = await this.liqClient.safeBurn(address, amountWei)
87
+ return result.txHash;
88
+ }
82
89
 
83
90
 
84
91
  /**
@@ -159,7 +166,7 @@ export class EthereumStakingClient implements IStakingClient {
159
166
  }
160
167
 
161
168
 
162
- let result = await this.pretokenClient.purchaseWarrantsWithLiqETH(amountBigNum, buyer);
169
+ let result = await this.pretokenClient.purchasePretokensWithLiqETH(amountBigNum, buyer);
163
170
 
164
171
  return result && result.txHash ? result.txHash : "Error - no resulting txHash";
165
172
  }
@@ -199,14 +206,6 @@ export class EthereumStakingClient implements IStakingClient {
199
206
  }
200
207
  }
201
208
 
202
-
203
-
204
- // TODO
205
- getBuyQuote(amount: bigint, purchaseAsset: PurchaseAsset): Promise<PurchaseQuote> {
206
- throw new Error("Method not yet implemented.");
207
- }
208
-
209
-
210
209
  /**
211
210
  * Resolve the user's ETH + liqETH balances.
212
211
  *
@@ -286,12 +285,12 @@ export class EthereumStakingClient implements IStakingClient {
286
285
  const [totalSharesBn, indexBn, trancheNumberBn, trancheSupplyBn, tranchePriceWadBn, totalSupplyBn, supplyGrowthBps, priceGrowthBps, minPriceUsd, maxPriceUsd] = await Promise.all([
287
286
  this.contract.Depositor.totalShares(blockTag),
288
287
  this.contract.Depositor.index(blockTag),
289
- this.contract.Warrant.trancheNumber(blockTag),
290
- this.contract.Warrant.trancheSupply(blockTag),
291
- this.contract.Warrant.tranchePriceUsd(blockTag),
292
- this.contract.Warrant.totalSupply(blockTag),
293
- this.contract.Warrant.supplyGrowthBps(blockTag),
294
- this.contract.Warrant.priceGrowthBps(blockTag),
288
+ this.contract.Pretoken.trancheNumber(blockTag),
289
+ this.contract.Pretoken.trancheSupply(blockTag),
290
+ this.contract.Pretoken.tranchePriceUsd(blockTag),
291
+ this.contract.Pretoken.totalSupply(blockTag),
292
+ this.contract.Pretoken.supplyGrowthBps(blockTag),
293
+ this.contract.Pretoken.priceGrowthBps(blockTag),
295
294
  this.contract.EthUsdPriceConsumer.MIN_PRICE(),
296
295
  this.contract.EthUsdPriceConsumer.MAX_PRICE(),
297
296
  ]);
@@ -303,33 +302,11 @@ export class EthereumStakingClient implements IStakingClient {
303
302
 
304
303
  // fetch price and timestamp from aggregator
305
304
  const [ roundId, answer, startedAt, updatedAt, answeredInRound ] = await this.contract.Aggregator.latestRoundData();
306
- console.log('mockaggregator answer', answer.toString())
307
305
  let ethPriceUsd: bigint = BigInt(answer.toString());
308
306
  let nativePriceTimestamp: number = Number(updatedAt);
309
307
 
310
-
311
308
  // ! Placeholder from hoodi deployment - don't think this can be fetched dynamically
312
309
  const initialTrancheSupply = BigInt(60000) * BigInt(1e8);
313
-
314
- console.log('options for building eth tranche snapshot', {
315
- chainID,
316
- totalSharesBn,
317
- indexBn,
318
- trancheNumberBn,
319
- currentTrancheSupply: currentTrancheSupply.toString(),
320
- tranchePriceWadBn,
321
- totalTrancheSupply: totalTrancheSupply.toString(),
322
- initialTrancheSupply: initialTrancheSupply.toString(),
323
- supplyGrowthBps,
324
- priceGrowthBps,
325
- minPriceUsd,
326
- maxPriceUsd,
327
-
328
- ethPriceUsd,
329
- nativePriceTimestamp,
330
- ladderWindowBefore: windowBefore,
331
- ladderWindowAfter: windowAfter,
332
- })
333
310
 
334
311
  return buildEthereumTrancheSnapshot({
335
312
  chainID,
@@ -400,7 +377,7 @@ export class EthereumStakingClient implements IStakingClient {
400
377
  //update answer with current timestamp
401
378
  const tx = await aggregator.updateAnswer(currentEthPrice);
402
379
  const txreceipt = await tx.wait(1);
403
- console.log('MockAggregator answer updated - receipt:', txreceipt)
380
+ // console.log('MockAggregator answer updated - receipt:', txreceipt)
404
381
  } catch (err: any) {
405
382
  console.error('MockAggregator updateAnswer failed', err?.message || err);
406
383
  }
@@ -5,14 +5,9 @@ export const CONTRACT_NAMES = [
5
5
  'Accounting',
6
6
  'DepositManager',
7
7
  'LiqEth',
8
- // 'LiqEthBurn',
9
- // 'LiqEthMint',
10
- // 'RewardsERC20',
11
8
  'StakingModule',
12
- // 'ValidatorBalance',
13
9
  'WithdrawalQueue',
14
10
  'WithdrawalVault',
15
- // 'Yield',
16
11
 
17
12
  //Outpost contracts
18
13
  'Depositor',
@@ -22,7 +17,7 @@ export const CONTRACT_NAMES = [
22
17
  'OPP',
23
18
  'OPPCommon',
24
19
  'OPPInbound',
25
- 'Warrant',
20
+ 'Pretoken',
26
21
  'Aggregator',
27
22
  'EthUsdPriceConsumer',
28
23
 
@@ -89,6 +84,12 @@ export interface WithdrawnStakeResult extends Result {
89
84
 
90
85
  }
91
86
 
87
+ export interface SharesBurnedEvent {
88
+ from: string;
89
+ shares: BigNumber;
90
+ tokenValue: BigNumber;
91
+ }
92
+
92
93
  export interface preLaunchReceipt {
93
94
  tokenId: bigint;
94
95
  receipt: {
@@ -138,7 +138,7 @@ function shrinkOnce(value: bigint, growthBps: number): bigint {
138
138
  */
139
139
  function getTrancheSize(startSupply: bigint, supplyGrowthBps: number, trancheNumber: number): bigint {
140
140
  let supply = startSupply;
141
- for (let i = 1; i < trancheNumber; i++) {
141
+ for (let i = 0; i < trancheNumber; i++) {
142
142
  supply = (supply * (BPS + BigInt(supplyGrowthBps)) + BPS / BigInt(2)) / BPS;
143
143
  }
144
144
  return supply;
@@ -172,12 +172,8 @@ export function buildEthereumTrancheLadder(options: {
172
172
  windowAfter = 5,
173
173
  } = options;
174
174
 
175
- const startId = Math.max(1, currentTranche - windowBefore);
175
+ const startId = Math.max(0, currentTranche - windowBefore);
176
176
  const endId = currentTranche + windowAfter;
177
-
178
- console.error('loading eth tranche ladder - ', currentTranche, currentTrancheSupply);
179
- console.log('startId', startId)
180
-
181
177
 
182
178
  //calculate total tranche size (e.g. 60,600 on tranche 2)
183
179
  const currentTrancheSize = getTrancheSize(initialTrancheSupply, supplyGrowthBps, currentTranche);
@@ -300,13 +296,11 @@ export async function buildEthereumTrancheSnapshot(options: {
300
296
  totalShares,
301
297
  currentTranche,
302
298
  currentPriceUsd,
303
- minPriceUsd,
304
- maxPriceUsd,
305
299
  supplyGrowthBps,
306
300
  priceGrowthBps,
307
301
  currentTrancheSupply,
308
302
  initialTrancheSupply,
309
- totalWarrantsSold: totalTrancheSupply,
303
+ totalPretokensSold: totalTrancheSupply,
310
304
  nativePriceUsd: ethPriceUsd,
311
305
  nativePriceTimestamp,
312
306
  ladder,
@@ -20,7 +20,6 @@ import {
20
20
  import { derivePriceHistoryPda } from '../constants';
21
21
  import type { } from '../types';
22
22
  import { ChainID, SolChainID } from '@wireio/core';
23
- import { PurchaseAsset, PurchaseQuote, TrancheSnapshot } from '../../../types';
24
23
 
25
24
  export class TokenClient {
26
25
  private readonly program: Program<LiqsolCore>;