ETH Price: $1,857.29 (-1.94%)

Transaction Decoder

Block:
6667150 at Nov-08-2018 04:00:44 PM +UTC
Transaction Fee:
0.00042602 ETH $0.79
Gas Used:
42,602 Gas / 10 Gwei

Emitted Events:

53 OSM.LogValue( val=00000000000000000000000000000000000000000000002381A058908627B780 )

Account State Difference:

  Address   Before After State Difference Code
(Nanopool)
8,214.152553044637256522 Eth8,214.152979064637256522 Eth0.00042602
0x5C1fc813...984CA44B7
0x825c5302...22E1BCe12
0.070167156354034214 Eth
Nonce: 1305
0.069741136354034214 Eth
Nonce: 1306
0.00042602

Execution Trace

OSM.CALL( )
  • Medianizer.CALL( )
    File 1 of 2: OSM
    // hevm: flattened sources of src/osm.sol
    pragma solidity ^0.4.24;
    
    ////// lib/ds-stop/lib/ds-auth/src/auth.sol
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU 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 General Public License for more details.
    
    // You should have received a copy of the GNU General Public License
    // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    /* pragma solidity ^0.4.23; */
    
    contract DSAuthority {
        function canCall(
            address src, address dst, bytes4 sig
        ) public view returns (bool);
    }
    
    contract DSAuthEvents {
        event LogSetAuthority (address indexed authority);
        event LogSetOwner     (address indexed owner);
    }
    
    contract DSAuth is DSAuthEvents {
        DSAuthority  public  authority;
        address      public  owner;
    
        constructor() public {
            owner = msg.sender;
            emit LogSetOwner(msg.sender);
        }
    
        function setOwner(address owner_)
            public
            auth
        {
            owner = owner_;
            emit LogSetOwner(owner);
        }
    
        function setAuthority(DSAuthority authority_)
            public
            auth
        {
            authority = authority_;
            emit LogSetAuthority(authority);
        }
    
        modifier auth {
            require(isAuthorized(msg.sender, msg.sig));
            _;
        }
    
        function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
            if (src == address(this)) {
                return true;
            } else if (src == owner) {
                return true;
            } else if (authority == DSAuthority(0)) {
                return false;
            } else {
                return authority.canCall(src, this, sig);
            }
        }
    }
    
    ////// lib/ds-stop/lib/ds-note/src/note.sol
    /// note.sol -- the `note' modifier, for logging calls as events
    
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU 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 General Public License for more details.
    
    // You should have received a copy of the GNU General Public License
    // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    /* pragma solidity ^0.4.23; */
    
    contract DSNote {
        event LogNote(
            bytes4   indexed  sig,
            address  indexed  guy,
            bytes32  indexed  foo,
            bytes32  indexed  bar,
            uint              wad,
            bytes             fax
        ) anonymous;
    
        modifier note {
            bytes32 foo;
            bytes32 bar;
    
            assembly {
                foo := calldataload(4)
                bar := calldataload(36)
            }
    
            emit LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);
    
            _;
        }
    }
    
    ////// lib/ds-stop/src/stop.sol
    /// stop.sol -- mixin for enable/disable functionality
    
    // Copyright (C) 2017  DappHub, LLC
    
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU 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 General Public License for more details.
    
    // You should have received a copy of the GNU General Public License
    // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    /* pragma solidity ^0.4.23; */
    
    /* import "ds-auth/auth.sol"; */
    /* import "ds-note/note.sol"; */
    
    contract DSStop is DSNote, DSAuth {
    
        bool public stopped;
    
        modifier stoppable {
            require(!stopped);
            _;
        }
        function stop() public auth note {
            stopped = true;
        }
        function start() public auth note {
            stopped = false;
        }
    
    }
    
    ////// src/osm.sol
    /// osm.sol - oracle security module
    
    // Copyright (C) 2018  DappHub, LLC
    
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU 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 General Public License for more details.
    
    // You should have received a copy of the GNU General Public License
    // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    /* pragma solidity ^0.4.24; */
    
    /* import "ds-auth/auth.sol"; */
    /* import "ds-stop/stop.sol"; */
    // import "ds-value/value.sol";
    
    interface DSValue {
        function peek() external returns (bytes32,bool);
        function read() external returns (bytes32);
    }
    
    contract OSM is DSAuth, DSStop {
        DSValue public src;
        
        uint16 constant ONE_HOUR = uint16(3600);
    
        uint16 public hop = ONE_HOUR;
        uint64 public zzz;
    
        struct Feed {
            uint128 val;
            bool    has;
        }
    
        Feed cur;
        Feed nxt;
    
        event LogValue(bytes32 val);
        
        constructor (DSValue src_) public {
            src = src_;
            (bytes32 wut, bool ok) = src_.peek();
            if (ok) {
                cur = nxt = Feed(uint128(wut), ok);
                zzz = prev(era());
            }
        }
    
        function era() internal view returns (uint) {
            return block.timestamp;
        }
    
        function prev(uint ts) internal view returns (uint64) {
            return uint64(ts - (ts % hop));
        }
    
        function step(uint16 ts) external auth {
            require(ts > 0);
            hop = ts;
        }
    
        function void() external auth {
            cur = nxt = Feed(0, false);
            stopped = true;
        }
    
        function pass() public view returns (bool ok) {
            return era() >= zzz + hop;
        }
    
        function poke() external stoppable {
            require(pass());
            (bytes32 wut, bool ok) = src.peek();
            cur = nxt;
            nxt = Feed(uint128(wut), ok);
            zzz = prev(era());
            emit LogValue(bytes32(cur.val));
        }
    
        function peek() external view returns (bytes32,bool) {
            return (bytes32(cur.val), cur.has);
        }
    
        function peep() external view returns (bytes32,bool) {
            return (bytes32(nxt.val), nxt.has);
        }
    
        function read() external view returns (bytes32) {
            require(cur.has);
            return (bytes32(cur.val));
        }
    }

    File 2 of 2: Medianizer
    // Medianizer
    // Copyright (C) 2017 Dapphub
    
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU 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 General Public License for more details.
    
    // You should have received a copy of the GNU General Public License
    // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    // hevm: flattened sources of src/medianizer.sol
    pragma solidity ^0.4.18;
    
    ////// lib/ds-value/lib/ds-thing/lib/ds-auth/src/auth.sol
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU 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 General Public License for more details.
    
    // You should have received a copy of the GNU General Public License
    // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    /* pragma solidity ^0.4.13; */
    
    contract DSAuthority {
        function canCall(
            address src, address dst, bytes4 sig
        ) public view returns (bool);
    }
    
    contract DSAuthEvents {
        event LogSetAuthority (address indexed authority);
        event LogSetOwner     (address indexed owner);
    }
    
    contract DSAuth is DSAuthEvents {
        DSAuthority  public  authority;
        address      public  owner;
    
        function DSAuth() public {
            owner = msg.sender;
            LogSetOwner(msg.sender);
        }
    
        function setOwner(address owner_)
            public
            auth
        {
            owner = owner_;
            LogSetOwner(owner);
        }
    
        function setAuthority(DSAuthority authority_)
            public
            auth
        {
            authority = authority_;
            LogSetAuthority(authority);
        }
    
        modifier auth {
            require(isAuthorized(msg.sender, msg.sig));
            _;
        }
    
        function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
            if (src == address(this)) {
                return true;
            } else if (src == owner) {
                return true;
            } else if (authority == DSAuthority(0)) {
                return false;
            } else {
                return authority.canCall(src, this, sig);
            }
        }
    }
    
    ////// lib/ds-value/lib/ds-thing/lib/ds-math/src/math.sol
    /// math.sol -- mixin for inline numerical wizardry
    
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU 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 General Public License for more details.
    
    // You should have received a copy of the GNU General Public License
    // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    /* pragma solidity ^0.4.13; */
    
    contract DSMath {
        function add(uint x, uint y) internal pure returns (uint z) {
            require((z = x + y) >= x);
        }
        function sub(uint x, uint y) internal pure returns (uint z) {
            require((z = x - y) <= x);
        }
        function mul(uint x, uint y) internal pure returns (uint z) {
            require(y == 0 || (z = x * y) / y == x);
        }
    
        function min(uint x, uint y) internal pure returns (uint z) {
            return x <= y ? x : y;
        }
        function max(uint x, uint y) internal pure returns (uint z) {
            return x >= y ? x : y;
        }
        function imin(int x, int y) internal pure returns (int z) {
            return x <= y ? x : y;
        }
        function imax(int x, int y) internal pure returns (int z) {
            return x >= y ? x : y;
        }
    
        uint constant WAD = 10 ** 18;
        uint constant RAY = 10 ** 27;
    
        function wmul(uint x, uint y) internal pure returns (uint z) {
            z = add(mul(x, y), WAD / 2) / WAD;
        }
        function rmul(uint x, uint y) internal pure returns (uint z) {
            z = add(mul(x, y), RAY / 2) / RAY;
        }
        function wdiv(uint x, uint y) internal pure returns (uint z) {
            z = add(mul(x, WAD), y / 2) / y;
        }
        function rdiv(uint x, uint y) internal pure returns (uint z) {
            z = add(mul(x, RAY), y / 2) / y;
        }
    
        // This famous algorithm is called "exponentiation by squaring"
        // and calculates x^n with x as fixed-point and n as regular unsigned.
        //
        // It's O(log n), instead of O(n) for naive repeated multiplication.
        //
        // These facts are why it works:
        //
        //  If n is even, then x^n = (x^2)^(n/2).
        //  If n is odd,  then x^n = x * x^(n-1),
        //   and applying the equation for even x gives
        //    x^n = x * (x^2)^((n-1) / 2).
        //
        //  Also, EVM division is flooring and
        //    floor[(n-1) / 2] = floor[n / 2].
        //
        function rpow(uint x, uint n) internal pure returns (uint z) {
            z = n % 2 != 0 ? x : RAY;
    
            for (n /= 2; n != 0; n /= 2) {
                x = rmul(x, x);
    
                if (n % 2 != 0) {
                    z = rmul(z, x);
                }
            }
        }
    }
    
    ////// lib/ds-value/lib/ds-thing/lib/ds-note/src/note.sol
    /// note.sol -- the `note' modifier, for logging calls as events
    
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU 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 General Public License for more details.
    
    // You should have received a copy of the GNU General Public License
    // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    /* pragma solidity ^0.4.13; */
    
    contract DSNote {
        event LogNote(
            bytes4   indexed  sig,
            address  indexed  guy,
            bytes32  indexed  foo,
            bytes32  indexed  bar,
            uint              wad,
            bytes             fax
        ) anonymous;
    
        modifier note {
            bytes32 foo;
            bytes32 bar;
    
            assembly {
                foo := calldataload(4)
                bar := calldataload(36)
            }
    
            LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);
    
            _;
        }
    }
    
    ////// lib/ds-value/lib/ds-thing/src/thing.sol
    // thing.sol - `auth` with handy mixins. your things should be DSThings
    
    // Copyright (C) 2017  DappHub, LLC
    
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU 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 General Public License for more details.
    
    // You should have received a copy of the GNU General Public License
    // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    /* pragma solidity ^0.4.13; */
    
    /* import 'ds-auth/auth.sol'; */
    /* import 'ds-note/note.sol'; */
    /* import 'ds-math/math.sol'; */
    
    contract DSThing is DSAuth, DSNote, DSMath {
    }
    
    ////// lib/ds-value/src/value.sol
    /// value.sol - a value is a simple thing, it can be get and set
    
    // Copyright (C) 2017  DappHub, LLC
    
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU 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 General Public License for more details.
    
    // You should have received a copy of the GNU General Public License
    // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    /* pragma solidity ^0.4.13; */
    
    /* import 'ds-thing/thing.sol'; */
    
    contract DSValue is DSThing {
        bool    has;
        bytes32 val;
        function peek() public view returns (bytes32, bool) {
            return (val,has);
        }
        function read() public view returns (bytes32) {
            var (wut, haz) = peek();
            assert(haz);
            return wut;
        }
        function poke(bytes32 wut) public note auth {
            val = wut;
            has = true;
        }
        function void() public note auth {  // unset the value
            has = false;
        }
    }
    
    ////// src/medianizer.sol
    /* pragma solidity ^0.4.18; */
    
    /* import 'ds-value/value.sol'; */
    
    contract MedianizerEvents {
        event LogValue(bytes32 val);
    }
    
    contract Medianizer is DSValue, MedianizerEvents {
        mapping (bytes12 => address) public values;
        mapping (address => bytes12) public indexes;
        bytes12 public next = 0x1;
    
        uint96 public min = 0x1;
    
        function set(address wat) public auth {
            bytes12 nextId = bytes12(uint96(next) + 1);
            assert(nextId != 0x0);
            this.set(next, wat);
            next = nextId;
        }
    
        function set(bytes12 pos, address wat) public note auth {
            require(pos != 0x0);
            require(wat == 0 || indexes[wat] == 0);
    
            indexes[values[pos]] = 0x0; // Making sure to remove a possible existing address in that position
    
            if (wat != 0) {
                indexes[wat] = pos;
            }
    
            values[pos] = wat;
        }
    
        function setMin(uint96 min_) public note auth {
            require(min_ != 0x0);
            min = min_;
        }
    
        function setNext(bytes12 next_) public note auth {
            require(next_ != 0x0);
            next = next_;
        }
    
        function unset(bytes12 pos) public auth {
            this.set(pos, 0);
        }
    
        function unset(address wat) public auth {
            this.set(indexes[wat], 0);
        }
    
        function poke() public {
            poke(0);
        }
    
        function poke(bytes32) public note {
            (val, has) = compute();
            LogValue(val);
        }
    
        function compute() public constant returns (bytes32, bool) {
            bytes32[] memory wuts = new bytes32[](uint96(next) - 1);
            uint96 ctr = 0;
            for (uint96 i = 1; i < uint96(next); i++) {
                if (values[bytes12(i)] != 0) {
                    var (wut, wuz) = DSValue(values[bytes12(i)]).peek();
                    if (wuz) {
                        if (ctr == 0 || wut >= wuts[ctr - 1]) {
                            wuts[ctr] = wut;
                        } else {
                            uint96 j = 0;
                            while (wut >= wuts[j]) {
                                j++;
                            }
                            for (uint96 k = ctr; k > j; k--) {
                                wuts[k] = wuts[k - 1];
                            }
                            wuts[j] = wut;
                        }
                        ctr++;
                    }
                }
            }
    
            if (ctr < min) {
                return (val, false);
            }
    
            bytes32 value;
            if (ctr % 2 == 0) {
                uint128 val1 = uint128(wuts[(ctr / 2) - 1]);
                uint128 val2 = uint128(wuts[ctr / 2]);
                value = bytes32(wdiv(add(val1, val2), 2 ether));
            } else {
                value = wuts[(ctr - 1) / 2];
            }
    
            return (value, true);
        }
    
    }