Contract 0xE6a423C642c5B264a430a2238EEe4343BA462063

 
Txn Hash
Method
Block
From
To
Value
0x01a8c75be752367e0529049d63be65d463627685887191d2d33bfaeb44b080fd0x60806040148469872022-05-26 8:31:55127 days 18 hrs ago0xaa3ab47924157a55963cddc6b10bcac1e1d0507c IN  Create: BackendPriceProvider0 Ether0.1275511590
[ Download CSV Export 
View more zero value Internal Transactions in Advanced View mode
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BackendPriceProvider

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 12 : BackendPriceProvider.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import "./PriceProvider.sol";
import "../../openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../../openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "../../openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";

/**
 * Backend price verifier.
 */
contract BackendPriceProvider is PriceProvider,
                                 Initializable,
                                 AccessControlUpgradeable
{

    bytes32 public constant TRUSTED_BACKEND_ROLE = keccak256("TRUSTED_BACKEND_ROLE");

    string public constant DESCRIPTION = "Price provider that uses trusted backend";

    uint8 public usdDecimals;

    mapping(address => BackendMetadata) public backendMetadata;

    struct BackendMetadata {
        bool isListed; // true - listed, false - not listed
        bool isActive; // true - active, false - not active
    }

    event GrandTrustedBackendRole(address indexed who, address indexed newTrustedBackend);
    event RevokeTrustedBackendRole(address indexed who, address indexed trustedBackend);
    event SetToken(address indexed who, address indexed token);
    event ChangeActive(address indexed who, address indexed token, bool active);
    

    function initialize() public initializer {
        __AccessControl_init();
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(TRUSTED_BACKEND_ROLE, msg.sender);
        usdDecimals = 6;
    }

    modifier onlyAdmin() {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not the Admin");
        _;
    }

    modifier onlyTrustedBackend() {
        require(hasRole(TRUSTED_BACKEND_ROLE, msg.sender), "Caller is not the trusted backend");
        _;
    }

    /****************** Admin functions ****************** */

    function grandTrustedBackendRole(address newTrustedBackend) public onlyAdmin {
        grantRole(TRUSTED_BACKEND_ROLE, newTrustedBackend);
        emit GrandTrustedBackendRole(msg.sender, newTrustedBackend);
    }

    function revokeTrustedBackendRole(address trustedBackend) public onlyAdmin {
        revokeRole(TRUSTED_BACKEND_ROLE, trustedBackend);
        emit RevokeTrustedBackendRole(msg.sender, trustedBackend);
    }

    /****************** TrustedBackendRole functions ****************** */

    function setToken(address token) public onlyTrustedBackend {
        backendMetadata[token].isListed = true;
        backendMetadata[token].isActive = true;
        emit SetToken(msg.sender, token);
    }

    function changeActive(address token, bool active) public override onlyTrustedBackend {
        backendMetadata[token].isActive = active;
        emit ChangeActive(msg.sender, token, active);
    }

    /****************** sign steps ****************** */

    /**
     * @notice 1. step. Backend creates offchain data and get hash of this data. This data calls message.
     * @dev returns the keccak256 of concatenated input data
     * @param token the address of asset
     * @param priceMantissa the price of asset that include decimals
     * @param validTo the unix timestamp in seconds that define the validity of given price to `validTo` timestamp
     */
    function getMessageHash(address token, uint256 priceMantissa, uint256 validTo) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(token, priceMantissa, validTo));
    }

    /**
     * @notice 2. step. Backend formatting the message and get hash of this message.
     * @dev returns the keccak256 of formatted message
     * @param messageHash the keccak256 of message
     */
    function getEthSignedMessageHash(bytes32 messageHash) public pure returns (bytes32){
        /*
        Signature is produced by signing a keccak256 hash with the following format:
        "\x19Ethereum Signed Message\n" + len(msg) + msg
        Where   + (plus) is concatenation operation
                \x19 is 0x19
                len(msg) = 32, because keccak256 returns 32 bytes, i.e. lenght of data is 32 bytes
                msg is hash of massage
        */
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", messageHash));
    }

    /**
     * @notice 3. step. Backend sign the message using web3 library and get signature.
        # using browser
        account = "copy paste account of signer here"
        ethereum.request({ method: "personal_sign", params: [account, hash]}).then(console.log)

        # using web3
        web3.personal.sign(hash, web3.eth.defaultAccount, console.log)
        
        # using rust secp256k1 and web3:
        let signature = secret_key.sign(&ethSignedMessageHash,None).unwrap();

        Signature will be different for different accounts
        Example of sign:
        0x993dab3dd91f5c6dc28e17439be475478f5635c92a56e17e82349d3fb2f166196f466c0b4e0c146f285204f0dcb13e5ae67bc33f4b888ec32dfe0a063e8f3f781b
        
        Than backend provide the tuple:
        (token, priceMantissa, priceDecimals, validTo, signature)
     */

    /**
     * @notice 4. step. Smart contract verify the message (tuple)
     * @dev returns true if the message is signed by trusted backend. Else returns false.
     * @param token the address of asset
     * @param priceMantissa the price of asset that include decimals
     * @param validTo the unix timestamp in seconds that define the validity of given price to `validTo` timestamp
     * @param signature the sign of message.
     */
    function verify(address token, uint256 priceMantissa, uint256 validTo, bytes memory signature) public view returns (bool) {
        require(block.timestamp <= validTo, "BackendPriceProvider: expired price!");
        
        bytes32 messageHash = getMessageHash(token, priceMantissa, validTo);
        bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash);

        address messageSigner = recoverSigner(ethSignedMessageHash, signature);
        return hasRole(TRUSTED_BACKEND_ROLE, messageSigner);
    }

    /**
     * @dev returns the signer of `ethSignedMessageHash`
     */
    function recoverSigner(bytes32 ethSignedMessageHash, bytes memory signature) public pure returns (address){
        require(signature.length == 65, "BackendPriceProvider: invalid signature length");
        bytes32 r; bytes32 s; uint8 v; //splitting signature in (r,s,v)
        assembly {
            /*
            First 32 bytes stores the length of the signature

            add(sig, 32) = pointer of sig + 32
            effectively, skips first 32 bytes of signature

            mload(p) loads next 32 bytes starting at the memory address p into memory
            */
            // first 32 bytes, after the length prefix
            r := mload(add(signature, 32))
            // second 32 bytes
            s := mload(add(signature, 64))
            // final byte (first byte of the next 32 bytes)
            v := byte(0, mload(add(signature, 96)))
        }
        //return the signer by ecrecover
        return ecrecover(ethSignedMessageHash, v, r, s);
    }

    /****************** end sign functions ****************** */

    /****************** View functions ****************** */

    function isListed(address token) public override view returns(bool){
        return backendMetadata[token].isListed;
    }

    function isActive(address token) public override view returns(bool){
        return backendMetadata[token].isActive;
    }

    /**
     * @notice Returns the latest asset price and price decimals
     * @param token the token address
     */
    function getPrice(address token) public override pure returns(uint256 price, uint8 priceDecimals) {
        token; price; priceDecimals;
        revert("Use getPriceSigned(...)");
    }

    function getPriceSigned(address token, uint256 priceMantissa, uint256 validTo, bytes memory signature) public override view returns(uint256 _priceMantissa, uint8 priceDecimals){
        require(isActive(token),"BackendPriceProvider: token is not active!");
        require(verify(token, priceMantissa, validTo, signature),"BackendPriceProvider: signer is not moderator");
        return (priceMantissa, getPriceDecimals());
    }

    function getEvaluation(address token, uint256 tokenAmount) public override pure returns(uint256 evaluation) {
        token; tokenAmount; evaluation;
        revert("Use getEvaluationSigned(...)");
    }
    
    /**
     * @dev return the evaluation in $ of `tokenAmount` with signed price
     * @param token the address of token to get evaluation in $
     * @param tokenAmount the amount of token to get evaluation. Amount is scaled by 10 in power token decimals
     * @param priceMantissa the price multiplied by priceDecimals. The dimension of priceMantissa should be $/token
     * @param validTo the timestamp in seconds, when price is gonna be not valid.
     * @param signature the ECDSA sign on eliptic curve secp256k1.        
     */
    function getEvaluationSigned(address token, uint256 tokenAmount, uint256 priceMantissa, uint256 validTo, bytes memory signature) public override view returns(uint256 evaluation){
        require(isActive(token),"BackendPriceProvider: token is not active!");
        require(verify(token, priceMantissa, validTo, signature), "BackendPriceProvider: signer is not moderator");
        evaluation = tokenAmount * priceMantissa / (10 ** getPriceDecimals());
        uint8 tokenDecimals = ERC20Upgradeable(token).decimals();
        if (tokenDecimals >= usdDecimals) {
            evaluation = evaluation / (10 ** (tokenDecimals - usdDecimals)); //get the evaluation in USD.
        } else {
            evaluation = evaluation * (10 ** (usdDecimals - tokenDecimals)); 
        }
    }

    function getPriceDecimals() public view override returns (uint8) {
        return usdDecimals;
    }
}

File 2 of 12 : PriceProvider.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

abstract contract PriceProvider {

    function changeActive(address token, bool active) public virtual {}

    /****************** view functions ****************** */

    function isActive(address token) public virtual view returns(bool) {}

    function isListed(address token) public virtual view returns(bool) {}

    function getPrice(address token) public virtual view returns(uint256 priceMantissa, uint8 priceDecimals) {}

    function getPriceSigned(address token, uint256 priceMantissa, uint256 validTo, bytes memory signature) public virtual view returns(uint256 _priceMantissa, uint8 _priceDecimals) {}

    function getEvaluation(address token, uint256 tokenAmount) public virtual view returns(uint256 evaluation) {}
    
    /**
     * @dev return the evaluation in $ of `tokenAmount` with signed price
     * @param token the address of token to get evaluation in $
     * @param tokenAmount the amount of token to get evaluation. Amount is scaled by 10 in power token decimals
     * @param priceMantissa the price multiplied by priceDecimals. The dimension of priceMantissa should be $/token
     * @param validTo the timestamp in seconds, when price is gonna be not valid.
     * @param signature the ECDSA sign on eliptic curve secp256k1.        
     */
    function getEvaluationSigned(address token, uint256 tokenAmount, uint256 priceMantissa, uint256 validTo, bytes memory signature) public virtual view returns(uint256 evaluation) {}

    function getPriceDecimals() public virtual view returns (uint8 priceDecimals) {}

}

