-
-
Save akolotov/faffde298b0fb678ac2d045587fcf257 to your computer and use it in GitHub Desktop.
Foundry Script for verification of Direct Deposit queue parameters changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: CC0-1.0 | |
| pragma solidity 0.8.15; | |
| import "forge-std/Script.sol"; | |
| import "../../src/zkbob/ZkBobDirectDepositQueueETH.sol"; | |
| import "../../src/zkbob/ZkBobPoolETH.sol"; | |
| import "../../src/interfaces/IBatchDepositVerifier.sol"; | |
| import "../../src/interfaces/ITreeVerifier.sol"; | |
| contract DDConfigUpdateVerification is Script { | |
| IERC20 token = IERC20(0x4200000000000000000000000000000000000006); | |
| ZkBobPoolETH pool = ZkBobPoolETH(payable(0x58320A55bbc5F89E5D0c92108F762Ac0172C5992)); | |
| ZkBobDirectDepositQueueETH dd_queue = ZkBobDirectDepositQueueETH(0x318e2C1f5f6Ac4fDD5979E73D498342B255fC869); | |
| address sender = address(0x39F0bD56c1439a22Ee90b4972c16b7868D161981); | |
| address governance = address(0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290); | |
| address operator = address(0x65Eb51b16678d57Bb0bB8d160D1b9D0a57880512); | |
| address fee_recipient = address(0xa022d235755D25fC2B7335ceCBD08A8658d07333); | |
| function run() external { | |
| IBatchDepositVerifier dd_verifier = pool.batch_deposit_verifier(); | |
| ITreeVerifier tree_verifier = pool.tree_verifier(); | |
| vm.startPrank(governance); | |
| dd_queue.setDirectDepositTimeout(86400); | |
| dd_queue.setDirectDepositFee(200000); | |
| vm.stopPrank(); | |
| string memory zkaddr = "PQV2e7adSmwA4ez5T6jcX12VQt8CscU4NWkDPLtYPiFpV57BBDLha394H7BUwdD"; | |
| vm.mockCall(address(dd_verifier), abi.encodeWithSelector(dd_verifier.verifyProof.selector), abi.encode(true)); | |
| vm.mockCall(address(tree_verifier), abi.encodeWithSelector(tree_verifier.verifyProof.selector), abi.encode(true)); | |
| vm.startPrank(sender); | |
| dd_queue.directNativeDeposit{value: 10_000_000_000_000_000}(sender, zkaddr); | |
| vm.stopPrank(); | |
| uint256[8] memory proof = [uint256(0), uint256(0), uint256(0), uint256(0), uint256(0), uint256(0), uint256(0), uint256(0)]; | |
| uint256[] memory indices = new uint256[](1); | |
| indices[0] = 0; | |
| // check that 0.2 finney is collected as fees | |
| vm.startPrank(operator); | |
| pool.withdrawFee(operator, fee_recipient); | |
| uint256 prev_balance = token.balanceOf(fee_recipient); | |
| pool.appendDirectDeposits(uint256(0xcafe), indices, uint256(0xdead), proof, proof); | |
| pool.withdrawFee(operator, fee_recipient); | |
| uint256 cur_balance = token.balanceOf(fee_recipient); | |
| require(cur_balance - prev_balance == 200_000 gwei, "Incorrect amount of collected fees"); | |
| vm.stopPrank(); | |
| // check that refund is not possible before timeout exceeds | |
| vm.startPrank(sender); | |
| dd_queue.directNativeDeposit{value: 10_000_000_000_000_000}(sender, zkaddr); | |
| vm.warp(block.timestamp + 1); | |
| vm.expectRevert("ZkBobDirectDepositQueue: direct deposit timeout not passed"); | |
| dd_queue.refundDirectDeposit(1); | |
| vm.warp(block.timestamp + 86400); | |
| dd_queue.refundDirectDeposit(1); | |
| vm.stopPrank(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment