false
true
0

Contract Address Details

0xA3F68d722FBa26173aB64697B4625d4aD0F4C818

Contract Name
SatWeiPriceFeed
Creator
0xfc452e–d1d9af at 0xd7ad13–d62eb8
Balance
0 PLS ( )
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
26141727
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been partially verified via Sourcify. View contract in Sourcify repository
Contract name:
SatWeiPriceFeed




Optimization enabled
true
Compiler version
v0.5.17+commit.d19bba13




Optimization runs
200
EVM Version
istanbul




Verified at
2026-03-29T01:43:01.173818Z

solidity/contracts/price-feed/SatWeiPriceFeed.sol

/*
 Authored by Satoshi Nakamoto ?
 */

pragma solidity 0.5.17;

import {SafeMath} from "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "../external/IMedianizer.sol";
import "../interfaces/ISatWeiPriceFeed.sol";

/// @notice satoshi/wei price feed.
/// @dev Used ETH/USD medianizer values converted to sat/wei.
contract SatWeiPriceFeed is Ownable, ISatWeiPriceFeed {
    using SafeMath for uint256;

    bool private _initialized = false;
    address internal tbtcSystemAddress;

    IMedianizer[] private ethBtcFeeds;

    constructor() public {
    // solium-disable-previous-line no-empty-blocks
    }

    /// @notice Initialises the addresses of the ETHBTC price feeds.
    /// @param _tbtcSystemAddress Address of the `TBTCSystem` contract. Used for access control.
    /// @param _ETHBTCPriceFeed The ETHBTC price feed address.
    function initialize(
        address _tbtcSystemAddress,
        IMedianizer _ETHBTCPriceFeed
    )
        external onlyOwner
    {
        require(!_initialized, "Already initialized.");
        tbtcSystemAddress = _tbtcSystemAddress;
        ethBtcFeeds.push(_ETHBTCPriceFeed);
        _initialized = true;
    }

    /// @notice Get the current price of 1 satoshi in wei.
    /// @dev This does not account for any 'Flippening' event.
    /// @return The price of one satoshi in wei.
    function getPrice()
        external onlyTbtcSystem view returns (uint256)
    {
        bool ethBtcActive;
        uint256 ethBtc;

        for(uint i = 0; i < ethBtcFeeds.length; i++){
            (ethBtc, ethBtcActive) = ethBtcFeeds[i].peek();
            if(ethBtcActive) {
                break;
            }
        }

        require(ethBtcActive, "Price feed offline");

        // convert eth/btc to sat/wei
        // We typecast down to uint128, because the first 128 bits of
        // the medianizer value is unrelated to the price.
        return uint256(10**28).div(uint256(uint128(ethBtc)));
    }

    /// @notice Get the first active Medianizer contract from the ethBtcFeeds array.
    /// @return The address of the first Active Medianizer. address(0) if none found
    function getWorkingEthBtcFeed() external view returns (address){
        bool ethBtcActive;

        for(uint i = 0; i < ethBtcFeeds.length; i++){
            (, ethBtcActive) = ethBtcFeeds[i].peek();
            if(ethBtcActive) {
                return address(ethBtcFeeds[i]);
            }
        }
        return address(0);
    }

    /// @notice Add _ethBtcFeed to internal ethBtcFeeds array.
    /// @dev IMedianizer must be active in order to add.
    function addEthBtcFeed(IMedianizer _ethBtcFeed) external onlyTbtcSystem {
        bool ethBtcActive;
        (, ethBtcActive) = _ethBtcFeed.peek();
        require(ethBtcActive, "Cannot add inactive feed");
        ethBtcFeeds.push(_ethBtcFeed);
    }

    /// @notice Function modifier ensures modified function is only called by tbtcSystemAddress.
    modifier onlyTbtcSystem(){
        require(msg.sender == tbtcSystemAddress, "Caller must be tbtcSystem contract");
        _;
    }
}
        

/IMedianizer.sol

pragma solidity 0.5.17;

/// @notice A medianizer price feed.
/// @dev Based off the MakerDAO medianizer (https://github.com/makerdao/median)
interface IMedianizer {
    /// @notice Get the current price.
    /// @dev May revert if caller not whitelisted.
    /// @return Designated price with 18 decimal places.
    function read() external view returns (uint256);

    /// @notice Get the current price and check if the price feed is active
    /// @dev May revert if caller not whitelisted.
    /// @return Designated price with 18 decimal places.
    /// @return true if price is > 0, else returns false
    function peek() external view returns (uint256, bool);
}
          

/ISatWeiPriceFeed.sol

pragma solidity 0.5.17;

import "../external/IMedianizer.sol";

