@wireio/stake 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/stake.browser.js +11779 -2023
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +94 -40
- package/lib/stake.js +11906 -2088
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +11779 -2023
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json +26 -65
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IAccounting.json +24 -20
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.json +0 -20
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.json +2 -2
- package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20Pausable.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.json +2 -2
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.json +2 -2
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json +2 -2
- package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json +31 -109
- package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json +2 -25
- package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json +30 -72
- package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +2 -2
- package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.json +2 -2
- package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.json +2 -2
- package/src/assets/ethereum/ABI/outpost/BAR.sol/BAR.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/BAR.sol/BAR.json +1856 -0
- package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.json +1753 -0
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.json +122 -0
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +601 -0
- package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.json +930 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPP.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPP.json +88 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPEndpoint.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPEndpoint.json +29 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPInbound.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPInbound.json +194 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPReceiver.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPReceiver.json +29 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPSender.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/IOPPSender.json +36 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/OPPCommon.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPCommon.sol/OPPCommon.json +199 -0
- package/src/assets/ethereum/ABI/outpost/OPPEndpoint.sol/OPPEndpoint.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPEndpoint.sol/OPPEndpoint.json +273 -0
- package/src/assets/ethereum/ABI/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPEndpointManaged.sol/OPPEndpointManaged.json +394 -0
- package/src/assets/ethereum/ABI/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPEndpointOwnable.sol/OPPEndpointOwnable.json +378 -0
- package/src/assets/ethereum/ABI/outpost/OPPErrors.sol/OPPErrors.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPErrors.sol/OPPErrors.json +224 -0
- package/src/assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.json +1010 -0
- package/src/assets/ethereum/ABI/outpost/OPPReceiver.sol/OPPReceiver.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPReceiver.sol/OPPReceiver.json +291 -0
- package/src/assets/ethereum/ABI/outpost/OPPSender.sol/OPPSender.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OPPSender.sol/OPPSender.json +298 -0
- package/src/assets/ethereum/ABI/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OutpostErrors.sol/OutpostErrors.json +473 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManaged.sol/OutpostManaged.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManaged.sol/OutpostManaged.json +229 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManager.sol/OutpostManager.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManager.sol/OutpostManager.json +730 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManagerAuthority.sol/OutpostManagerAuthority.json +1432 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/IOutpostManager.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/IOutpostManager.json +130 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/IOutpostUpgradeable.json +29 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OutpostManagerCommon.sol/OutpostManagerCommon.json +141 -0
- package/src/assets/ethereum/ABI/outpost/OutpostOwnable.sol/OutpostOwnable.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/OutpostOwnable.sol/OutpostOwnable.json +213 -0
- package/src/assets/ethereum/ABI/outpost/Pool.sol/Pool.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/Pool.sol/Pool.json +921 -0
- package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.json +2020 -0
- package/src/assets/ethereum/ABI/outpost/Warrant.sol/Warrant.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/Warrant.sol/Warrant.json +1650 -0
- package/src/assets/ethereum/ABI/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +4 -0
- package/src/assets/ethereum/ABI/{liqEth/LiqEthCommon.sol/ILiqEthMint.json → outpost/interfaces/IWarrant.sol/IWarrant.json} +6 -12
- package/src/assets/ethereum/ABI/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/token/ERC721EthEquivalentVotesUpgradeable.sol/ERC721EthEquivalentVotesUpgradeable.json +858 -0
- package/src/assets/ethereum/ABI/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/token/IERC721EthEquivalent.sol/IERC721EthEquivalent.json +30 -0
- package/src/networks/ethereum/clients/deposit.client.ts +82 -0
- package/src/networks/ethereum/clients/stake.client.ts +215 -0
- package/src/networks/ethereum/contract.ts +79 -23
- package/src/networks/ethereum/ethereum.ts +130 -66
- package/src/networks/ethereum/types.ts +74 -7
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthBurn.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthBurn.json +0 -24
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthMint.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/liqEthBurn.sol/LiqEthBurn.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/liqEthBurn.sol/LiqEthBurn.json +0 -391
- package/src/assets/ethereum/ABI/liqEth/liqEthMint.sol/LiqEthMint.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/liqEthMint.sol/LiqEthMint.json +0 -402
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { BigNumber,
|
|
1
|
+
import { BigNumber, ethers } from 'ethers';
|
|
2
2
|
import { IStakingClient, Portfolio, StakerConfig } from '../../staker/types';
|
|
3
3
|
import { PublicKey as WirePubKey } from '@wireio/core';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { EthereumContractService } from './contract';
|
|
5
|
+
import { preLaunchReceipt, WithdrawRequestedEvent, WithdrawResult } from './types';
|
|
6
|
+
import { DepositClient } from './clients/deposit.client';
|
|
7
|
+
import { StakeClient } from './clients/stake.client';
|
|
8
|
+
|
|
9
|
+
|
|
6
10
|
|
|
7
11
|
export class EthereumStakingClient implements IStakingClient {
|
|
8
12
|
public readonly pubKey: WirePubKey;
|
|
@@ -10,6 +14,9 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
10
14
|
private readonly signer: ethers.Signer;
|
|
11
15
|
private readonly contractService: EthereumContractService;
|
|
12
16
|
|
|
17
|
+
private depositClient: DepositClient;
|
|
18
|
+
private stakeClient: StakeClient;
|
|
19
|
+
|
|
13
20
|
get contract() { return this.contractService.contract; }
|
|
14
21
|
get network() { return this.config.network; }
|
|
15
22
|
|
|
@@ -23,6 +30,8 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
23
30
|
provider: this.provider,
|
|
24
31
|
signer: this.signer,
|
|
25
32
|
});
|
|
33
|
+
this.depositClient = new DepositClient(this.contractService);
|
|
34
|
+
this.stakeClient = new StakeClient(this.contractService);
|
|
26
35
|
}
|
|
27
36
|
catch (error) {
|
|
28
37
|
// console.error('Error initializing EthereumStakingClient:', error);
|
|
@@ -45,25 +54,67 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
45
54
|
? amount
|
|
46
55
|
: BigNumber.from(amount);
|
|
47
56
|
|
|
48
|
-
const result = await this.performDeposit(amountWei);
|
|
57
|
+
const result = await this.depositClient.performDeposit(amountWei);
|
|
49
58
|
return result.txHash;
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
|
|
62
|
+
// TODO - In progress
|
|
63
|
+
async withdraw(amount: number | string | bigint | BigNumber): Promise<string> {
|
|
64
|
+
const amountWei = BigNumber.isBigNumber(amount)
|
|
65
|
+
? amount
|
|
66
|
+
: BigNumber.from(amount);
|
|
67
|
+
|
|
68
|
+
const result = await this.requestWithdraw(amountWei);
|
|
69
|
+
return result.txHash;
|
|
55
70
|
}
|
|
56
71
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
|
|
73
|
+
// TODO - In progress
|
|
74
|
+
async stake(amount: bigint): Promise<string> {
|
|
75
|
+
const walletAddress = await this.signer.getAddress();
|
|
76
|
+
const amountWei = BigNumber.from(amount);
|
|
77
|
+
|
|
78
|
+
const result = await this.stakeClient.performStake(amountWei, walletAddress);
|
|
79
|
+
return result.txHash;
|
|
60
80
|
}
|
|
61
81
|
|
|
82
|
+
|
|
62
83
|
// TODO
|
|
63
84
|
async unstake(): Promise<string> {
|
|
64
85
|
throw new Error("Method not yet implemented.");
|
|
65
86
|
}
|
|
66
87
|
|
|
88
|
+
// TODO
|
|
89
|
+
async unstakePrelaunch(tokenId: bigint, recipient: string): Promise<string> {
|
|
90
|
+
const tokenIdBigNum = BigNumber.from(tokenId)
|
|
91
|
+
const result = await this.stakeClient.performWithdrawStake(tokenIdBigNum, recipient);
|
|
92
|
+
return result.txHash;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
async fetchPrelaunchReceipts(address?: string): Promise<preLaunchReceipt[]> {
|
|
97
|
+
if(address === undefined) address = await this.signer.getAddress();
|
|
98
|
+
|
|
99
|
+
let receipts = await this.stakeClient.fetchPreLaunchReceipts(address);
|
|
100
|
+
return receipts
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
async getEthStats(): Promise<any> {
|
|
106
|
+
let withdrawDelay = await this.contract.DepositManager.withdrawDelay();
|
|
107
|
+
let minDeposit = await this.contract.DepositManager.minDeposit();
|
|
108
|
+
let rewardCooldown = await this.contract.DepositManager.rewardCooldown();
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
withdrawDelay,
|
|
112
|
+
minDeposit,
|
|
113
|
+
rewardCooldown,
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
67
118
|
/**
|
|
68
119
|
* Resolve the user's ETH + liqETH balances.
|
|
69
120
|
*
|
|
@@ -74,21 +125,21 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
74
125
|
async getPortfolio(): Promise<Portfolio> {
|
|
75
126
|
const walletAddress = await this.signer.getAddress();
|
|
76
127
|
// console.log('getPortfolio() wallet address', walletAddress)
|
|
128
|
+
|
|
129
|
+
|
|
77
130
|
// 1) Native ETH balance
|
|
78
131
|
const nativeBalance = await this.provider.getBalance(walletAddress);
|
|
79
|
-
// console.log('nativeBalance', nativeBalance);
|
|
80
132
|
const nativeDecimals = this.network?.nativeCurrency?.decimals ?? 18;
|
|
81
133
|
const nativeSymbol = this.network?.nativeCurrency?.symbol ?? 'ETH';
|
|
82
134
|
|
|
83
|
-
|
|
84
|
-
|
|
85
135
|
// 2) liqETH ERC-20 balance (actual)
|
|
86
136
|
const liqBalance: ethers.BigNumber = await this.contract.LiqEth.balanceOf(walletAddress);
|
|
87
|
-
// console.log('liqBalance', liqBalance);
|
|
88
|
-
|
|
89
|
-
const liqDecimals = this.network?.nativeCurrency?.decimals ?? 18;
|
|
90
137
|
const liqSymbol = 'Liq' + (this.network?.nativeCurrency?.symbol ?? 'ETH');
|
|
91
138
|
|
|
139
|
+
// 3) staked liqEth ERC-20 balance (actual)
|
|
140
|
+
const stakedLiqBalance = await this.contract.Depositor.sharesOf(walletAddress);
|
|
141
|
+
|
|
142
|
+
|
|
92
143
|
const portfolio: Portfolio = {
|
|
93
144
|
native: {
|
|
94
145
|
amount: nativeBalance.toBigInt(),
|
|
@@ -97,17 +148,17 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
97
148
|
},
|
|
98
149
|
liq: {
|
|
99
150
|
amount: liqBalance.toBigInt(),
|
|
100
|
-
decimals:
|
|
151
|
+
decimals: nativeDecimals,
|
|
101
152
|
symbol: liqSymbol,
|
|
102
153
|
},
|
|
103
154
|
tracked: {
|
|
104
155
|
amount: liqBalance.toBigInt(),
|
|
105
|
-
decimals:
|
|
156
|
+
decimals: nativeDecimals,
|
|
106
157
|
symbol: liqSymbol,
|
|
107
158
|
},
|
|
108
|
-
staked: {
|
|
109
|
-
amount:
|
|
110
|
-
decimals:
|
|
159
|
+
staked: {
|
|
160
|
+
amount: stakedLiqBalance.toBigInt(),
|
|
161
|
+
decimals: nativeDecimals,
|
|
111
162
|
symbol: liqSymbol,
|
|
112
163
|
},
|
|
113
164
|
chainID: this.network.chainId
|
|
@@ -121,63 +172,76 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
121
172
|
// Internal ETH Staking client helper functions
|
|
122
173
|
// ---------------------------------------------------------------------
|
|
123
174
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// Send the payable tx
|
|
154
|
-
const tx = await this.contract.DepositManager.deposit({
|
|
175
|
+
private async requestWithdraw(amountWei: BigNumber): Promise<WithdrawResult> {
|
|
176
|
+
// deadline is a period of time in the future that the signature is valid for
|
|
177
|
+
const deadline = Math.floor(Date.now() / 1000) + 3600;
|
|
178
|
+
const liqEth = this.contract.LiqEth;
|
|
179
|
+
const owner = await this.signer.getAddress();
|
|
180
|
+
const liqEthAddress = this.contractService.getAddress('LiqEth');
|
|
181
|
+
|
|
182
|
+
const nonce: BigNumber = await liqEth.nonces(owner);
|
|
183
|
+
const chainId = this.network?.chainId ?? (await this.provider.getNetwork()).chainId;
|
|
184
|
+
const domain = {
|
|
185
|
+
name: await liqEth.name(),
|
|
186
|
+
version: '1',
|
|
187
|
+
chainId,
|
|
188
|
+
verifyingContract: liqEthAddress,
|
|
189
|
+
} as any;
|
|
190
|
+
|
|
191
|
+
const types = {
|
|
192
|
+
Permit: [
|
|
193
|
+
{ name: 'owner', type: 'address' },
|
|
194
|
+
{ name: 'spender', type: 'address' },
|
|
195
|
+
{ name: 'value', type: 'uint256' },
|
|
196
|
+
{ name: 'nonce', type: 'uint256' },
|
|
197
|
+
{ name: 'deadline', type: 'uint256' },
|
|
198
|
+
],
|
|
199
|
+
} as any;
|
|
200
|
+
|
|
201
|
+
const values = {
|
|
202
|
+
owner,
|
|
203
|
+
spender: this.contractService.getAddress('DepositManager'),
|
|
155
204
|
value: amountWei,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
205
|
+
nonce: nonce,
|
|
206
|
+
deadline,
|
|
207
|
+
} as any;
|
|
208
|
+
|
|
209
|
+
const signature = await (this.signer as any)._signTypedData(domain, types, values);
|
|
210
|
+
const split = ethers.utils.splitSignature(signature);
|
|
211
|
+
|
|
212
|
+
const tx = await this.contract.DepositManager.requestWithdrawal(
|
|
213
|
+
amountWei,
|
|
214
|
+
deadline,
|
|
215
|
+
split.v,
|
|
216
|
+
split.r,
|
|
217
|
+
split.s
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
// wait for 1 confirmation
|
|
159
221
|
const receipt = await tx.wait(1);
|
|
160
222
|
|
|
161
|
-
//
|
|
162
|
-
let
|
|
163
|
-
const ev = receipt.events?.find((e) => e.event === '
|
|
223
|
+
// if WithdrawRequested event exists, parse it and get arguments
|
|
224
|
+
let withdrawRequested: WithdrawRequestedEvent | undefined;
|
|
225
|
+
const ev = receipt.events?.find((e) => e.event === 'WithdrawRequested');
|
|
164
226
|
|
|
165
227
|
if (ev && ev.args) {
|
|
166
|
-
const { user,
|
|
167
|
-
|
|
228
|
+
const { user, ethAmount, nftId, readyAt } = ev.args;
|
|
229
|
+
withdrawRequested = {
|
|
168
230
|
user,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
231
|
+
ethAmount: BigNumber.from(ethAmount),
|
|
232
|
+
nftId: BigNumber.from(nftId),
|
|
233
|
+
readyAt: readyAt,
|
|
172
234
|
};
|
|
173
235
|
}
|
|
174
236
|
|
|
175
237
|
return {
|
|
176
238
|
txHash: tx.hash,
|
|
177
239
|
receipt,
|
|
178
|
-
|
|
179
|
-
};
|
|
240
|
+
withdrawRequested,
|
|
241
|
+
} as WithdrawResult;
|
|
180
242
|
}
|
|
181
243
|
|
|
182
|
-
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
// TODO: implement claimRewards, etc.
|
|
183
247
|
}
|
|
@@ -1,22 +1,43 @@
|
|
|
1
1
|
import { BigNumber, ethers } from 'ethers';
|
|
2
|
+
import { BalanceView } from '../../staker/types';
|
|
2
3
|
|
|
3
4
|
export const CONTRACT_NAMES = [
|
|
4
5
|
'Accounting',
|
|
5
6
|
'DepositManager',
|
|
6
7
|
'LiqEth',
|
|
7
|
-
'LiqEthBurn',
|
|
8
|
-
'LiqEthMint',
|
|
8
|
+
// 'LiqEthBurn',
|
|
9
|
+
// 'LiqEthMint',
|
|
9
10
|
// 'RewardsERC20',
|
|
10
11
|
'StakingModule',
|
|
11
12
|
// 'ValidatorBalance',
|
|
12
13
|
'WithdrawalQueue',
|
|
13
14
|
'WithdrawalVault',
|
|
14
15
|
// 'Yield',
|
|
16
|
+
|
|
17
|
+
//Outpost contracts
|
|
18
|
+
'Depositor',
|
|
19
|
+
'ReceiptNFT',
|
|
20
|
+
'OutpostManager',
|
|
21
|
+
'BAR',
|
|
22
|
+
'OPP',
|
|
23
|
+
'OPPCommon',
|
|
24
|
+
'OPPInbound',
|
|
25
|
+
'Warrant',
|
|
26
|
+
|
|
15
27
|
] as const;
|
|
16
28
|
|
|
17
29
|
export type ContractName = typeof CONTRACT_NAMES[number];
|
|
18
30
|
export type AddressBook = Record<ContractName, string>;
|
|
19
31
|
|
|
32
|
+
|
|
33
|
+
interface Result {
|
|
34
|
+
/** EVM transaction hash */
|
|
35
|
+
txHash: string;
|
|
36
|
+
/** Full receipt, if you want it */
|
|
37
|
+
receipt: ethers.providers.TransactionReceipt;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
20
41
|
export interface DepositEvent {
|
|
21
42
|
user: string;
|
|
22
43
|
netEth: BigNumber;
|
|
@@ -24,11 +45,57 @@ export interface DepositEvent {
|
|
|
24
45
|
shares: BigNumber;
|
|
25
46
|
}
|
|
26
47
|
|
|
27
|
-
export interface DepositResult {
|
|
28
|
-
/** EVM transaction hash */
|
|
29
|
-
txHash: string;
|
|
30
|
-
/** Full receipt, if you want it */
|
|
31
|
-
receipt: ethers.providers.TransactionReceipt;
|
|
48
|
+
export interface DepositResult extends Result {
|
|
32
49
|
/** Parsed Deposited event, if present */
|
|
33
50
|
deposited?: DepositEvent;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface WithdrawRequestedEvent {
|
|
54
|
+
user: string;
|
|
55
|
+
ethAmount: BigNumber;
|
|
56
|
+
nftId: BigNumber;
|
|
57
|
+
readyAt: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface WithdrawResult extends Result {
|
|
61
|
+
/** Parsed WithdrawRequested event, if present */
|
|
62
|
+
withdrawRequested?: WithdrawRequestedEvent;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
export interface StakedEvent {
|
|
67
|
+
user: string;
|
|
68
|
+
amountLiq: BigNumber;
|
|
69
|
+
shares: BigNumber;
|
|
70
|
+
tokenId: BigNumber;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface StakedResult extends Result {
|
|
74
|
+
/** Parsed Staked event, if present */
|
|
75
|
+
staked?: StakedEvent;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
export interface WithdrawnStakeEvent {
|
|
80
|
+
user: string;
|
|
81
|
+
tokenId: BigNumber;
|
|
82
|
+
tokenOut: BigNumber;
|
|
83
|
+
}
|
|
84
|
+
export interface WithdrawnStakeResult extends Result {
|
|
85
|
+
/** Parsed WithdrawnStake event, if present */
|
|
86
|
+
withdrawnstake?: WithdrawnStakeEvent;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface preLaunchReceipt {
|
|
91
|
+
tokenId: bigint;
|
|
92
|
+
receipt: {
|
|
93
|
+
account: string,
|
|
94
|
+
currency: number,
|
|
95
|
+
kind: number,
|
|
96
|
+
indexAtMint: BalanceView,
|
|
97
|
+
principal: BalanceView,
|
|
98
|
+
shares: BalanceView,
|
|
99
|
+
timestamp: string,
|
|
100
|
+
}
|
|
34
101
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_format": "hh-sol-artifact-1",
|
|
3
|
-
"contractName": "ILiqEthBurn",
|
|
4
|
-
"sourceName": "contracts/liqEth/LiqEthCommon.sol",
|
|
5
|
-
"abi": [
|
|
6
|
-
{
|
|
7
|
-
"inputs": [
|
|
8
|
-
{
|
|
9
|
-
"internalType": "uint256",
|
|
10
|
-
"name": "amount",
|
|
11
|
-
"type": "uint256"
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"name": "burn",
|
|
15
|
-
"outputs": [],
|
|
16
|
-
"stateMutability": "nonpayable",
|
|
17
|
-
"type": "function"
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"bytecode": "0x",
|
|
21
|
-
"deployedBytecode": "0x",
|
|
22
|
-
"linkReferences": {},
|
|
23
|
-
"deployedLinkReferences": {}
|
|
24
|
-
}
|