|  | 
|  | 1 | +// SPDX-FileCopyrightText: © 2025 Dai Foundation <www.daifoundation.org> | 
|  | 2 | +// SPDX-License-Identifier: AGPL-3.0-or-later | 
|  | 3 | +// | 
|  | 4 | +// This program is free software: you can redistribute it and/or modify | 
|  | 5 | +// it under the terms of the GNU Affero General Public License as published by | 
|  | 6 | +// the Free Software Foundation, either version 3 of the License, or | 
|  | 7 | +// (at your option) any later version. | 
|  | 8 | +// | 
|  | 9 | +// This program is distributed in the hope that it will be useful, | 
|  | 10 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 11 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 12 | +// GNU Affero General Public License for more details. | 
|  | 13 | +// | 
|  | 14 | +// You should have received a copy of the GNU Affero General Public License | 
|  | 15 | +// along with this program.  If not, see <https://www.gnu.org/licenses/>. | 
|  | 16 | + | 
|  | 17 | +pragma solidity ^0.8.21; | 
|  | 18 | + | 
|  | 19 | +interface VatLike { | 
|  | 20 | +    function dai(address) external view returns (uint256); | 
|  | 21 | +    function sin(address) external view returns (uint256); | 
|  | 22 | +    function hope(address) external; | 
|  | 23 | +    function suck(address, address, uint256) external; | 
|  | 24 | +} | 
|  | 25 | + | 
|  | 26 | +interface VowLike { | 
|  | 27 | +    function Sin() external view returns (uint256); | 
|  | 28 | +    function Ash() external view returns (uint256); | 
|  | 29 | +} | 
|  | 30 | + | 
|  | 31 | +interface SplitterLike { | 
|  | 32 | +    function kick(uint256, uint256) external returns (uint256); | 
|  | 33 | +} | 
|  | 34 | + | 
|  | 35 | +contract Kicker { | 
|  | 36 | +    // --- storage variables --- | 
|  | 37 | + | 
|  | 38 | +    mapping(address usr => uint256 allowed) public wards; | 
|  | 39 | +    uint256 public kbump; | 
|  | 40 | +    int256  public khump; | 
|  | 41 | + | 
|  | 42 | +    // --- immutables --- | 
|  | 43 | + | 
|  | 44 | +    VatLike      public immutable vat; | 
|  | 45 | +    VowLike      public immutable vow; | 
|  | 46 | +    SplitterLike public immutable splitter; | 
|  | 47 | + | 
|  | 48 | +    // --- immutables --- | 
|  | 49 | + | 
|  | 50 | +    constructor(address vat_, address vow_, address splitter_) { | 
|  | 51 | +        vat = VatLike(vat_); | 
|  | 52 | +        vow = VowLike(vow_); | 
|  | 53 | +        splitter = SplitterLike(splitter_); | 
|  | 54 | +        vat.hope(splitter_); | 
|  | 55 | + | 
|  | 56 | +        wards[msg.sender] = 1; | 
|  | 57 | +        emit Rely(msg.sender); | 
|  | 58 | +    } | 
|  | 59 | + | 
|  | 60 | +    // --- events --- | 
|  | 61 | + | 
|  | 62 | +    event Rely(address indexed usr); | 
|  | 63 | +    event Deny(address indexed usr); | 
|  | 64 | +    event File(bytes32 indexed what, uint256 data); | 
|  | 65 | +    event File(bytes32 indexed what, int256 data); | 
|  | 66 | + | 
|  | 67 | +    // --- modifiers --- | 
|  | 68 | + | 
|  | 69 | +    modifier auth { | 
|  | 70 | +        require(wards[msg.sender] == 1, "Kicker/not-authorized"); | 
|  | 71 | +        _; | 
|  | 72 | +    } | 
|  | 73 | + | 
|  | 74 | +    // --- internals --- | 
|  | 75 | + | 
|  | 76 | +    function _toInt256(uint256 x) internal pure returns (int256 y) { | 
|  | 77 | +        require(x <= uint256(type(int256).max), "Kicker/overflow"); | 
|  | 78 | +        y = int256(x); | 
|  | 79 | +    } | 
|  | 80 | + | 
|  | 81 | +    // --- administration --- | 
|  | 82 | + | 
|  | 83 | +    function rely(address usr) external auth { | 
|  | 84 | +        wards[usr] = 1; | 
|  | 85 | +        emit Rely(usr); | 
|  | 86 | +    } | 
|  | 87 | + | 
|  | 88 | +    function deny(address usr) external auth { | 
|  | 89 | +        wards[usr] = 0; | 
|  | 90 | +        emit Deny(usr); | 
|  | 91 | +    } | 
|  | 92 | + | 
|  | 93 | +    function file(bytes32 what, uint256 data) external auth { | 
|  | 94 | +        if (what == "kbump") { | 
|  | 95 | +            kbump = data; | 
|  | 96 | +        } else revert("Kicker/file-unrecognized-param"); | 
|  | 97 | +        emit File(what, data); | 
|  | 98 | +    } | 
|  | 99 | + | 
|  | 100 | +    function file(bytes32 what, int256 data) external auth { | 
|  | 101 | +        if (what == "khump") { | 
|  | 102 | +            khump = data; | 
|  | 103 | +        } else revert("Kicker/file-unrecognized-param"); | 
|  | 104 | +        emit File(what, data); | 
|  | 105 | +    } | 
|  | 106 | + | 
|  | 107 | +    // --- execution --- | 
|  | 108 | + | 
|  | 109 | +    function flap() external returns (uint256 id) { | 
|  | 110 | +        require(_toInt256(vat.dai(address(vow))) >= _toInt256(vat.sin(address(vow))) + _toInt256(kbump) + khump, "Kicker/insufficient-allowance"); | 
|  | 111 | +        // require(vat.sin(address(vow)) - vow.Sin() - vow.Ash() == 0 || vat.dai(address(vow)) == 0 , "Kicker/not-healed"); | 
|  | 112 | +        vat.suck(address(vow), address(this), kbump); | 
|  | 113 | +        id = splitter.kick(kbump, 0); | 
|  | 114 | +    } | 
|  | 115 | +} | 
0 commit comments