File 3 of 12 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 4 of 12 : ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    function __ERC20_init(string memory name_, string memory symbol_) internal initializer {
        __Context_init_unchained();
        __ERC20_init_unchained(name_, symbol_);
    }

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(_msgSender(), spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
    uint256[45] private __gap;
}

File 5 of 12 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
    }

    function __AccessControl_init_unchained() internal initializer {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(uint160(account), 20),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
    uint256[49] private __gap;
}

File 6 of 12 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 7 of 12 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 8 of 12 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal initializer {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal initializer {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 9 of 12 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 10 of 12 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 11 of 12 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal initializer {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal initializer {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

File 12 of 12 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"who","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"active","type":"bool"}],"name":"ChangeActive","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"who","type":"address"},{"indexed":true,"internalType":"address","name":"newTrustedBackend","type":"address"}],"name":"GrandTrustedBackendRole","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"who","type":"address"},{"indexed":true,"internalType":"address","name":"trustedBackend","type":"address"}],"name":"RevokeTrustedBackendRole","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"who","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"}],"name":"SetToken","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DESCRIPTION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TRUSTED_BACKEND_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"backendMetadata","outputs":[{"internalType":"bool","name":"isListed","type":"bool"},{"internalType":"bool","name":"isActive","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"active","type":"bool"}],"name":"changeActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"name":"getEthSignedMessageHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"getEvaluation","outputs":[{"internalType":"uint256","name":"evaluation","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"uint256","name":"priceMantissa","type":"uint256"},{"internalType":"uint256","name":"validTo","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"getEvaluationSigned","outputs":[{"internalType":"uint256","name":"evaluation","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"priceMantissa","type":"uint256"},{"internalType":"uint256","name":"validTo","type":"uint256"}],"name":"getMessageHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"priceDecimals","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getPriceDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"priceMantissa","type":"uint256"},{"internalType":"uint256","name":"validTo","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"getPriceSigned","outputs":[{"internalType":"uint256","name":"_priceMantissa","type":"uint256"},{"internalType":"uint8","name":"priceDecimals","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newTrustedBackend","type":"address"}],"name":"grandTrustedBackendRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isListed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"ethSignedMessageHash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"recoverSigner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"trustedBackend","type":"address"}],"name":"revokeTrustedBackendRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"setToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usdDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"priceMantissa","type":"uint256"},{"internalType":"uint256","name":"validTo","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"verify","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506118ae806100206000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c806381fd01ea116100f9578063abc3644411610097578063ec39004b11610071578063ec39004b146103ff578063f1ae885614610414578063f794062e14610429578063fa5408011461045557600080fd5b8063abc36444146103c6578063d2b0737b146103d9578063d547741f146103ec57600080fd5b80639f8a13d7116100d35780639f8a13d714610337578063a217fddf14610368578063a5c6822614610370578063a980ff071461038357600080fd5b806381fd01ea146102e657806391d14854146102f957806397aba7f91461030c57600080fd5b8063258a45321161016657806341976e091161014057806341976e09146102ab5780636058bde5146102be57806366a4b6c0146102d15780638129fc1c146102de57600080fd5b8063258a4532146102725780632f2ff15d1461028557806336568abe1461029857600080fd5b806301ffc9a7146101ae5780630deea608146101d6578063144fa6d7146101e957806319ed931d146101fe5780631b30aafc14610228578063248a9ca314610241575b600080fd5b6101c16101bc366004611168565b610468565b60405190151581526020015b60405180910390f35b6101c16101e4366004611251565b61049f565b6101fc6101f73660046112b2565b610550565b005b61021161020c366004611251565b6105d3565b6040805192835260ff9091166020830152016101cd565b60975460ff165b60405160ff90911681526020016101cd565b61026461024f3660046112cd565b60009081526065602052604090206001015490565b6040519081526020016101cd565b6101fc6102803660046112e6565b610654565b6101fc610293366004611322565b6106f5565b6101fc6102a6366004611322565b610720565b6102116102b93660046112b2565b61079e565b6101fc6102cc3660046112b2565b6107eb565b60975461022f9060ff1681565b6101fc61088d565b6102646102f436600461134e565b610931565b6101c1610307366004611322565b61097c565b61031f61031a366004611378565b6109a7565b6040516001600160a01b0390911681526020016101cd565b6101c16103453660046112b2565b6001600160a01b0316600090815260986020526040902054610100900460ff1690565b610264600081565b61026461037e3660046113bf565b610a86565b6103af6103913660046112b2565b60986020526000908152604090205460ff8082169161010090041682565b6040805192151583529015156020830152016101cd565b6101fc6103d43660046112b2565b610bf7565b6102646103e736600461142a565b610c99565b6101fc6103fa366004611322565b610ce8565b61026460008051602061183183398151915281565b61041c610d0e565b6040516101cd919061148d565b6101c16104373660046112b2565b6001600160a01b031660009081526098602052604090205460ff1690565b6102646104633660046112cd565b610d2a565b60006001600160e01b03198216637965db0b60e01b148061049957506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000824211156105025760405162461bcd60e51b8152602060048201526024808201527f4261636b656e64507269636550726f76696465723a20657870697265642070726044820152636963652160e01b60648201526084015b60405180910390fd5b600061050f868686610c99565b9050600061051c82610d2a565b9050600061052a82866109a7565b90506105446000805160206118318339815191528261097c565b98975050505050505050565b6105686000805160206118318339815191523361097c565b6105845760405162461bcd60e51b81526004016104f9906114c0565b6001600160a01b038116600081815260986020526040808220805461ffff19166101011790555133917f2fbf043b3496ffa4fee9402ff8bd239c1d7870465d0d095438df831b81e0defb91a350565b6001600160a01b0384166000908152609860205260408120548190610100900460ff166106125760405162461bcd60e51b81526004016104f990611501565b61061e8686868661049f565b61063a5760405162461bcd60e51b81526004016104f99061154b565b8461064760975460ff1690565b9150915094509492505050565b61066c6000805160206118318339815191523361097c565b6106885760405162461bcd60e51b81526004016104f9906114c0565b6001600160a01b0382166000818152609860205260409081902080548415156101000261ff00199091161790555133907fc871914c1db1064902dc2618178ec19d5b0899de5c0a9164486c3e0bd59ec133906106e990851515815260200190565b60405180910390a35050565b6000828152606560205260409020600101546107118133610d7d565b61071b8383610de1565b505050565b6001600160a01b03811633146107905760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016104f9565b61079a8282610e67565b5050565b60405162461bcd60e51b815260206004820152601760248201527f5573652067657450726963655369676e6564282e2e2e29000000000000000000604482015260009081906064016104f9565b6107f660003361097c565b61083c5760405162461bcd60e51b815260206004820152601760248201527621b0b63632b91034b9903737ba103a34329020b236b4b760491b60448201526064016104f9565b610854600080516020611831833981519152826106f5565b6040516001600160a01b0382169033907f06614c3105572a1af7de6dcfa48a48326571f8e799b724f948dab59c49e1268190600090a350565b600054610100900460ff16806108a6575060005460ff16155b6108c25760405162461bcd60e51b81526004016104f990611598565b600054610100900460ff161580156108e4576000805461ffff19166101011790555b6108ec610ece565b6108f7600033610f51565b61090f60008051602061183183398151915233610f51565b6097805460ff19166006179055801561092e576000805461ff00191690555b50565b60405162461bcd60e51b815260206004820152601c60248201527f557365206765744576616c756174696f6e5369676e6564282e2e2e290000000060448201526000906064016104f9565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60008151604114610a115760405162461bcd60e51b815260206004820152602e60248201527f4261636b656e64507269636550726f76696465723a20696e76616c696420736960448201526d0cedcc2e8eae4ca40d8cadccee8d60931b60648201526084016104f9565b602082810151604080850151606080870151835160008082529681018086528a9052951a928501839052840183905260808401819052919260019060a0016020604051602081039080840390855afa158015610a71573d6000803e3d6000fd5b5050604051601f190151979650505050505050565b6001600160a01b038516600090815260986020526040812054610100900460ff16610ac35760405162461bcd60e51b81526004016104f990611501565b610acf8685858561049f565b610aeb5760405162461bcd60e51b81526004016104f99061154b565b60975460ff16610afc90600a6116e0565b610b0685876116ef565b610b10919061170e565b90506000866001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610b4d57600080fd5b505afa158015610b61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b859190611730565b60975490915060ff90811690821610610bc457609754610ba89060ff1682611753565b610bb390600a6116e0565b610bbd908361170e565b9150610bed565b609754610bd590829060ff16611753565b610be090600a6116e0565b610bea90836116ef565b91505b5095945050505050565b610c0260003361097c565b610c485760405162461bcd60e51b815260206004820152601760248201527621b0b63632b91034b9903737ba103a34329020b236b4b760491b60448201526064016104f9565b610c6060008051602061183183398151915282610ce8565b6040516001600160a01b0382169033907f18204b83a91dadeda3c26bc5edc7e95204d0d6f4b75ba7024b04c79d66ef2e8390600090a350565b6040516bffffffffffffffffffffffff19606085901b16602082015260348101839052605481018290526000906074016040516020818303038152906040528051906020012090509392505050565b600082815260656020526040902060010154610d048133610d7d565b61071b8383610e67565b6040518060600160405280602881526020016118516028913981565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b610d87828261097c565b61079a57610d9f816001600160a01b03166014610f5b565b610daa836020610f5b565b604051602001610dbb929190611776565b60408051601f198184030181529082905262461bcd60e51b82526104f99160040161148d565b610deb828261097c565b61079a5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055610e233390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610e71828261097c565b1561079a5760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600054610100900460ff1680610ee7575060005460ff16155b610f035760405162461bcd60e51b81526004016104f990611598565b600054610100900460ff16158015610f25576000805461ffff19166101011790555b610f2d6110fe565b610f356110fe565b610f3d6110fe565b801561092e576000805461ff001916905550565b61079a8282610de1565b60606000610f6a8360026116ef565b610f759060026117eb565b67ffffffffffffffff811115610f8d57610f8d6111ae565b6040519080825280601f01601f191660200182016040528015610fb7576020820181803683370190505b509050600360fc1b81600081518110610fd257610fd2611803565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061100157611001611803565b60200101906001600160f81b031916908160001a90535060006110258460026116ef565b6110309060016117eb565b90505b60018111156110a8576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061106457611064611803565b1a60f81b82828151811061107a5761107a611803565b60200101906001600160f81b031916908160001a90535060049490941c936110a181611819565b9050611033565b5083156110f75760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016104f9565b9392505050565b600054610100900460ff1680611117575060005460ff16155b6111335760405162461bcd60e51b81526004016104f990611598565b600054610100900460ff16158015610f3d576000805461ffff1916610101179055801561092e576000805461ff001916905550565b60006020828403121561117a57600080fd5b81356001600160e01b0319811681146110f757600080fd5b80356001600160a01b03811681146111a957600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126111d557600080fd5b813567ffffffffffffffff808211156111f0576111f06111ae565b604051601f8301601f19908116603f01168101908282118183101715611218576112186111ae565b8160405283815286602085880101111561123157600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561126757600080fd5b61127085611192565b93506020850135925060408501359150606085013567ffffffffffffffff81111561129a57600080fd5b6112a6878288016111c4565b91505092959194509250565b6000602082840312156112c457600080fd5b6110f782611192565b6000602082840312156112df57600080fd5b5035919050565b600080604083850312156112f957600080fd5b61130283611192565b91506020830135801515811461131757600080fd5b809150509250929050565b6000806040838503121561133557600080fd5b8235915061134560208401611192565b90509250929050565b6000806040838503121561136157600080fd5b61136a83611192565b946020939093013593505050565b6000806040838503121561138b57600080fd5b82359150602083013567ffffffffffffffff8111156113a957600080fd5b6113b5858286016111c4565b9150509250929050565b600080600080600060a086880312156113d757600080fd5b6113e086611192565b9450602086013593506040860135925060608601359150608086013567ffffffffffffffff81111561141157600080fd5b61141d888289016111c4565b9150509295509295909350565b60008060006060848603121561143f57600080fd5b61144884611192565b95602085013595506040909401359392505050565b60005b83811015611478578181015183820152602001611460565b83811115611487576000848401525b50505050565b60208152600082518060208401526114ac81604085016020870161145d565b601f01601f19169190910160400192915050565b60208082526021908201527f43616c6c6572206973206e6f74207468652074727573746564206261636b656e6040820152601960fa1b606082015260800190565b6020808252602a908201527f4261636b656e64507269636550726f76696465723a20746f6b656e206973206e6040820152696f74206163746976652160b01b606082015260800190565b6020808252602d908201527f4261636b656e64507269636550726f76696465723a207369676e65722069732060408201526c3737ba1036b7b232b930ba37b960991b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600181815b8085111561163757816000190482111561161d5761161d6115e6565b8085161561162a57918102915b93841c9390800290611601565b509250929050565b60008261164e57506001610499565b8161165b57506000610499565b8160018114611671576002811461167b57611697565b6001915050610499565b60ff84111561168c5761168c6115e6565b50506001821b610499565b5060208310610133831016604e8410600b84101617156116ba575081810a610499565b6116c483836115fc565b80600019048211156116d8576116d86115e6565b029392505050565b60006110f760ff84168361163f565b6000816000190483118215151615611709576117096115e6565b500290565b60008261172b57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561174257600080fd5b815160ff811681146110f757600080fd5b600060ff821660ff84168082101561176d5761176d6115e6565b90039392505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516117ae81601785016020880161145d565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516117df81602884016020880161145d565b01602801949350505050565b600082198211156117fe576117fe6115e6565b500190565b634e487b7160e01b600052603260045260246000fd5b600081611828576118286115e6565b50600019019056fe3fbd90d0a44c3c0feaeb60de04a3a97656cc0924f298a33bfe8fa78307fc48aa50726963652070726f7669646572207468617420757365732074727573746564206261636b656e64a2646970667358221220acb90b2555c968d90582e1cca448d6050166d047211bd7a4176fd76edfa8694164736f6c63430008090033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

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.