/// @notice satoshi/wei price feed interface.
interface ISatWeiPriceFeed {
    /// @notice Get the current price of 1 satoshi in wei.
    /// @dev This does not account for any 'Flippening' event.
    /// @return The price of one satoshi in wei.
    function getPrice() external view returns (uint256);

    /// @notice add a new ETH/BTC meidanizer to the internal ethBtcFeeds array
    function addEthBtcFeed(IMedianizer _ethBtcFeed) external;
}
          

/Ownable.sol

pragma solidity ^0.5.0;

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be aplied to your functions to restrict their use to
 * the owner.
 */
contract Ownable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        _owner = msg.sender;
        emit OwnershipTransferred(address(0), _owner);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return msg.sender == _owner;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * > Note: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}
          

/SafeMath.sol

pragma solidity ^0.5.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, "SafeMath: division by zero");
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b != 0, "SafeMath: modulo by zero");
        return a % b;
    }
}
          

Compiler Settings

{"remappings":[],"optimizer":{"runs":200,"enabled":true},"metadata":{"useLiteralContent":true},"libraries":{},"evmVersion":"istanbul","compilationTarget":{"solidity/contracts/price-feed/SatWeiPriceFeed.sol":"SatWeiPriceFeed"}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[]},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"addEthBtcFeed","inputs":[{"type":"address","name":"_ethBtcFeed","internalType":"contract IMedianizer"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPrice","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getWorkingEthBtcFeed","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_tbtcSystemAddress","internalType":"address"},{"type":"address","name":"_ETHBTCPriceFeed","internalType":"contract IMedianizer"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isOwner","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"renounceOwnership","inputs":[],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}],"constant":false}]
              

Contract Creation Code

Verify & Publish
0x60806040526000805460ff60a01b1916905534801561001d57600080fd5b50600080546001600160a01b03191633178082556040516001600160a01b039190911691907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3610906806100766000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806398d5fdca1161005b57806398d5fdca14610105578063d14dd4131461011f578063e6f5c60a14610145578063f2fde38b1461014d57610088565b8063485cc9551461008d578063715018a6146100bd5780638da5cb5b146100c55780638f32d59b146100e9575b600080fd5b6100bb600480360360408110156100a357600080fd5b506001600160a01b0381358116916020013516610173565b005b6100bb610294565b6100cd610337565b604080516001600160a01b039092168252519081900360200190f35b6100f1610347565b604080519115158252519081900360200190f35b61010d610358565b60408051918252519081900360200190f35b6100bb6004803603602081101561013557600080fd5b50356001600160a01b03166104dc565b6100cd610635565b6100bb6004803603602081101561016357600080fd5b50356001600160a01b031661071a565b61017b610347565b6101cc576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600054600160a01b900460ff1615610222576040805162461bcd60e51b815260206004820152601460248201527320b63932b0b23c9034b734ba34b0b634bd32b21760611b604482015290519081900360640190fd5b600180546001600160a01b039384166001600160a01b031991821617825560028054928301815560009081527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace909201805493909416921691909117909155805460ff60a01b1916600160a01b179055565b61029c610347565b6102ed576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b03165b90565b6000546001600160a01b0316331490565b6001546000906001600160a01b031633146103a45760405162461bcd60e51b81526004018080602001828103825260228152602001806108b06022913960400191505060405180910390fd5b600080805b60025481101561045f57600281815481106103c057fe5b9060005260206000200160009054906101000a90046001600160a01b03166001600160a01b03166359e02dd76040518163ffffffff1660e01b8152600401604080518083038186803b15801561041557600080fd5b505afa158015610429573d6000803e3d6000fd5b505050506040513d604081101561043f57600080fd5b5080516020909101519350915082156104575761045f565b6001016103a9565b50816104a7576040805162461bcd60e51b815260206004820152601260248201527150726963652066656564206f66666c696e6560701b604482015290519081900360640190fd5b6104d56b204fce5e3e250261100000006fffffffffffffffffffffffffffffffff831663ffffffff61077f16565b9250505090565b6001546001600160a01b031633146105255760405162461bcd60e51b81526004018080602001828103825260228152602001806108b06022913960400191505060405180910390fd5b6000816001600160a01b03166359e02dd76040518163ffffffff1660e01b8152600401604080518083038186803b15801561055f57600080fd5b505afa158015610573573d6000803e3d6000fd5b505050506040513d604081101561058957600080fd5b50602001519050806105e2576040805162461bcd60e51b815260206004820152601860248201527f43616e6e6f742061646420696e61637469766520666565640000000000000000604482015290519081900360640190fd5b50600280546001810182556000919091527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319166001600160a01b0392909216919091179055565b600080805b600254811015610711576002818154811061065157fe5b9060005260206000200160009054906101000a90046001600160a01b03166001600160a01b03166359e02dd76040518163ffffffff1660e01b8152600401604080518083038186803b1580156106a657600080fd5b505afa1580156106ba573d6000803e3d6000fd5b505050506040513d60408110156106d057600080fd5b50602001519150811561070957600281815481106106ea57fe5b6000918252602090912001546001600160a01b03169250610344915050565b60010161063a565b50600091505090565b610722610347565b610773576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61077c816107e9565b50565b60008082116107d5576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b60008284816107e057fe5b04949350505050565b6001600160a01b03811661082e5760405162461bcd60e51b815260040180806020018281038252602681526020018061088a6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b039290921691909117905556fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737343616c6c6572206d757374206265207462746353797374656d20636f6e7472616374a265627a7a7231582056b8a4cee5b6827feedb5db89a693021041d5a964ea5635098eab2b923081a8764736f6c63430005110032

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100885760003560e01c806398d5fdca1161005b57806398d5fdca14610105578063d14dd4131461011f578063e6f5c60a14610145578063f2fde38b1461014d57610088565b8063485cc9551461008d578063715018a6146100bd5780638da5cb5b146100c55780638f32d59b146100e9575b600080fd5b6100bb600480360360408110156100a357600080fd5b506001600160a01b0381358116916020013516610173565b005b6100bb610294565b6100cd610337565b604080516001600160a01b039092168252519081900360200190f35b6100f1610347565b604080519115158252519081900360200190f35b61010d610358565b60408051918252519081900360200190f35b6100bb6004803603602081101561013557600080fd5b50356001600160a01b03166104dc565b6100cd610635565b6100bb6004803603602081101561016357600080fd5b50356001600160a01b031661071a565b61017b610347565b6101cc576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600054600160a01b900460ff1615610222576040805162461bcd60e51b815260206004820152601460248201527320b63932b0b23c9034b734ba34b0b634bd32b21760611b604482015290519081900360640190fd5b600180546001600160a01b039384166001600160a01b031991821617825560028054928301815560009081527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace909201805493909416921691909117909155805460ff60a01b1916600160a01b179055565b61029c610347565b6102ed576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b03165b90565b6000546001600160a01b0316331490565b6001546000906001600160a01b031633146103a45760405162461bcd60e51b81526004018080602001828103825260228152602001806108b06022913960400191505060405180910390fd5b600080805b60025481101561045f57600281815481106103c057fe5b9060005260206000200160009054906101000a90046001600160a01b03166001600160a01b03166359e02dd76040518163ffffffff1660e01b8152600401604080518083038186803b15801561041557600080fd5b505afa158015610429573d6000803e3d6000fd5b505050506040513d604081101561043f57600080fd5b5080516020909101519350915082156104575761045f565b6001016103a9565b50816104a7576040805162461bcd60e51b815260206004820152601260248201527150726963652066656564206f66666c696e6560701b604482015290519081900360640190fd5b6104d56b204fce5e3e250261100000006fffffffffffffffffffffffffffffffff831663ffffffff61077f16565b9250505090565b6001546001600160a01b031633146105255760405162461bcd60e51b81526004018080602001828103825260228152602001806108b06022913960400191505060405180910390fd5b6000816001600160a01b03166359e02dd76040518163ffffffff1660e01b8152600401604080518083038186803b15801561055f57600080fd5b505afa158015610573573d6000803e3d6000fd5b505050506040513d604081101561058957600080fd5b50602001519050806105e2576040805162461bcd60e51b815260206004820152601860248201527f43616e6e6f742061646420696e61637469766520666565640000000000000000604482015290519081900360640190fd5b50600280546001810182556000919091527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319166001600160a01b0392909216919091179055565b600080805b600254811015610711576002818154811061065157fe5b9060005260206000200160009054906101000a90046001600160a01b03166001600160a01b03166359e02dd76040518163ffffffff1660e01b8152600401604080518083038186803b1580156106a657600080fd5b505afa1580156106ba573d6000803e3d6000fd5b505050506040513d60408110156106d057600080fd5b50602001519150811561070957600281815481106106ea57fe5b6000918252602090912001546001600160a01b03169250610344915050565b60010161063a565b50600091505090565b610722610347565b610773576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61077c816107e9565b50565b60008082116107d5576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b60008284816107e057fe5b04949350505050565b6001600160a01b03811661082e5760405162461bcd60e51b815260040180806020018281038252602681526020018061088a6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b039290921691909117905556fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737343616c6c6572206d757374206265207462746353797374656d20636f6e7472616374a265627a7a7231582056b8a4cee5b6827feedb5db89a693021041d5a964ea5635098eab2b923081a8764736f6c63430005110032