@wireio/stake 0.2.4 → 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.
- package/lib/stake.browser.js +5991 -4340
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +74 -60
- package/lib/stake.js +9782 -8054
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +5991 -4340
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/BeaconState.sol/BeaconState.dbg.json +4 -0
- package/src/assets/ethereum/ABI/liqEth/BeaconState.sol/BeaconState.json +807 -0
- package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json +184 -346
- package/src/assets/ethereum/ABI/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +4 -0
- package/src/assets/ethereum/ABI/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +1289 -0
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +1 -1
- 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/ILiqEthUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.json +36 -0
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +263 -0
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.json +226 -0
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +59 -0
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +14 -12
- 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/LiqEthManaged.sol/LiqEthManaged.dbg.json +4 -0
- package/src/assets/ethereum/ABI/liqEth/LiqEthManaged.sol/LiqEthManaged.json +229 -0
- package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +4 -0
- package/src/assets/ethereum/ABI/liqEth/{RewardsERC20Pausable.sol/RewardsERC20Pausable.json → RewardsERC20.sol/RewardsERC20Upgradeable.json} +140 -78
- package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +4 -0
- package/src/assets/ethereum/ABI/liqEth/{RewardsERC20.sol/RewardsERC20.json → RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json} +218 -30
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.json +2 -2
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.json +2 -2
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZExtras.dbg.json +4 -0
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZExtras.json +10 -0
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZVec48.dbg.json +4 -0
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZVec48.json +10 -0
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json +121 -55
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json +836 -273
- package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json +150 -168
- package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json +301 -186
- package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json +814 -206
- package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +244 -198
- 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 +165 -152
- package/src/assets/ethereum/ABI/outpost/Aggregator.sol/Aggregator.json +82 -0
- package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.json +167 -282
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +2 -54
- package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.json +26 -8
- package/src/assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.json +2 -2
- package/src/assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.json +1650 -0
- package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.json +2 -22
- package/src/assets/ethereum/ABI/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +4 -0
- package/src/assets/ethereum/ABI/outpost/interfaces/IPretoken.sol/IPretoken.json +29 -0
- package/src/assets/ethereum/ABI/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +1 -1
- package/src/networks/ethereum/clients/deposit.client.ts +86 -8
- package/src/networks/ethereum/clients/liq.client.ts +47 -0
- package/src/networks/ethereum/clients/pretoken.client.ts +127 -0
- package/src/networks/ethereum/clients/stake.client.ts +87 -24
- package/src/networks/ethereum/contract.ts +34 -48
- package/src/networks/ethereum/ethereum.ts +219 -96
- package/src/networks/ethereum/types.ts +9 -6
- package/src/networks/ethereum/utils.ts +308 -0
- package/src/networks/solana/clients/token.client.ts +0 -1
- package/src/networks/solana/solana.ts +44 -146
- package/src/networks/solana/types.ts +6 -2
- package/src/networks/solana/utils.ts +4 -6
- package/src/staker/types.ts +62 -0
- package/src/types.ts +18 -33
- package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20Pausable.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.json +0 -10
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.dbg.json +0 -4
- package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.json +0 -10
- package/src/assets/ethereum/ABI/outpost/Warrant.sol/Warrant.dbg.json +0 -4
- package/src/assets/ethereum/ABI/outpost/Warrant.sol/Warrant.json +0 -1650
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { BigNumber, ethers } from "ethers";
|
|
2
|
+
import { EthereumContractService } from "../contract";
|
|
3
|
+
import { formatContractErrors, sendOPPFinalize } from "../utils";
|
|
4
|
+
|
|
5
|
+
export class PretokenClient {
|
|
6
|
+
private readonly contractService: EthereumContractService;
|
|
7
|
+
|
|
8
|
+
get contract() { return this.contractService.contract; }
|
|
9
|
+
|
|
10
|
+
constructor(contract: EthereumContractService) {
|
|
11
|
+
this.contractService = contract;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Purchase pretokens by sending ETH to the Depositor.purchasePretokensWithETH(buyer) payable function.
|
|
18
|
+
* Returns txHash, receipt and parsed PurchasedWithETH event (if present).
|
|
19
|
+
*/
|
|
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
|
+
// }
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Purchase pretokens by transferring liqETH into the pool (ERC-20) and calling Depositor.purchasePretokensWithLiqETH(amountLiq, buyer).
|
|
65
|
+
* Returns txHash, receipt and parsed PurchasedWithLiqETH event (if present).
|
|
66
|
+
*/
|
|
67
|
+
async purchasePretokensWithLiqETH(amountLiq: BigNumber, buyer: string): Promise<any> {
|
|
68
|
+
// attempt a simulation of the purchase call
|
|
69
|
+
try {
|
|
70
|
+
await this.contract.Depositor.callStatic.purchasePretokensWithLiqETH(amountLiq, buyer);
|
|
71
|
+
} catch (err: any) {
|
|
72
|
+
let errorObj = formatContractErrors(err);
|
|
73
|
+
|
|
74
|
+
// ! TEMP for testing
|
|
75
|
+
if(errorObj.name == "OPP_PreviousEpochUnsent") {
|
|
76
|
+
console.error("OPP Previous Epoch is unsent - trigger OPP finalizeEpoch()")
|
|
77
|
+
await sendOPPFinalize(this.contract.OPP);
|
|
78
|
+
throw new Error(errorObj.name+` - triggering OPP finalizeEpoch() please try again`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
throw new Error(errorObj.name ?? errorObj.raw)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// attempt the real purchase call
|
|
85
|
+
let tx, receipt;
|
|
86
|
+
try {
|
|
87
|
+
tx = await this.contract.Depositor.purchasePretokensWithLiqETH(amountLiq, buyer);
|
|
88
|
+
receipt = await tx.wait(1);
|
|
89
|
+
} catch (err: any) {
|
|
90
|
+
let errorObj = formatContractErrors(err);
|
|
91
|
+
throw new Error(errorObj.name ?? errorObj.raw)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
// Attempt to parse PurchasedWithLiqETH event
|
|
96
|
+
let purchased: any | undefined;
|
|
97
|
+
const ev = receipt.events?.find((e) => e.event === 'PurchasedWithLiqETH' || (e.event && e.event.toString().startsWith('PurchasedWithLiqETH')));
|
|
98
|
+
|
|
99
|
+
if (ev && ev.args) {
|
|
100
|
+
// Event shape: PurchasedWithLiqETH(buyer, amountLiq, ethEqWei, shares, tokenId)
|
|
101
|
+
const args: any = ev.args;
|
|
102
|
+
// try named fields first, fallback to positional
|
|
103
|
+
const evtBuyer = args.buyer ?? args[0];
|
|
104
|
+
const evtAmountLiq = (args.amountLiq ?? args[1]) ? BigNumber.from(args.amountLiq ?? args[1]) : undefined;
|
|
105
|
+
const evtEthEqWei = (args.ethEqWei ?? args[2]) ? BigNumber.from(args.ethEqWei ?? args[2]) : undefined;
|
|
106
|
+
const evtShares = (args.shares ?? args[3]) ? BigNumber.from(args.shares ?? args[3]) : undefined;
|
|
107
|
+
const evtTokenId = (args.tokenId ?? args[4]) ? BigNumber.from(args.tokenId ?? args[4]) : undefined;
|
|
108
|
+
|
|
109
|
+
purchased = {
|
|
110
|
+
buyer: evtBuyer,
|
|
111
|
+
amountLiq: evtAmountLiq,
|
|
112
|
+
ethEqWei: evtEthEqWei,
|
|
113
|
+
shares: evtShares,
|
|
114
|
+
tokenId: evtTokenId,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
txHash: tx.hash,
|
|
120
|
+
receipt,
|
|
121
|
+
purchased,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BigNumber, ethers } from "ethers";
|
|
2
|
-
import { preLaunchReceipt, StakedEvent,
|
|
2
|
+
import { preLaunchReceipt, StakedEvent, WithdrawnStakeEvent, WithdrawnStakeResult } from "../types";
|
|
3
3
|
import { EthereumContractService } from "../contract";
|
|
4
|
+
import { formatContractErrors } from "../utils";
|
|
4
5
|
|
|
5
6
|
export class StakeClient {
|
|
6
7
|
|
|
@@ -15,19 +16,72 @@ export class StakeClient {
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
|
-
* Simulate a stake via callStatic
|
|
19
|
-
*
|
|
20
|
-
* Useful for pre-flight checks; will throw with the same revert
|
|
21
|
-
* reason as a real tx if it would fail.
|
|
19
|
+
* Simulate a stake via callStatic
|
|
22
20
|
*/
|
|
23
|
-
async simulateStake(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
async simulateStake(amountWei: BigNumber): Promise<void> {
|
|
22
|
+
try {
|
|
23
|
+
await this.contract.Depositor.callStatic.stakeLiqETH(amountWei);
|
|
24
|
+
} catch (err: any) {
|
|
25
|
+
let errorObj = formatContractErrors(err);
|
|
26
|
+
throw new Error(errorObj.name ?? errorObj.raw)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Read OPP / Outpost state used by the Depositor to decide whether staking is allowed.
|
|
33
|
+
* Returns various data
|
|
34
|
+
*/
|
|
35
|
+
async getOppStatus(): Promise<any> {
|
|
36
|
+
const depositor = this.contract.Depositor;
|
|
37
|
+
const opp = this.contract.OPP;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const oppAddress: string = await depositor.oppAddress();
|
|
41
|
+
const oppInboundAddress: string = await depositor.oppInboundAddress();
|
|
42
|
+
const prevEpochSent = await opp.prevEpochSent();
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const inbound = this.contractService.getReadOnly('OPPInbound');
|
|
46
|
+
|
|
47
|
+
// Query useful getters
|
|
48
|
+
const nextEpochBN: any = await inbound.nextEpochNum();
|
|
49
|
+
const pendingEpochRaw: any = await inbound.pendingEpoch();
|
|
50
|
+
const pendingMessageCount: any = await inbound.pendingMessageCount();
|
|
51
|
+
const previousEpochHash: string = await inbound.previousEpochHash();
|
|
52
|
+
const nextEpochNum = (nextEpochBN && typeof nextEpochBN.toNumber === 'function') ? nextEpochBN.toNumber() : Number(nextEpochBN || 0);
|
|
53
|
+
|
|
54
|
+
const pendingEpoch = (pendingEpochRaw && pendingEpochRaw.epochNumber !== undefined)
|
|
55
|
+
? {
|
|
56
|
+
epochNumber: (pendingEpochRaw.epochNumber && typeof pendingEpochRaw.epochNumber.toNumber === 'function') ? pendingEpochRaw.epochNumber.toNumber() : Number(pendingEpochRaw.epochNumber || 0),
|
|
57
|
+
timestamp: (pendingEpochRaw.timestamp && typeof pendingEpochRaw.timestamp.toNumber === 'function') ? pendingEpochRaw.timestamp.toNumber() : Number(pendingEpochRaw.timestamp || 0),
|
|
58
|
+
prevEpochHash: pendingEpochRaw.prevEpochHash,
|
|
59
|
+
merkleRoot: pendingEpochRaw.merkleRoot,
|
|
60
|
+
firstMessageID: pendingEpochRaw.firstMessageID,
|
|
61
|
+
lastMessageID: pendingEpochRaw.lastMessageID,
|
|
62
|
+
}
|
|
63
|
+
: null;
|
|
64
|
+
|
|
65
|
+
const pendingMessagesBN = pendingMessageCount;
|
|
66
|
+
const pendingMessages = (pendingMessagesBN && typeof pendingMessagesBN.toString === 'function') ? pendingMessagesBN.toString() : String(pendingMessagesBN || '0');
|
|
67
|
+
|
|
68
|
+
const hasPendingMessages = (pendingMessagesBN && typeof pendingMessagesBN.gt === 'function') ? pendingMessagesBN.gt(0) : (Number(pendingMessages) > 0);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
oppAddress,
|
|
72
|
+
prevEpochSent,
|
|
73
|
+
oppInboundAddress,
|
|
74
|
+
nextEpochNum,
|
|
75
|
+
pendingEpoch,
|
|
76
|
+
pendingMessageCount: pendingMessages,
|
|
77
|
+
previousEpochHash,
|
|
78
|
+
hasPendingMessages,
|
|
79
|
+
raw: {
|
|
80
|
+
nextEpochBN,
|
|
81
|
+
pendingEpochRaw,
|
|
82
|
+
pendingMessageCount: pendingMessagesBN,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
31
85
|
}
|
|
32
86
|
|
|
33
87
|
|
|
@@ -36,12 +90,17 @@ export class StakeClient {
|
|
|
36
90
|
* @param amountWei an amount of liqETH (in WEI) to stake to the Outpost
|
|
37
91
|
* @returns txHash (hash of the transaction), receipt, Staked event
|
|
38
92
|
*/
|
|
39
|
-
async performStake(amountWei: BigNumber, signerAddress: string): Promise<
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
93
|
+
async performStake(amountWei: BigNumber, signerAddress: string): Promise<any> {
|
|
94
|
+
const depositor = this.contract.Depositor.address;
|
|
95
|
+
const liqRead = this.contract.LiqEth;
|
|
96
|
+
const bal = await liqRead.balanceOf(signerAddress);
|
|
97
|
+
const allowance = await liqRead.allowance(signerAddress, depositor);
|
|
98
|
+
|
|
99
|
+
const paused = await this.contract.Depositor.paused();
|
|
100
|
+
if(paused) {
|
|
101
|
+
throw new Error("Error - Depositor is in a paused state");
|
|
102
|
+
}
|
|
103
|
+
|
|
45
104
|
|
|
46
105
|
// if allowance is less than the requested stake amount, request permission to spend LiqEth
|
|
47
106
|
if (allowance.lt(amountWei)) {
|
|
@@ -50,17 +109,20 @@ export class StakeClient {
|
|
|
50
109
|
// currently requested unlimited amount - potentially change to only request up to the current amount?
|
|
51
110
|
const approveAmount = ethers.constants.MaxUint256;
|
|
52
111
|
|
|
53
|
-
console.warn(`allowance insufficient (${allowance.toString()} < ${amountWei.toString()}); sending approve(${
|
|
54
|
-
const approveTx = await liqWrite.approve(
|
|
112
|
+
console.warn(`allowance insufficient (${allowance.toString()} < ${amountWei.toString()}); sending approve(${depositor}, ${approveAmount.toString()})`);
|
|
113
|
+
const approveTx = await liqWrite.approve(depositor, approveAmount);
|
|
55
114
|
await approveTx.wait(1);
|
|
56
115
|
|
|
57
116
|
// re-read allowance to ensure approval succeeded
|
|
58
|
-
const newAllowance = await
|
|
117
|
+
const newAllowance = await liqRead.allowance(signerAddress, depositor);
|
|
59
118
|
if (newAllowance.lt(amountWei)) {
|
|
60
119
|
throw new Error('Approval failed or allowance still insufficient after approve');
|
|
61
120
|
}
|
|
62
121
|
}
|
|
63
122
|
|
|
123
|
+
|
|
124
|
+
await this.simulateStake(amountWei);
|
|
125
|
+
|
|
64
126
|
|
|
65
127
|
// send the tx to stake liqeth
|
|
66
128
|
const tx = await this.contract.Depositor.stakeLiqETH(amountWei);
|
|
@@ -150,7 +212,6 @@ export class StakeClient {
|
|
|
150
212
|
for (const idBN of tokenIds) {
|
|
151
213
|
try {
|
|
152
214
|
const receiptData = await receiptContract.getReceipt(idBN);
|
|
153
|
-
|
|
154
215
|
const formattedReceipt = {
|
|
155
216
|
account: receiptData.account,
|
|
156
217
|
currency: receiptData.currency,
|
|
@@ -169,7 +230,8 @@ export class StakeClient {
|
|
|
169
230
|
timestamp: new Date(Number(receiptData.timestamp.toString()) * 1000).toLocaleString(),
|
|
170
231
|
}
|
|
171
232
|
|
|
172
|
-
|
|
233
|
+
// Only fetch staking receipts (kind 1 is a wire pretoken receipt)
|
|
234
|
+
if(receiptData.kind == 0) results.push({ tokenId: idBN.toBigInt(), receipt: formattedReceipt } as any);
|
|
173
235
|
} catch (err) {
|
|
174
236
|
// in case of any mismatch or race, just skip this id
|
|
175
237
|
console.warn(`Failed to load receipt for tokenId=${idBN.toString()}`, err);
|
|
@@ -177,6 +239,7 @@ export class StakeClient {
|
|
|
177
239
|
}
|
|
178
240
|
}
|
|
179
241
|
|
|
242
|
+
console.log('results of prelaunch receipts', results)
|
|
180
243
|
return results;
|
|
181
244
|
}
|
|
182
245
|
|
|
@@ -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,13 +18,9 @@ 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
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// import LiqEthCommonArtifact from '../../assets/ethereum/ABI/liqEth/liqEthCommon.sol/liqEthCommon.json';
|
|
27
|
-
// import RewardsERC20Artifact from '../../assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.json';
|
|
28
|
-
// import ValidatorBalanceArtifact from '../../assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json';
|
|
29
|
-
// import YieldArtifact from '../../assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json';
|
|
21
|
+
import PretokenArtifact from '../../assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.json';
|
|
22
|
+
import AggregatorArtifact from '../../assets/ethereum/ABI/outpost/Aggregator.sol/Aggregator.json';
|
|
23
|
+
import EthUsdPriceConsumerArtifact from '../../assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json';
|
|
30
24
|
|
|
31
25
|
import ERC20Artifact from '../../assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.json';
|
|
32
26
|
import ERC721Artifact from '../../assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.json';
|
|
@@ -47,23 +41,28 @@ export const ERC1155Abi = ERC1155Artifact.abi;
|
|
|
47
41
|
|
|
48
42
|
// Make sure ContractName in ./types includes all of these keys.
|
|
49
43
|
export const ADDRESSES: AddressBook = {
|
|
50
|
-
Accounting: "
|
|
51
|
-
DepositManager: "
|
|
52
|
-
LiqEth: "
|
|
53
|
-
StakingModule: "
|
|
54
|
-
WithdrawalQueue: "
|
|
55
|
-
WithdrawalVault: "
|
|
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",
|
|
56
54
|
|
|
57
|
-
|
|
58
55
|
//Outpost contracts
|
|
59
|
-
Depositor: "
|
|
60
|
-
ReceiptNFT: "
|
|
61
|
-
OutpostManager: "
|
|
62
|
-
BAR: "
|
|
63
|
-
OPP: "
|
|
64
|
-
OPPCommon: "
|
|
65
|
-
OPPInbound: "
|
|
66
|
-
|
|
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",
|
|
67
66
|
};
|
|
68
67
|
|
|
69
68
|
export type Contracts<T extends string = ContractName> = Record<T, ContractConfig>;
|
|
@@ -90,26 +89,10 @@ export const CONTRACTS: Contracts<ContractName> = {
|
|
|
90
89
|
address: ADDRESSES.DepositManager,
|
|
91
90
|
abi: DepositManagerArtifact.abi as JsonFragment[],
|
|
92
91
|
},
|
|
93
|
-
// LiqEthMint: {
|
|
94
|
-
// address: ADDRESSES.LiqEthMint,
|
|
95
|
-
// abi: LiqEthMintArtifact.abi as JsonFragment[],
|
|
96
|
-
// },
|
|
97
|
-
// LiqEthBurn: {
|
|
98
|
-
// address: ADDRESSES.LiqEthBurn,
|
|
99
|
-
// abi: LiqEthBurnArtifact.abi as JsonFragment[],
|
|
100
|
-
// },
|
|
101
|
-
// RewardsERC20: {
|
|
102
|
-
// address: ADDRESSES.RewardsERC20,
|
|
103
|
-
// abi: RewardsERC20Artifact.abi as JsonFragment[],
|
|
104
|
-
// },
|
|
105
92
|
StakingModule: {
|
|
106
93
|
address: ADDRESSES.StakingModule,
|
|
107
94
|
abi: StakingModuleArtifact.abi as JsonFragment[],
|
|
108
95
|
},
|
|
109
|
-
// ValidatorBalance: {
|
|
110
|
-
// address: ADDRESSES.ValidatorBalance,
|
|
111
|
-
// abi: ValidatorBalanceArtifact.abi as JsonFragment[],
|
|
112
|
-
// },
|
|
113
96
|
WithdrawalQueue: {
|
|
114
97
|
address: ADDRESSES.WithdrawalQueue,
|
|
115
98
|
abi: WithdrawalQueueArtifact.abi as JsonFragment[],
|
|
@@ -118,11 +101,6 @@ export const CONTRACTS: Contracts<ContractName> = {
|
|
|
118
101
|
address: ADDRESSES.WithdrawalVault,
|
|
119
102
|
abi: WithdrawalVaultArtifact.abi as JsonFragment[],
|
|
120
103
|
},
|
|
121
|
-
// Yield: {
|
|
122
|
-
// address: ADDRESSES.Yield,
|
|
123
|
-
// abi: YieldArtifact.abi as JsonFragment[],
|
|
124
|
-
// },
|
|
125
|
-
|
|
126
104
|
|
|
127
105
|
// Outpost Contracts
|
|
128
106
|
Depositor: {
|
|
@@ -153,9 +131,17 @@ export const CONTRACTS: Contracts<ContractName> = {
|
|
|
153
131
|
address: ADDRESSES.OPPInbound,
|
|
154
132
|
abi: OPPInboundArtifact.abi as JsonFragment[],
|
|
155
133
|
},
|
|
156
|
-
|
|
157
|
-
address: ADDRESSES.
|
|
158
|
-
abi:
|
|
134
|
+
Pretoken: {
|
|
135
|
+
address: ADDRESSES.Pretoken,
|
|
136
|
+
abi: PretokenArtifact.abi as JsonFragment[],
|
|
137
|
+
},
|
|
138
|
+
Aggregator: {
|
|
139
|
+
address: ADDRESSES.Aggregator,
|
|
140
|
+
abi: AggregatorArtifact.abi as JsonFragment[],
|
|
141
|
+
},
|
|
142
|
+
EthUsdPriceConsumer: {
|
|
143
|
+
address: ADDRESSES.EthUsdPriceConsumer,
|
|
144
|
+
abi: EthUsdPriceConsumerArtifact.abi as JsonFragment[],
|
|
159
145
|
}
|
|
160
146
|
};
|
|
161
147
|
|