Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
696ca56e
Commit
696ca56e
authored
Mar 24, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: fee vault withdrawal script
parent
9bc5135f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
+86
-0
README.md
packages/contracts-bedrock/README.md
+5
-0
FeeVaultWithdrawal.s.sol
packages/contracts-bedrock/scripts/FeeVaultWithdrawal.s.sol
+81
-0
No files found.
packages/contracts-bedrock/README.md
View file @
696ca56e
...
@@ -244,3 +244,8 @@ Test contracts should be named one of the following according to their use:
...
@@ -244,3 +244,8 @@ Test contracts should be named one of the following according to their use:
-
`TargetContract_Init`
for contracts that perform basic setup to be reused in other test contracts.
-
`TargetContract_Init`
for contracts that perform basic setup to be reused in other test contracts.
-
`TargetContract_Function_Test`
for contracts containing happy path tests for a given function.
-
`TargetContract_Function_Test`
for contracts containing happy path tests for a given function.
-
`TargetContract_Function_TestFail`
for contracts containing sad path tests for a given function.
-
`TargetContract_Function_TestFail`
for contracts containing sad path tests for a given function.
## Withdrawaing From Fee Vaults
See the file
`scripts/FeeVaultWithdrawal.s.sol`
to withdraw from the L2 fee vaults. It includes
instructions on how to run it.
`foundry`
is required.
packages/contracts-bedrock/scripts/FeeVaultWithdrawal.s.sol
0 → 100644
View file @
696ca56e
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { console } from "forge-std/console.sol";
import { Script } from "forge-std/Script.sol";
import { Predeploys } from "../contracts/libraries/Predeploys.sol";
import { FeeVault } from "../contracts/universal/FeeVault.sol";
import { IMulticall3 } from "forge-std/interfaces/IMulticall3.sol";
/**
* @title FeeVaultWithdrawal
* @notice A script to make it very simple to withdraw from the fee vaults.
* The usage is as follows:
* $ forge script scripts/FeeVaultWithdrawal.s.sol \
* --rpc-url $OPTI_GOERLI_RPC_URL --broadcast \
* --private-key $PRIVATE_KEY
*/
contract FeeVaultWithdrawal is Script {
IMulticall3 private constant multicall = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11);
IMulticall3.Call3[] internal calls;
/**
* @notice The entrypoint function. Determines which FeeVaults can be withdrawn from and then
* will send the transaction via Multicall3 to withdraw all FeeVaults.
*/
function run() external {
require(address(multicall).code.length > 0);
address[] memory vaults = new address[](3);
vaults[0] = Predeploys.SEQUENCER_FEE_WALLET;
vaults[1] = Predeploys.BASE_FEE_VAULT;
vaults[2] = Predeploys.L1_FEE_VAULT;
for (uint256 i; i < vaults.length; i++) {
address vault = vaults[i];
bool shouldCall = canWithdrawal(vault);
if (shouldCall) {
calls.push(IMulticall3.Call3({
target: vault,
allowFailure: false,
callData: abi.encodeWithSelector(FeeVault.withdraw.selector)
}));
address recipient = FeeVault(payable(vault)).RECIPIENT();
uint256 balance = vault.balance;
log(balance, recipient, vault);
}
}
if (calls.length > 0) {
vm.broadcast();
IMulticall3.Result[] memory results = multicall.aggregate3(calls);
console.log("Success");
}
}
/**
* @notice Checks whether or not a FeeVault can be withdrawn. The balance of the account must
* be larger than the `MIN_WITHDRAWAL_AMOUNT`.
*/
function canWithdrawal(address _vault) internal view returns (bool) {
uint256 minWithdrawalAmount = FeeVault(payable(_vault)).MIN_WITHDRAWAL_AMOUNT();
uint256 balance = _vault.balance;
return balance >= minWithdrawalAmount;
}
/**
* @notice Logs the information relevant to the user.
*/
function log(uint256 _balance, address _recipient, address _vault) internal view {
string memory logline = string.concat(
"Withdrawaing ",
vm.toString(_balance),
" to ",
vm.toString(_recipient),
" from ",
vm.toString(_vault)
);
console.log(logline);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment