Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
16047155 | 739 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x9B207AfA...d6D81C160 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
LinearDecrease
Compiler Version
v0.6.12+commit.27d51765
Contract Source Code (Solidity)
/** *Submitted for verification at Etherscan.io on 2022-04-12 */ /** *Submitted for verification at Etherscan.io on 2021-08-18 */ // 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 LinearDecrease 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, "LinearDecrease/not-authorized"); _; } // --- Data --- uint256 public tau; // Seconds after auction start when the price reaches zero [seconds] // --- Events --- event Rely(address indexed usr); event Deny(address indexed usr); event File(bytes32 indexed what, uint256 data); // --- Init --- constructor() public { wards[msg.sender] = 1; emit Rely(msg.sender); } // --- Administration --- function file(bytes32 what, uint256 data) external auth { if (what == "tau") tau = data; else revert("LinearDecrease/file-unrecognized-param"); emit File(what, data); } // --- Math --- uint256 constant RAY = 10 ** 27; function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x); } function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(y == 0 || (z = x * y) / y == x); } function rmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x * y; require(y == 0 || z / y == x); z = z / RAY; } // Price calculation when price is decreased linearly in proportion to time: // tau: The number of seconds after the start of the auction where the price will hit 0 // top: Initial price // dur: current seconds since the start of the auction // // Returns y = top * ((tau - dur) / tau) // // Note the internal call to mul multiples by RAY, thereby ensuring that the rmul calculation // which utilizes top and tau (RAY values) is also a RAY value. function price(uint256 top, uint256 dur) override external view returns (uint256) { if (dur >= tau) return 0; return rmul(top, mul(tau - dur, RAY) / tau); } } 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)); } } // While an equivalent function can be obtained by setting step = 1 in StairstepExponentialDecrease, // this continous (i.e. per-second) exponential decrease has be implemented as it is more gas-efficient // than using the stairstep version with step = 1 (primarily due to 1 fewer SLOAD per price calculation). contract ExponentialDecrease 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, "ExponentialDecrease/not-authorized"); _; } // --- Data --- uint256 public cut; // Per-second multiplicative factor [ray] // --- Events --- event Rely(address indexed usr); event Deny(address indexed usr); event File(bytes32 indexed what, uint256 data); // --- Init --- // @notice: `cut` value 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, "ExponentialDecrease/cut-gt-RAY"); else revert("ExponentialDecrease/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 // cut: cut encodes the percentage to decrease per second. // For efficiency, the values is set as (1 - (% value / 100)) * RAY // So, for a 1% decrease per second, 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, RAY)); } } /// DssDeploy.sol // Copyright (C) 2018-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.5.12; */ contract CalcFab { function newLinearDecrease(address owner) public returns (LinearDecrease calc) { calc = new LinearDecrease(); calc.rely(owner); calc.deny(address(this)); } function newStairstepExponentialDecrease(address owner) public returns (StairstepExponentialDecrease calc) { calc = new StairstepExponentialDecrease(); calc.rely(owner); calc.deny(address(this)); } function newExponentialDecrease(address owner) public returns (ExponentialDecrease calc) { calc = new ExponentialDecrease(); calc.rely(owner); calc.deny(address(this)); } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"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":[{"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":"tau","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"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100625760003560e01c806329ae811414610067578063487a23951461009f57806365fae35e146100eb5780639c52a7f11461012f578063bf353dbb14610173578063cfc4af55146101cb575b600080fd5b61009d6004803603604081101561007d57600080fd5b8101908080359060200190929190803590602001909291905050506101e9565b005b6100d5600480360360408110156100b557600080fd5b81019080803590602001909291908035906020019092919050505061035e565b6040518082815260200191505060405180910390f35b61012d6004803603602081101561010157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103a9565b005b6101716004803603602081101561014557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104e7565b005b6101b56004803603602081101561018957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610625565b6040518082815260200191505060405180910390f35b6101d361063d565b6040518082815260200191505060405180910390f35b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461029d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4c696e65617244656372656173652f6e6f742d617574686f72697a656400000081525060200191505060405180910390fd5b7f74617500000000000000000000000000000000000000000000000000000000008214156102d15780600181905550610322565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806106b56026913960400191505060405180910390fd5b817fe986e40cc8c151830d4f61050f4fb2e4add8567caad2d5f5496f9158e91fe4c7826040518082815260200191505060405180910390a25050565b6000600154821061037257600090506103a3565b6103a08360015461039385600154036b033b2e3c9fd0803ce8000000610643565b8161039a57fe5b0461066f565b90505b92915050565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461045d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4c696e65617244656372656173652f6e6f742d617574686f72697a656400000081525060200191505060405180910390fd5b60016000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a6060405160405180910390a250565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461059b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4c696e65617244656372656173652f6e6f742d617574686f72697a656400000081525060200191505060405180910390fd5b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b60405160405180910390a250565b60006020528060005260406000206000915090505481565b60015481565b600080821480610660575082828385029250828161065d57fe5b04145b61066957600080fd5b92915050565b60008183029050600082148061068d57508282828161068a57fe5b04145b61069657600080fd5b6b033b2e3c9fd0803ce800000081816106ab57fe5b0490509291505056fe4c696e65617244656372656173652f66696c652d756e7265636f676e697a65642d706172616da26469706673582212203010180855bbe57dd2befbbb986c1d678da74f0d5eb1b26e6ede366c1b6d7eda64736f6c634300060c0033
Deployed Bytecode Sourcemap
1149:2182:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1969:201;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;3149:179;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1261:76;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;1343;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;1213:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1563:18;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1969:201;1479:1;1458:5;:17;1464:10;1458:17;;;;;;;;;;;;;;;;:22;1450:64;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2040:14:::1;:4;:14;2036:94;;;2062:4;2056:3;:10;;;;2036:94;;;2082:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2036:94;2151:4;2146:16;2157:4;2146:16;;;;;;;;;;;;;;;;;;1969:201:::0;;:::o;3149:179::-;3222:7;3253:3;;3246;:10;3242:24;;3265:1;3258:8;;;;3242:24;3284:36;3289:3;3316;;3294:19;3304:3;3298;;:9;2222:8;3294:3;:19::i;:::-;:25;;;;;;3284:4;:36::i;:::-;3277:43;;3149:179;;;;;:::o;1261:76::-;1479:1;1458:5;:17;1464:10;1458:17;;;;;;;;;;;;;;;;:22;1450:64;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1317:1:::1;1304:5;:10:::0;1310:3:::1;1304:10;;;;;;;;;;;;;;;:14;;;;1330:3;1325:9;;;;;;;;;;;;1261:76:::0;:::o;1343:::-;1479:1;1458:5;:17;1464:10;1458:17;;;;;;;;;;;;;;;;:22;1450:64;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1399:1:::1;1386:5:::0;:10:::1;1392:3;1386:10;;;;;;;;;;;;;;;:14;;;;1412:3;1407:9;;;;;;;;;;;;1343:76:::0;:::o;1213:41::-;;;;;;;;;;;;;;;;;:::o;1563:18::-;;;;:::o;2356:127::-;2414:9;2449:1;2444;:6;:30;;;;2473:1;2468;2463;2459;:5;2455:9;;;2454:15;;;;;;:20;2444:30;2436:39;;;;;;2356:127;;;;:::o;2489:160::-;2548:9;2578:1;2574;:5;2570:9;;2603:1;2598;:6;:20;;;;2617:1;2612;2608;:5;;;;;;:10;2598:20;2590:29;;;;;;2222:8;2634:1;:7;;;;;;2630:11;;2489:160;;;;:::o
Swarm Source
ipfs://3010180855bbe57dd2befbbb986c1d678da74f0d5eb1b26e6ede366c1b6d7eda
Loading...
Loading
Loading...
Loading
OVERVIEW
Sky (formerly Maker) enables users to get rewarded for non-custodial savings.Multichain Portfolio | 29 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.