Address Contract Partially Verified
Address
0x30784615252B13E1DbE2bDf598627eaC297Bf4C5
Balance
0 ETH
Nonce
1
Code Size
6211 bytes
Creator
0x54eAde20...039e at tx 0x232641eb...1e5f08
Indexed Transactions
0
Contract Bytecode
6211 bytes
0x608060405234801561000f575f80fd5b5060043610610127575f3560e01c806365fae35e116100a9578063bf353dbb1161006e578063bf353dbb14610325578063c5ce281e14610344578063cfc4af551461036b578063f29c29c41461039d578063fee4412f146103b0575f80fd5b806365fae35e1461028757806384718d891461029a57806389afb88a146102c15780639c3674fc146102f35780639c52a7f114610312575f80fd5b806329ae8114116100ef57806329ae81141461020b57806353a7d8cd1461021e5780635e2e013e1461023d578063606ce3bf1461026157806365c4ce7a14610274575f80fd5b806308b368701461012b5780630aebbede1461016f5780631a0b287e146101965780631aeba947146101ab57806323548b8b146101f4575b5f80fd5b6101527f000000000000000000000000ea91a18dafa1cb1d2a19dfb205816034e6fe7e5281565b6040516001600160a01b0390911681526020015b60405180910390f35b6101527f00000000000000000000000099cd4ec3f88a45940936f469e4bb72a2a701eeb981565b6101a96101a43660046116a4565b6103b9565b005b6002546101cf9061ffff808216916201000081048216916401000000009091041683565b6040805161ffff94851681529284166020840152921691810191909152606001610166565b6101fd60055481565b604051908152602001610166565b6101a96102193660046116cd565b61069d565b6101fd61022c3660046116ed565b60016020525f908152604090205481565b6003546101cf9061ffff808216916201000081048216916401000000009091041683565b6101a961026f36600461171a565b6109da565b6101a96102823660046116ed565b611218565b6101a96102953660046116ed565b611289565b6101527f00000000000000000000000019c0976f590d67707e62397c87829d896dc0f1f181565b6006546102db90600160481b90046001600160801b031681565b6040516001600160801b039091168152602001610166565b6006546103009060ff1681565b60405160ff9091168152602001610166565b6101a96103203660046116ed565b6112fb565b6101fd6103333660046116ed565b5f6020819052908152604090205481565b6101fd7f4c534556322d534b592d4100000000000000000000000000000000000000000081565b60065461038490610100900467ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610166565b6101a96103ab3660046116ed565b61136c565b6101fd60045481565b335f908152602081905260409020546001146103f05760405162461bcd60e51b81526004016103e790611749565b60405180910390fd5b5f836229aa2960e91b036104065750600261048b565b7f4c534556322d534b592d4100000000000000000000000000000000000000000084036104355750600361048b565b60405162461bcd60e51b815260206004820152602560248201527f537455736473526174655365747465722f66696c652d756e7265636f676e697a60448201526419590b5a5960da1b60648201526084016103e7565b61ffff8211156104dd5760405162461bcd60e51b815260206004820152601e60248201527f537455736473526174655365747465722f696e76616c69642d76616c7565000060448201526064016103e7565b826236b4b760e91b0361055957805462010000900461ffff168211156105455760405162461bcd60e51b815260206004820152601d60248201527f537455736473526174655365747465722f6d696e2d746f6f2d6869676800000060448201526064016103e7565b805461ffff191661ffff831617815561065c565b82620dac2f60eb1b036105d657805461ffff168210156105bb5760405162461bcd60e51b815260206004820152601c60248201527f537455736473526174655365747465722f6d61782d746f6f2d6c6f770000000060448201526064016103e7565b805463ffff000019166201000061ffff84160217815561065c565b82630737465760e41b0361060357805465ffff00000000191664010000000061ffff84160217815561065c565b60405162461bcd60e51b815260206004820152602860248201527f537455736473526174655365747465722f66696c652d756e7265636f676e697a60448201526765642d706172616d60c01b60648201526084016103e7565b82847f851aa1caf4888170ad8875449d18f0f512fd6deb2a6571ea1a41fb9f95acbcd18460405161068f91815260200190565b60405180910390a350505050565b335f908152602081905260409020546001146106cb5760405162461bcd60e51b81526004016103e790611749565b816218985960ea1b03610750578015806106e55750806001145b61073c5760405162461bcd60e51b815260206004820152602260248201527f537455736473526174655365747465722f696e76616c69642d6261642d76616c604482015261756560f01b60648201526084016103e7565b6006805460ff191660ff831617905561099c565b816274617560e81b036107e75767ffffffffffffffff8111156107c05760405162461bcd60e51b815260206004820152602260248201527f537455736473526174655365747465722f696e76616c69642d7461752d76616c604482015261756560f01b60648201526084016103e7565b6006805468ffffffffffffffff00191661010067ffffffffffffffff84160217905561099c565b8162746f6360e81b0361087f576001600160801b038111156108565760405162461bcd60e51b815260206004820152602260248201527f537455736473526174655365747465722f696e76616c69642d746f632d76616c604482015261756560f01b60648201526084016103e7565b60068054600160481b600160c81b031916600160481b6001600160801b0384160217905561099c565b81666d61784c696e6560c81b03610918578015806108b05750722cd76fe086b93ce2f768a00b22a000000000008110155b61090e5760405162461bcd60e51b815260206004820152602960248201527f537455736473526174655365747465722f6d61784c696e652d697272656c6576604482015268616e742d76616c756560b81b60648201526084016103e7565b600481905561099c565b816506d61784361760d41b0361060357722cd76fe086b93ce2f768a00b22a0000000000081106109965760405162461bcd60e51b8152602060048201526024808201527f537455736473526174655365747465722f6d61784361702d696e73616e652d76604482015263616c756560e01b60648201526084016103e7565b60058190555b817fe986e40cc8c151830d4f61050f4fb2e4add8567caad2d5f5496f9158e91fe4c7826040516109ce91815260200190565b60405180910390a25050565b335f9081526001602081905260409091205414610a395760405162461bcd60e51b815260206004820181905260248201527f537455736473526174655365747465722f6e6f742d666163696c697461746f7260448201526064016103e7565b60065460ff1615610a8c5760405162461bcd60e51b815260206004820152601e60248201527f537455736473526174655365747465722f6d6f64756c652d68616c746564000060448201526064016103e7565b600654610ab890600160481b81046001600160801b031690610100900467ffffffffffffffff16611794565b6001600160801b0316421015610b105760405162461bcd60e51b815260206004820152601a60248201527f537455736473526174655365747465722f746f6f2d6561726c7900000000000060448201526064016103e7565b60068054600160481b600160c81b031916600160481b426001600160801b031602179055600454821115610b865760405162461bcd60e51b815260206004820152601e60248201527f537455736473526174655365747465722f6c696e652d746f6f2d68696768000060448201526064016103e7565b604051630a6ba04560e21b8152636c696e6560e01b6004820152602481018390527f00000000000000000000000099cd4ec3f88a45940936f469e4bb72a2a701eeb96001600160a01b0316906329ae8114906044015f604051808303815f87803b158015610bf2575f80fd5b505af1158015610c04573d5f803e3d5ffd5b50505050600554811115610c5a5760405162461bcd60e51b815260206004820152601d60248201527f537455736473526174655365747465722f6361702d746f6f2d6869676800000060448201526064016103e7565b604051630a6ba04560e21b81526206361760ec1b6004820152602481018290527f00000000000000000000000099cd4ec3f88a45940936f469e4bb72a2a701eeb96001600160a01b0316906329ae8114906044015f604051808303815f87803b158015610cc5575f80fd5b505af1158015610cd7573d5f803e3d5ffd5b505050505f610e24857f000000000000000000000000ea91a18dafa1cb1d2a19dfb205816034e6fe7e526001600160a01b031663538af0377f00000000000000000000000099cd4ec3f88a45940936f469e4bb72a2a701eeb96001600160a01b031663c15bae846040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d6b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d8f91906117bb565b6040518263ffffffff1660e01b8152600401610dad91815260200190565b602060405180830381865afa158015610dc8573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dec91906117bb565b6040805160608101825260025461ffff80821683526201000082048116602084015264010000000090910416918101919091526113e0565b90507f00000000000000000000000099cd4ec3f88a45940936f469e4bb72a2a701eeb96001600160a01b0316639f678cca6040518163ffffffff1660e01b81526004015f604051808303815f87803b158015610e7e575f80fd5b505af1158015610e90573d5f803e3d5ffd5b5050604051630a6ba04560e21b81526239ba3960e91b6004820152602481018490527f00000000000000000000000099cd4ec3f88a45940936f469e4bb72a2a701eeb96001600160a01b031692506329ae811491506044015f604051808303815f87803b158015610eff575f80fd5b505af1158015610f11573d5f803e3d5ffd5b5050604051636cb1c69b60e11b81527f4c534556322d534b592d4100000000000000000000000000000000000000000060048201525f92507f00000000000000000000000019c0976f590d67707e62397c87829d896dc0f1f16001600160a01b0316915063d9638d36906024016040805180830381865afa158015610f98573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fbc91906117d2565b509050611088857f000000000000000000000000ea91a18dafa1cb1d2a19dfb205816034e6fe7e526001600160a01b031663538af037846040518263ffffffff1660e01b815260040161101191815260200190565b602060405180830381865afa15801561102c573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061105091906117bb565b6040805160608101825260035461ffff80821683526201000082048116602084015264010000000090910416918101919091526113e0565b60405163089c54b560e31b81527f4c534556322d534b592d4100000000000000000000000000000000000000000060048201529092507f00000000000000000000000019c0976f590d67707e62397c87829d896dc0f1f16001600160a01b0316906344e2a5a8906024015f604051808303815f87803b158015611109575f80fd5b505af115801561111b573d5f803e3d5ffd5b5050604051630d05943f60e11b81527f4c534556322d534b592d410000000000000000000000000000000000000000006004820152636475747960e01b6024820152604481018590527f00000000000000000000000019c0976f590d67707e62397c87829d896dc0f1f16001600160a01b03169250631a0b287e91506064015f604051808303815f87803b1580156111b1575f80fd5b505af11580156111c3573d5f803e3d5ffd5b50506040805189815260208101899052908101879052606081018690527f80c9bdaa28e2c8c29e1f3d127e3e57466544546d365a0731bb69d8966a0778ec9250608001905060405180910390a1505050505050565b335f908152602081905260409020546001146112465760405162461bcd60e51b81526004016103e790611749565b6001600160a01b0381165f81815260016020526040808220829055517f12fdafd291eb287a54e3416070923d22aa5072f5ee04c4fb8361615e7508a37c9190a250565b335f908152602081905260409020546001146112b75760405162461bcd60e51b81526004016103e790611749565b6001600160a01b0381165f8181526020819052604080822060019055517fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a609190a250565b335f908152602081905260409020546001146113295760405162461bcd60e51b81526004016103e790611749565b6001600160a01b0381165f81815260208190526040808220829055517f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b9190a250565b335f9081526020819052604090205460011461139a5760405162461bcd60e51b81526004016103e790611749565b6001600160a01b0381165f81815260016020819052604080832091909155517f6ffc0fabf0709270e42087e84a3bfc36041d3b281266d04ae1962185092fb2449190a250565b5f80826040015161ffff16116114445760405162461bcd60e51b8152602060048201526024808201527f537455736473526174655365747465722f726174652d6e6f742d636f6e6669676044820152631d5c995960e21b60648201526084016103e7565b815161ffff168410156114995760405162461bcd60e51b815260206004820152601a60248201527f537455736473526174655365747465722f62656c6f772d6d696e00000000000060448201526064016103e7565b816020015161ffff168411156114f15760405162461bcd60e51b815260206004820152601a60248201527f537455736473526174655365747465722f61626f76652d6d617800000000000060448201526064016103e7565b815161ffff1683101561150b57815161ffff169250611527565b816020015161ffff1683111561152757816020015161ffff1692505b5f83851161153e5761153985856117f4565b611548565b61154884866117f4565b9050826040015161ffff168111156115ac5760405162461bcd60e51b815260206004820152602160248201527f537455736473526174655365747465722f64656c74612d61626f76652d7374656044820152600760fc1b60648201526084016103e7565b604051630c33fe8160e21b8152600481018690527f000000000000000000000000ea91a18dafa1cb1d2a19dfb205816034e6fe7e526001600160a01b0316906330cffa0490602401602060405180830381865afa15801561160f573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061163391906117bb565b91506b033b2e3c9fd0803ce800000082101561169c5760405162461bcd60e51b815260206004820152602260248201527f537455736473526174655365747465722f696e76616c69642d726174652d636f604482015261373b60f11b60648201526084016103e7565b509392505050565b5f805f606084860312156116b6575f80fd5b505081359360208301359350604090920135919050565b5f80604083850312156116de575f80fd5b50508035926020909101359150565b5f602082840312156116fd575f80fd5b81356001600160a01b0381168114611713575f80fd5b9392505050565b5f805f806080858703121561172d575f80fd5b5050823594602084013594506040840135936060013592509050565b6020808252601f908201527f537455736473526174655365747465722f6e6f742d617574686f72697a656400604082015260600190565b634e487b7160e01b5f52601160045260245ffd5b6001600160801b038181168382160190808211156117b4576117b4611780565b5092915050565b5f602082840312156117cb575f80fd5b5051919050565b5f80604083850312156117e3575f80fd5b505080516020909101519092909150565b8181038181111561180757611807611780565b9291505056fea26469706673582212208d01da31a2782bce833f520eb2b8cb62474fa5b48eca70969711feec8f98f94f64736f6c63430008150033
Verified Source Code Partial Match
Compiler: v0.8.21+commit.d9974bed
EVM: shanghai
Optimization: Yes (200 runs)
StUsdsRateSetter.sol 213 lines
// 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 JugLike {
function ilks(bytes32) external view returns (uint256, uint256);
function file(bytes32, bytes32, uint256) external;
function drip(bytes32) external;
}
interface StUsdsLike {
function jug() external view returns (address);
function ilk() external view returns (bytes32);
function str() external view returns (uint256);
function file(bytes32, uint256) external;
function drip() external;
}
interface ConvLike {
function btor(uint256) external pure returns (uint256);
function rtob(uint256) external pure returns (uint256);
}
contract StUsdsRateSetter {
// --- Storage Variables ---
mapping(address => uint256) public wards;
mapping(address => uint256) public buds;
Cfg public strCfg;
Cfg public dutyCfg;
uint256 public maxLine; // [rad]
uint256 public maxCap; // [wad]
uint8 public bad; // Circuit breaker flag
uint64 public tau; // Cooldown period between rate changes in seconds
uint128 public toc; // Last time when rates were updated (Unix timestamp)
// --- Structs ---
// All values are in basis points (1 bp = 0.01%)
struct Cfg {
uint16 min; // Minimum allowed rate
uint16 max; // Maximum allowed rate
uint16 step; // Maximum allowed rate change per update
}
// --- Constants ---
uint256 private constant RAY = 10 ** 27;
uint256 private constant RAD = 10 ** 45;
// --- Immutables ---
JugLike public immutable jug;
StUsdsLike public immutable stusds;
ConvLike public immutable conv;
bytes32 public immutable ilk;
// --- Events ---
event Rely(address indexed usr);
event Deny(address indexed usr);
event Kiss(address indexed usr);
event Diss(address indexed usr);
event File(bytes32 indexed what, uint256 data);
event File(bytes32 indexed id, bytes32 indexed what, uint256 data);
event Set(uint256 strBps, uint256 dutyBps, uint256 line, uint256 cap);
// --- Modifiers ---
modifier auth() {
require(wards[msg.sender] == 1, "StUsdsRateSetter/not-authorized");
_;
}
modifier toll() {
require(buds[msg.sender] == 1, "StUsdsRateSetter/not-facilitator");
_;
}
modifier good() {
require(bad == 0, "StUsdsRateSetter/module-halted");
_;
}
constructor(address _stusds, address _conv) {
stusds = StUsdsLike(_stusds);
conv = ConvLike(_conv);
jug = JugLike(stusds.jug());
ilk = stusds.ilk();
wards[msg.sender] = 1;
emit Rely(msg.sender);
}
// --- 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 kiss(address usr) external auth {
buds[usr] = 1;
emit Kiss(usr);
}
function diss(address usr) external auth {
buds[usr] = 0;
emit Diss(usr);
}
function file(bytes32 what, uint256 data) external auth {
if (what == "bad") {
require(data == 0 || data == 1, "StUsdsRateSetter/invalid-bad-value");
bad = uint8(data);
} else if (what == "tau") {
require(data <= type(uint64).max, "StUsdsRateSetter/invalid-tau-value");
tau = uint64(data);
} else if (what == "toc") {
require(data <= type(uint128).max, "StUsdsRateSetter/invalid-toc-value");
toc = uint128(data);
} else if (what == "maxLine") {
require(data == 0 || data >= RAD, "StUsdsRateSetter/maxLine-irrelevant-value");
maxLine = data;
} else if (what == "maxCap") {
require(data < RAD, "StUsdsRateSetter/maxCap-insane-value");
maxCap = data;
} else revert("StUsdsRateSetter/file-unrecognized-param");
emit File(what, data);
}
function file(bytes32 id, bytes32 what, uint256 data) external auth {
Cfg storage cfg;
if (id == "STR") cfg = strCfg;
else if (id == ilk) cfg = dutyCfg;
else revert("StUsdsRateSetter/file-unrecognized-id");
require(data <= type(uint16).max, "StUsdsRateSetter/invalid-value");
if (what == "min") {
require(data <= cfg.max, "StUsdsRateSetter/min-too-high");
cfg.min = uint16(data);
} else if (what == "max") {
require(data >= cfg.min, "StUsdsRateSetter/max-too-low");
cfg.max = uint16(data);
} else if (what == "step") {
cfg.step = uint16(data);
} else revert("StUsdsRateSetter/file-unrecognized-param");
emit File(id, what, data);
}
function _calcRate(uint256 bps, uint256 oldBps, Cfg memory cfg) internal view returns (uint256 ray) {
require(cfg.step > 0, "StUsdsRateSetter/rate-not-configured");
require(bps >= cfg.min, "StUsdsRateSetter/below-min");
require(bps <= cfg.max, "StUsdsRateSetter/above-max");
if (oldBps < cfg.min) {
oldBps = cfg.min;
} else if (oldBps > cfg.max) {
oldBps = cfg.max;
}
// Calculates absolute difference between the old and the new rate
uint256 delta = bps > oldBps ? bps - oldBps : oldBps - bps;
require(delta <= cfg.step, "StUsdsRateSetter/delta-above-step");
ray = conv.btor(bps);
require(ray >= RAY, "StUsdsRateSetter/invalid-rate-conv");
}
// Notes:
// - It is intended to rewrite the same values, emit the event, and reset the toc count, even if there is no change.
function set(uint256 strBps, uint256 dutyBps, uint256 line, uint256 cap) external toll good {
require(block.timestamp >= tau + toc, "StUsdsRateSetter/too-early");
toc = uint128(block.timestamp);
require(line <= maxLine, "StUsdsRateSetter/line-too-high");
stusds.file("line", line); // New line will be immediately taken into account as stusds.drip will be called few lines below
require(cap <= maxCap, "StUsdsRateSetter/cap-too-high");
stusds.file("cap", cap);
uint256 ray = _calcRate({
bps : strBps,
oldBps : conv.rtob(stusds.str()),
cfg : strCfg
});
stusds.drip();
stusds.file("str", ray);
(uint256 duty,) = jug.ilks(ilk);
ray = _calcRate({
bps : dutyBps,
oldBps : conv.rtob(duty),
cfg : dutyCfg
});
jug.drip(ilk);
jug.file(ilk, "duty", ray);
emit Set(strBps, dutyBps, line, cap);
}
}
Read Contract
bad 0x9c3674fc → uint8
buds 0x53a7d8cd → uint256
conv 0x08b36870 → address
dutyCfg 0x5e2e013e → uint16, uint16, uint16
ilk 0xc5ce281e → bytes32
jug 0x84718d89 → address
maxCap 0x23548b8b → uint256
maxLine 0xfee4412f → uint256
strCfg 0x1aeba947 → uint16, uint16, uint16
stusds 0x0aebbede → address
tau 0xcfc4af55 → uint64
toc 0x89afb88a → uint128
wards 0xbf353dbb → uint256
Write Contract 7 functions
These functions modify contract state and require a wallet transaction to execute.
deny 0x9c52a7f1
address usr
diss 0x65c4ce7a
address usr
file 0x1a0b287e
bytes32 id
bytes32 what
uint256 data
file 0x29ae8114
bytes32 what
uint256 data
kiss 0xf29c29c4
address usr
rely 0x65fae35e
address usr
set 0x606ce3bf
uint256 strBps
uint256 dutyBps
uint256 line
uint256 cap
Recent Transactions
No transactions found for this address