-
Notifications
You must be signed in to change notification settings - Fork 22
Add Kicker #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Kicker #32
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0780c50
Add Kicker
sunbreak1211 d5d4ffd
Minor changes and changes for oracle wrapper test to not fail
sunbreak1211 8e97db1
Fix init script + tests changes
sunbreak1211 499f926
Minor changes to tests
sunbreak1211 a75d34d
Update src/Kicker.sol
sunbreak1211 0677919
Minor changes
sunbreak1211 d9bed0e
Add README
sunbreak1211 67c200b
Minor changes
sunbreak1211 73bdaed
Add note to REAME
sunbreak1211 f4f4f22
Fix typos
sunbreak1211 641e7b7
Add audit reports
sunbreak1211 d596307
Enforce evmVersion in foundry.toml
sunbreak1211 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| // SPDX-FileCopyrightText: © 2025 Dai Foundation <www.daifoundation.org> | ||
| // SPDX-License-Identifier: AGPL-3.0-or-later | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| pragma solidity ^0.8.21; | ||
|
|
||
| interface VatLike { | ||
| function dai(address) external view returns (uint256); | ||
| function sin(address) external view returns (uint256); | ||
| function hope(address) external; | ||
| function suck(address, address, uint256) external; | ||
| } | ||
|
|
||
| interface SplitterLike { | ||
| function vat() external view returns (VatLike); | ||
| function kick(uint256, uint256) external returns (uint256); | ||
| } | ||
|
|
||
| contract Kicker { | ||
| // --- storage variables --- | ||
|
|
||
| mapping(address usr => uint256 allowed) public wards; | ||
| uint256 public kbump; // Fixed lot size [rad] | ||
| int256 public khump; // Flap threshold [rad] | ||
|
|
||
| // --- immutables --- | ||
|
|
||
| VatLike public immutable vat; | ||
| address public immutable vow; | ||
| SplitterLike public immutable splitter; | ||
|
|
||
| // --- constructor --- | ||
|
|
||
| constructor(address vow_, address splitter_) { | ||
| vow = vow_; | ||
| splitter = SplitterLike(splitter_); | ||
| vat = splitter.vat(); | ||
| vat.hope(splitter_); | ||
|
|
||
| wards[msg.sender] = 1; | ||
| emit Rely(msg.sender); | ||
| } | ||
|
|
||
| // --- events --- | ||
|
|
||
| event Rely(address indexed usr); | ||
| event Deny(address indexed usr); | ||
| event File(bytes32 indexed what, uint256 data); | ||
| event File(bytes32 indexed what, int256 data); | ||
|
|
||
| // --- modifiers --- | ||
|
|
||
| modifier auth { | ||
| require(wards[msg.sender] == 1, "Kicker/not-authorized"); | ||
| _; | ||
| } | ||
|
|
||
| // --- internals --- | ||
|
|
||
| function _toInt256(uint256 x) internal pure returns (int256 y) { | ||
| require(x <= uint256(type(int256).max), "Kicker/overflow"); | ||
| y = int256(x); | ||
| } | ||
|
|
||
| // --- administration --- | ||
|
|
||
| function rely(address usr) external auth { | ||
| wards[usr] = 1; | ||
| emit Rely(usr); | ||
| } | ||
|
|
||
| function deny(address usr) external auth { | ||
| wards[usr] = 0; | ||
| emit Deny(usr); | ||
| } | ||
|
|
||
| function file(bytes32 what, uint256 data) external auth { | ||
| if (what == "kbump") { | ||
| kbump = data; | ||
| } else revert("Kicker/file-unrecognized-param"); | ||
| emit File(what, data); | ||
| } | ||
|
|
||
| function file(bytes32 what, int256 data) external auth { | ||
| if (what == "khump") { | ||
| khump = data; | ||
| } else revert("Kicker/file-unrecognized-param"); | ||
| emit File(what, data); | ||
| } | ||
|
|
||
| // --- execution --- | ||
|
|
||
| function flap() external returns (uint256 id) { | ||
oldchili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| require(_toInt256(vat.dai(vow)) >= _toInt256(vat.sin(vow)) + _toInt256(kbump) + khump, "Kicker/flap-threshold-not-reached"); | ||
| vat.suck(vow, address(this), kbump); | ||
| id = splitter.kick(kbump, 0); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.