Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x7B169667...8B7D86Eb1 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
StairstepExponentialDecrease
Compiler Version
v0.6.12+commit.27d51765
Contract Source Code (Solidity)
/**
*Submitted for verification at Etherscan.io on 2021-04-15
*/
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2020 Maker Ecosystem Growth Holdings, INC.
//
// 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.6.12;
interface Abacus {
// 1st arg: initial price [ray]
// 2nd arg: seconds since auction start [seconds]
// returns: current auction price [ray]
function price(uint256, uint256) external view returns (uint256);
}
contract StairstepExponentialDecrease is Abacus {
// --- Auth ---
mapping (address => uint256) public wards;
function rely(address usr) external auth { wards[usr] = 1; emit Rely(usr); }
function deny(address usr) external auth { wards[usr] = 0; emit Deny(usr); }
modifier auth {
require(wards[msg.sender] == 1, "StairstepExponentialDecrease/not-authorized");
_;
}
// --- Data ---
uint256 public step; // Length of time between price drops [seconds]
uint256 public cut; // Per-step multiplicative factor [ray]
// --- Events ---
event Rely(address indexed usr);
event Deny(address indexed usr);
event File(bytes32 indexed what, uint256 data);
// --- Init ---
// @notice: `cut` and `step` values must be correctly set for
// this contract to return a valid price
constructor() public {
wards[msg.sender] = 1;
emit Rely(msg.sender);
}
// --- Administration ---
function file(bytes32 what, uint256 data) external auth {
if (what == "cut") require((cut = data) <= RAY, "StairstepExponentialDecrease/cut-gt-RAY");
else if (what == "step") step = data;
else revert("StairstepExponentialDecrease/file-unrecognized-param");
emit File(what, data);
}
// --- Math ---
uint256 constant RAY = 10 ** 27;
function rmul(uint256 x, uint256 y) internal pure returns (uint256 z) {
z = x * y;
require(y == 0 || z / y == x);
z = z / RAY;
}
// optimized version from dss PR #78
function rpow(uint256 x, uint256 n, uint256 b) internal pure returns (uint256 z) {
assembly {
switch n case 0 { z := b }
default {
switch x case 0 { z := 0 }
default {
switch mod(n, 2) case 0 { z := b } default { z := x }
let half := div(b, 2) // for rounding.
for { n := div(n, 2) } n { n := div(n,2) } {
let xx := mul(x, x)
if shr(128, x) { revert(0,0) }
let xxRound := add(xx, half)
if lt(xxRound, xx) { revert(0,0) }
x := div(xxRound, b)
if mod(n,2) {
let zx := mul(z, x)
if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) { revert(0,0) }
let zxRound := add(zx, half)
if lt(zxRound, zx) { revert(0,0) }
z := div(zxRound, b)
}
}
}
}
}
}
// top: initial price
// dur: seconds since the auction has started
// step: seconds between a price drop
// cut: cut encodes the percentage to decrease per step.
// For efficiency, the values is set as (1 - (% value / 100)) * RAY
// So, for a 1% decrease per step, cut would be (1 - 0.01) * RAY
//
// returns: top * (cut ^ dur)
//
//
function price(uint256 top, uint256 dur) override external view returns (uint256) {
return rmul(top, rpow(cut, dur / step, RAY));
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"usr","type":"address"}],"name":"Deny","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"what","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"data","type":"uint256"}],"name":"File","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"usr","type":"address"}],"name":"Rely","type":"event"},{"inputs":[],"name":"cut","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"deny","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"what","type":"bytes32"},{"internalType":"uint256","name":"data","type":"uint256"}],"name":"file","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"top","type":"uint256"},{"internalType":"uint256","name":"dur","type":"uint256"}],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"rely","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"step","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"wards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
0x608060405234801561001057600080fd5b5060016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a6060405160405180910390a2610876806100a76000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80639c52a7f11161005b5780639c52a7f11461014a578063bf353dbb1461018e578063e25fe175146101e6578063e6fd604c146102045761007d565b806329ae811414610082578063487a2395146100ba57806365fae35e14610106575b600080fd5b6100b86004803603604081101561009857600080fd5b810190808035906020019092919080359060200190929190505050610222565b005b6100f0600480360360408110156100d057600080fd5b810190808035906020019092919080359060200190929190505050610412565b6040518082815260200191505060405180910390f35b6101486004803603602081101561011c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610449565b005b61018c6004803603602081101561016057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061056a565b005b6101d0600480360360208110156101a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061068b565b6040518082815260200191505060405180910390f35b6101ee6106a3565b6040518082815260200191505060405180910390f35b61020c6106a9565b6040518082815260200191505060405180910390f35b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146102b9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806107bb602b913960400191505060405180910390fd5b7f6375740000000000000000000000000000000000000000000000000000000000821415610350576b033b2e3c9fd0803ce8000000816002819055111561034b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806107e66027913960400191505060405180910390fd5b6103d6565b7f737465700000000000000000000000000000000000000000000000000000000082141561038457806001819055506103d5565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603481526020018061080d6034913960400191505060405180910390fd5b5b817fe986e40cc8c151830d4f61050f4fb2e4add8567caad2d5f5496f9158e91fe4c7826040518082815260200191505060405180910390a25050565b60006104418361043c600254600154868161042957fe5b046b033b2e3c9fd0803ce80000006106af565b610775565b905092915050565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146104e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806107bb602b913960400191505060405180910390fd5b60016000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a6060405160405180910390a250565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610601576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806107bb602b913960400191505060405180910390fd5b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b60405160405180910390a250565b60006020528060005260406000206000915090505481565b60015481565b60025481565b6000826000811461076957846000811461075e5760028506600081146106d7578693506106db565b8493505b50600284046002860495505b8515610758578687028760801c156106fe57600080fd5b8181018181101561070e57600080fd5b8681049850600288061561074b57888602868a820414158a1515161561073357600080fd5b8381018181101561074357600080fd5b888104975050505b50506002860495506106e7565b50610763565b600092505b5061076d565b8291505b509392505050565b60008183029050600082148061079357508282828161079057fe5b04145b61079c57600080fd5b6b033b2e3c9fd0803ce800000081816107b157fe5b0490509291505056fe5374616972737465704578706f6e656e7469616c44656372656173652f6e6f742d617574686f72697a65645374616972737465704578706f6e656e7469616c44656372656173652f6375742d67742d5241595374616972737465704578706f6e656e7469616c44656372656173652f66696c652d756e7265636f676e697a65642d706172616da26469706673582212204ae8e0fe98f28f7158108adb1ba14001e0158ee55a0a4c48548493c9f69e492664736f6c634300060c0033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80639c52a7f11161005b5780639c52a7f11461014a578063bf353dbb1461018e578063e25fe175146101e6578063e6fd604c146102045761007d565b806329ae811414610082578063487a2395146100ba57806365fae35e14610106575b600080fd5b6100b86004803603604081101561009857600080fd5b810190808035906020019092919080359060200190929190505050610222565b005b6100f0600480360360408110156100d057600080fd5b810190808035906020019092919080359060200190929190505050610412565b6040518082815260200191505060405180910390f35b6101486004803603602081101561011c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610449565b005b61018c6004803603602081101561016057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061056a565b005b6101d0600480360360208110156101a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061068b565b6040518082815260200191505060405180910390f35b6101ee6106a3565b6040518082815260200191505060405180910390f35b61020c6106a9565b6040518082815260200191505060405180910390f35b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146102b9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806107bb602b913960400191505060405180910390fd5b7f6375740000000000000000000000000000000000000000000000000000000000821415610350576b033b2e3c9fd0803ce8000000816002819055111561034b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806107e66027913960400191505060405180910390fd5b6103d6565b7f737465700000000000000000000000000000000000000000000000000000000082141561038457806001819055506103d5565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603481526020018061080d6034913960400191505060405180910390fd5b5b817fe986e40cc8c151830d4f61050f4fb2e4add8567caad2d5f5496f9158e91fe4c7826040518082815260200191505060405180910390a25050565b60006104418361043c600254600154868161042957fe5b046b033b2e3c9fd0803ce80000006106af565b610775565b905092915050565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146104e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806107bb602b913960400191505060405180910390fd5b60016000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a6060405160405180910390a250565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610601576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806107bb602b913960400191505060405180910390fd5b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b60405160405180910390a250565b60006020528060005260406000206000915090505481565b60015481565b60025481565b6000826000811461076957846000811461075e5760028506600081146106d7578693506106db565b8493505b50600284046002860495505b8515610758578687028760801c156106fe57600080fd5b8181018181101561070e57600080fd5b8681049850600288061561074b57888602868a820414158a1515161561073357600080fd5b8381018181101561074357600080fd5b888104975050505b50506002860495506106e7565b50610763565b600092505b5061076d565b8291505b509392505050565b60008183029050600082148061079357508282828161079057fe5b04145b61079c57600080fd5b6b033b2e3c9fd0803ce800000081816107b157fe5b0490509291505056fe5374616972737465704578706f6e656e7469616c44656372656173652f6e6f742d617574686f72697a65645374616972737465704578706f6e656e7469616c44656372656173652f6375742d67742d5241595374616972737465704578706f6e656e7469616c44656372656173652f66696c652d756e7265636f676e697a65642d706172616da26469706673582212204ae8e0fe98f28f7158108adb1ba14001e0158ee55a0a4c48548493c9f69e492664736f6c634300060c0033
Deployed Bytecode Sourcemap
1078:3321:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2092:328;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;4251:145;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1204:76;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;1286;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;1156:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1520:19;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1594:18;;;:::i;:::-;;;;;;;;;;;;;;;;;;;2092:328;1422:1;1401:5;:17;1407:10;1401:17;;;;;;;;;;;;;;;;:22;1393:78;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2168:14:::1;:4;:14;2159:221;;;2472:8;2199:4;2193:3;:10;;;2192:19;;2184:71;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2159:221;;;2275:14;:4;:14;2271:109;;;2298:4;2291;:11;;;;2271:109;;;2318:62;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2271:109;2159:221;2401:4;2396:16;2407:4;2396:16;;;;;;;;;;;;;;;;;;2092:328:::0;;:::o;4251:145::-;4324:7;4351:37;4356:3;4361:26;4366:3;;4377:4;;4371:3;:10;;;;;;2472:8;4361:4;:26::i;:::-;4351:4;:37::i;:::-;4344:44;;4251:145;;;;:::o;1204:76::-;1422:1;1401:5;:17;1407:10;1401:17;;;;;;;;;;;;;;;;:22;1393:78;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1260:1:::1;1247:5;:10:::0;1253:3:::1;1247:10;;;;;;;;;;;;;;;:14;;;;1273:3;1268:9;;;;;;;;;;;;1204:76:::0;:::o;1286:::-;1422:1;1401:5;:17;1407:10;1401:17;;;;;;;;;;;;;;;;:22;1393:78;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1342:1:::1;1329:5:::0;:10:::1;1335:3;1329:10;;;;;;;;;;;;;;;:14;;;;1355:3;1350:9;;;;;;;;;;;;1286:76:::0;:::o;1156:41::-;;;;;;;;;;;;;;;;;:::o;1520:19::-;;;;:::o;1594:18::-;;;;:::o;2695:1159::-;2765:9;2818:1;2825;2820:17;;;;2885:1;2892;2887:17;;;;2967:1;2964;2960:9;2975:1;2970:17;;;;3003:1;2998:6;;2953:53;;2970:17;2984:1;2979:6;;2953:53;;3047:1;3044;3040:9;3107:1;3104;3100:9;3095:14;;3089:713;3112:1;3089:713;;;3176:1;3173;3169:9;3216:1;3211:3;3207:11;3204:2;;;3230:1;3228;3221:11;3204:2;3283:4;3279:2;3275:13;3329:2;3320:7;3317:15;3314:2;;;3344:1;3342;3335:11;3314:2;3392:1;3383:7;3379:15;3374:20;;3429:1;3427;3423:8;3420:2;;;3480:1;3477;3473:9;3560:1;3556;3552:2;3548:10;3545:17;3538:25;3533:1;3526:9;3519:17;3515:49;3512:2;;;3576:1;3574;3567:11;3512:2;3633:4;3629:2;3625:13;3683:2;3674:7;3671:15;3668:2;;;3698:1;3696;3689:11;3668:2;3750:1;3741:7;3737:15;3732:20;;3432:347;;3420:2;3132:670;;3127:1;3125;3121:8;3116:13;;3089:713;;;2930:891;2878:943;;2887:17;2901:1;2896:6;;2878:943;;2811:1025;;2820:17;2834:1;2829:6;;2811:1025;;2796:1051;;;;;:::o;2487:160::-;2546:9;2576:1;2572;:5;2568:9;;2601:1;2596;:6;:20;;;;2615:1;2610;2606;:5;;;;;;:10;2596:20;2588:29;;;;;;2472:8;2632:1;:7;;;;;;2628:11;;2487:160;;;;:::o
Swarm Source
ipfs://4ae8e0fe98f28f7158108adb1ba14001e0158ee55a0a4c48548493c9f69e4926
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.