Commit 189fa9d7 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: delete `CheckBalanceHigh` dripcheck

This dripcheck is not used anywhere so no need to keep it around
and add time to building and testing.
parent c4d9b85e
...@@ -12,7 +12,6 @@ import { Proxy } from "src/universal/Proxy.sol"; ...@@ -12,7 +12,6 @@ import { Proxy } from "src/universal/Proxy.sol";
import { Faucet } from "src/periphery/faucet/Faucet.sol"; import { Faucet } from "src/periphery/faucet/Faucet.sol";
import { Drippie } from "src/periphery/drippie/Drippie.sol"; import { Drippie } from "src/periphery/drippie/Drippie.sol";
import { CheckGelatoLow } from "src/periphery/drippie/dripchecks/CheckGelatoLow.sol"; import { CheckGelatoLow } from "src/periphery/drippie/dripchecks/CheckGelatoLow.sol";
import { CheckBalanceHigh } from "src/periphery/drippie/dripchecks/CheckBalanceHigh.sol";
import { CheckBalanceLow } from "src/periphery/drippie/dripchecks/CheckBalanceLow.sol"; import { CheckBalanceLow } from "src/periphery/drippie/dripchecks/CheckBalanceLow.sol";
import { CheckTrue } from "src/periphery/drippie/dripchecks/CheckTrue.sol"; import { CheckTrue } from "src/periphery/drippie/dripchecks/CheckTrue.sol";
import { AdminFaucetAuthModule } from "src/periphery/faucet/authmodules/AdminFaucetAuthModule.sol"; import { AdminFaucetAuthModule } from "src/periphery/faucet/authmodules/AdminFaucetAuthModule.sol";
...@@ -62,7 +61,6 @@ contract DeployPeriphery is Deployer { ...@@ -62,7 +61,6 @@ contract DeployPeriphery is Deployer {
deployFaucetDrippie(); deployFaucetDrippie();
deployCheckTrue(); deployCheckTrue();
deployCheckBalanceLow(); deployCheckBalanceLow();
deployCheckBalanceHigh();
deployCheckGelatoLow(); deployCheckGelatoLow();
deployOnChainAuthModule(); deployOnChainAuthModule();
deployOffChainAuthModule(); deployOffChainAuthModule();
...@@ -199,25 +197,6 @@ contract DeployPeriphery is Deployer { ...@@ -199,25 +197,6 @@ contract DeployPeriphery is Deployer {
} }
} }
/// @notice Deploy CheckBalanceHigh contract.
function deployCheckBalanceHigh() public broadcast returns (address addr_) {
bytes32 salt = keccak256(bytes("CheckBalanceHigh"));
bytes32 initCodeHash = keccak256(abi.encodePacked(type(CheckBalanceHigh).creationCode));
address preComputedAddress = computeCreate2Address(salt, initCodeHash);
if (preComputedAddress.code.length > 0) {
console.log("CheckBalanceHigh already deployed at %s", preComputedAddress);
save("CheckBalanceHigh", preComputedAddress);
addr_ = preComputedAddress;
} else {
CheckBalanceHigh checkBalanceHigh = new CheckBalanceHigh{ salt: salt }();
save("CheckBalanceHigh", address(checkBalanceHigh));
console.log("CheckBalanceHigh deployed at %s", address(checkBalanceHigh));
addr_ = address(checkBalanceHigh);
}
}
/// @notice Deploy CheckGelatoLow contract. /// @notice Deploy CheckGelatoLow contract.
function deployCheckGelatoLow() public broadcast returns (address addr_) { function deployCheckGelatoLow() public broadcast returns (address addr_) {
bytes32 salt = keccak256(bytes("CheckGelatoLow")); bytes32 salt = keccak256(bytes("CheckGelatoLow"));
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { IDripCheck } from "../IDripCheck.sol";
/// @title CheckBalanceHigh
/// @notice DripCheck for checking if an account's balance is above a given threshold.
contract CheckBalanceHigh is IDripCheck {
struct Params {
address target;
uint256 threshold;
}
/// @notice External event used to help client-side tooling encode parameters.
/// @param params Parameters to encode.
event _EventToExposeStructInABI__Params(Params params);
/// @inheritdoc IDripCheck
function check(bytes memory _params) external view returns (bool execute_) {
Params memory params = abi.decode(_params, (Params));
// Check target balance is above threshold.
execute_ = params.target.balance > params.threshold;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { CheckBalanceHigh } from "src/periphery/drippie/dripchecks/CheckBalanceHigh.sol";
/// @title CheckBalanceHighTest
/// @notice Tests the CheckBalanceHigh contract via fuzzing both the success case
/// and the failure case.
contract CheckBalanceHighTest is Test {
/// @notice An instance of the CheckBalanceHigh contract.
CheckBalanceHigh c;
/// @notice Deploy the `CheckTrue` contract.
function setUp() external {
c = new CheckBalanceHigh();
}
/// @notice Fuzz the `check` function and assert that it always returns true
/// when the target's balance is larger than the threshold.
function testFuzz_check_succeeds(address _target, uint256 _threshold) external {
CheckBalanceHigh.Params memory p = CheckBalanceHigh.Params({ target: _target, threshold: _threshold });
// prevent overflows
vm.assume(_threshold != type(uint256).max);
vm.deal(_target, _threshold + 1);
assertEq(c.check(abi.encode(p)), true);
}
/// @notice Fuzz the `check` function and assert that it always returns false
/// when the target's balance is smaller than the threshold.
function testFuzz_check_lowBalance_fails(address _target, uint256 _threshold) external {
CheckBalanceHigh.Params memory p = CheckBalanceHigh.Params({ target: _target, threshold: _threshold });
vm.assume(_target.balance < _threshold);
assertEq(c.check(abi.encode(p)), false);
}
}
...@@ -20,7 +20,7 @@ contract MockGelatoTreasury is IGelatoTreasury { ...@@ -20,7 +20,7 @@ contract MockGelatoTreasury is IGelatoTreasury {
} }
/// @title CheckGelatoLowTest /// @title CheckGelatoLowTest
/// @notice Tests the CheckBalanceHigh contract via fuzzing both the success case /// @notice Tests the CheckGelatoLow contract via fuzzing both the success case
/// and the failure case. /// and the failure case.
contract CheckGelatoLowTest is Test { contract CheckGelatoLowTest is Test {
/// @notice An instance of the CheckGelatoLow contract. /// @notice An instance of the CheckGelatoLow contract.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment