diff --git a/proposals/dao/tokemak_withdraw.ts b/proposals/dao/tokemak_withdraw.ts index fe631ded2..f6b2be033 100644 --- a/proposals/dao/tokemak_withdraw.ts +++ b/proposals/dao/tokemak_withdraw.ts @@ -45,34 +45,8 @@ const teardown: TeardownUpgradeFunc = async (addresses, oldContracts, contracts, // Run any validations required on the fip using mocha or console logging // IE check balances, check state of contracts, etc. const validate: ValidateUpgradeFunc = async (addresses, oldContracts, contracts, logging) => { - const ethTokemakPCVDeposit = contracts.ethTokemakPCVDeposit; - - // Validate that DAO can withdraw funds in the next cycle - // impersonate the rollover signer, and make the Tokemak pool go to next cycle - await forceEth(addresses.tokemakManagerRollover); - const tokemakRolloverSigner = await getImpersonatedSigner(addresses.tokemakManagerRollover); - const tokemakManagerAbi = [ - 'function nextCycleStartTime() view returns (uint256)', - 'function completeRollover(string calldata rewardsIpfsHash)' - ]; - const tokemakManager = new ethers.Contract(addresses.tokemakManager, tokemakManagerAbi, tokemakRolloverSigner); - const cycleEnd = await tokemakManager.nextCycleStartTime(); - await time.increaseTo(cycleEnd + 1); - await tokemakManager.completeRollover(IPFS_JSON_FILE_HASH); - - // Perform withdraw - await ethTokemakPCVDeposit.withdraw(ethTokemakPCVDeposit.address, ethers.constants.WeiPerEther.mul(10_000)); - - // Should end with 0 tWETH, 10k ETH - expect((await contracts.tWETH.balanceOf(ethTokemakPCVDeposit.address)).toString()).to.be.equal( - ethers.utils.parseEther('0') - ); - expect((await ethers.provider.getBalance(ethTokemakPCVDeposit.address)).toString()).to.be.equal( - ethers.utils.parseEther('10000') - ); - - // Then re-deposit, to clean up state for e2e tests - await ethTokemakPCVDeposit.deposit(); + console.log(`No actions to complete in validate for fip${fipNumber}`); + // Validation performed in e2e test }; export { deploy, setup, teardown, validate }; diff --git a/test/integration/tests/fip-38-tokemak.ts b/test/integration/tests/fip-38-tokemak.ts index 1f24bd066..45c3c87f0 100644 --- a/test/integration/tests/fip-38-tokemak.ts +++ b/test/integration/tests/fip-38-tokemak.ts @@ -46,22 +46,56 @@ describe('e2e-fip-38-tokemak', function () { doLogging && console.log(`Environment loaded.`); }); - it('should have deposited ETH, and be able to withdraw', async function () { + it('should be able to withdraw ETH', async function () { const { ethTokemakPCVDeposit, tWETH // Tokemak ETH reactor } = contracts; - // we should start with 10k tWETH, 0 ETH - expect((await tWETH.balanceOf(ethTokemakPCVDeposit.address)).toString()).to.be.equal( + // impersonate the rollover signer, and make the Tokemak pool go to next cycle + await forceEth(TOKEMAK_MANAGER_ROLLOVER_ADDRESS); + const tokemakRolloverSigner = await getImpersonatedSigner(TOKEMAK_MANAGER_ROLLOVER_ADDRESS); + const tokemakManagerAbi = [ + 'function nextCycleStartTime() view returns (uint256)', + 'function completeRollover(string calldata rewardsIpfsHash)' + ]; + const tokemakManager = new ethers.Contract(TOKEMAK_MANAGER_ADDRESS, tokemakManagerAbi, tokemakRolloverSigner); + const cycleEnd = await tokemakManager.nextCycleStartTime(); + await time.increaseTo(cycleEnd + 1); + await tokemakManager.completeRollover(IPFS_JSON_FILE_HASH); + + // Perform withdraw + await ethTokemakPCVDeposit.withdraw(ethTokemakPCVDeposit.address, tenPow18.mul(toBN(10_000))); + + // Should end with 0 tWETH, 10k ETH + expect((await tWETH.balanceOf(ethTokemakPCVDeposit.address)).toString()).to.be.equal(ethers.utils.parseEther('0')); + expect((await ethers.provider.getBalance(ethTokemakPCVDeposit.address)).toString()).to.be.equal( ethers.utils.parseEther('10000') ); + }); + + it('should be able to deposit and then withdraw ETH', async function () { + const { + ethTokemakPCVDeposit, + tWETH // Tokemak ETH reactor + } = contracts; + + // Starting state: 10k tETH, 0 WETH + // Want to transfer ETH, and deposit. Then verify deposit and then withdraw + const ethWhaleSigner = await getImpersonatedSigner('0x73BCEb1Cd57C711feaC4224D062b0F6ff338501e'); + await ethWhaleSigner.sendTransaction({ to: ethTokemakPCVDeposit.address, value: ethers.utils.parseEther('10000') }); + await ethTokemakPCVDeposit.deposit(); + + // Now has 20k tETH, 0k WETH + expect((await tWETH.balanceOf(ethTokemakPCVDeposit.address)).toString()).to.be.equal( + ethers.utils.parseEther('20000') + ); expect((await ethers.provider.getBalance(ethTokemakPCVDeposit.address)).toString()).to.be.equal( ethers.utils.parseEther('0') ); - // request to withdraw 10k ETH - await ethTokemakPCVDeposit.requestWithdrawal(tenPow18.mul(toBN(10_000))); + // request to withdraw 20k ETH + await ethTokemakPCVDeposit.requestWithdrawal(tenPow18.mul(toBN(20_000))); // impersonate the rollover signer, and make the Tokemak pool go to next cycle await forceEth(TOKEMAK_MANAGER_ROLLOVER_ADDRESS); @@ -76,12 +110,12 @@ describe('e2e-fip-38-tokemak', function () { await tokemakManager.completeRollover(IPFS_JSON_FILE_HASH); // Perform withdraw - await ethTokemakPCVDeposit.withdraw(ethTokemakPCVDeposit.address, tenPow18.mul(toBN(10_000))); + await ethTokemakPCVDeposit.withdraw(ethTokemakPCVDeposit.address, tenPow18.mul(toBN(20_000))); // Should end with 0 tWETH, 10k ETH expect((await tWETH.balanceOf(ethTokemakPCVDeposit.address)).toString()).to.be.equal(ethers.utils.parseEther('0')); expect((await ethers.provider.getBalance(ethTokemakPCVDeposit.address)).toString()).to.be.equal( - ethers.utils.parseEther('10000') + ethers.utils.parseEther('20000') ); }); });