Skip to content

Commit

Permalink
feat(scripts): add Disputer WithdrawFunds script
Browse files Browse the repository at this point in the history
  • Loading branch information
nlecoufl committed Dec 4, 2024
1 parent c89070c commit 91de161
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions scripts/Disputer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,33 @@ contract FundDisputer is DisputerScript {
disputeToken.transfer(disputerAddress, _amountToFund);
}
}

contract WithdrawFunds is DisputerScript {
function run() external {
// MODIFY THESE VALUES TO SET THE WITHDRAWAL PARAMETERS
address asset = address(0); // Use address(0) for ETH, or token address for ERC20
uint256 amountToWithdraw = 100 * 10 ** 6; // Adjust decimals according to asset
address recipient = address(0); // Set the recipient address
_run(asset, recipient, amountToWithdraw);
}

function run(address asset, address recipient, uint256 amountToWithdraw) external {
_run(asset, recipient, amountToWithdraw);
}

function _run(address asset, address to, uint256 _amountToWithdraw) internal broadcast {
uint256 chainId = block.chainid;
address disputerAddress = readAddress(chainId, "Merkl.Disputer");
Disputer disputer = Disputer(disputerAddress);

if (asset == address(0)) {
// Withdraw ETH
disputer.withdrawFunds(payable(to), _amountToWithdraw);
console.log("Withdrew %s ETH to %s", _amountToWithdraw, to);
} else {
// Withdraw ERC20 token
disputer.withdrawFunds(asset, to, _amountToWithdraw);
console.log("Withdrew %s %s to %s", _amountToWithdraw, asset, to);
}
}
}

0 comments on commit 91de161

Please sign in to comment.