ETH Price: $2,067.22 (-4.91%)

Contract

0x39b44c5d7469f50E9500A2de36d9e3DbB6f9278e
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xC4939981...15cb3e493
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
ReverseMultiplicativePriceFeed

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 1 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.15;

import "../vendor/@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import "../IPriceFeed.sol";

/**
 * @title Reverse multiplicative price feed
 * @notice A custom price feed that multiplies the price from one price feed and the inverse price from another price feed and returns the result
 * @dev for example if we need tokenX to eth, but there is only tokenX to usd, we can use this price feed to get tokenX to eth: tokenX to usd * reversed(eth to usd)
 * @author Compound
 */
contract ReverseMultiplicativePriceFeed is IPriceFeed {
    /** Custom errors **/
    error BadDecimals();
    error InvalidInt256();

    /// @notice Version of the price feed
    uint public constant VERSION = 1;

    /// @notice Description of the price feed
    string public override description;

    /// @notice Number of decimals for returned prices
    uint8 public immutable override decimals;

    /// @notice Chainlink price feed A
    address public immutable priceFeedA;

    /// @notice Chainlink price feed B
    address public immutable priceFeedB;

    /// @notice Price feed A scale
    int public immutable priceFeedAScale;

    /// @notice Price feed B scale
    int public immutable priceFeedBScale;

    /// @notice Scale of this price feed
    int public immutable priceFeedScale;

    /**
     * @notice Construct a new reverse multiplicative price feed
     * @param priceFeedA_ The address of the first price feed to fetch prices from
     * @param priceFeedB_ The address of the second price feed to fetch prices from that should be reversed
     * @param decimals_ The number of decimals for the returned prices
     * @param description_ The description of the price feed
     **/
    constructor(address priceFeedA_, address priceFeedB_, uint8 decimals_, string memory description_) {
        priceFeedA = priceFeedA_;
        priceFeedB = priceFeedB_;
        uint8 priceFeedADecimals = AggregatorV3Interface(priceFeedA_).decimals();
        uint8 priceFeedBDecimals = AggregatorV3Interface(priceFeedB_).decimals();
        priceFeedAScale = signed256(10 ** (priceFeedADecimals));
        priceFeedBScale = signed256(10 ** (priceFeedBDecimals));

        if (decimals_ > 18) revert BadDecimals();
        decimals = decimals_;
        description = description_;
        priceFeedScale = int256(10 ** decimals);
    }

    /**
     * @notice Calculates the latest round data using data from the two price feeds
     * @return roundId Round id from price feed B
     * @return answer Latest price
     * @return startedAt Timestamp when the round was started; passed on from price feed B
     * @return updatedAt Timestamp when the round was last updated; passed on from price feed B
     * @return answeredInRound Round id in which the answer was computed; passed on from price feed B
     * @dev Note: Only the `answer` really matters for downstream contracts that use this price feed (e.g. Comet)
     **/
    function latestRoundData() override external view returns (uint80, int256, uint256, uint256, uint80) {
        (, int256 priceA, , , ) = AggregatorV3Interface(priceFeedA).latestRoundData();
        (uint80 roundId_, int256 priceB, uint256 startedAt_, uint256 updatedAt_, uint80 answeredInRound_) = AggregatorV3Interface(priceFeedB).latestRoundData();

        if (priceA <= 0 || priceB <= 0) return (roundId_, 0, startedAt_, updatedAt_, answeredInRound_);

        // int256 price = priceA * (priceFeedBScale/priceB) * priceFeedScale / priceFeedAScale;
        int256 price = priceA * priceFeedBScale * priceFeedScale / priceB / priceFeedAScale;
        return (roundId_, price, startedAt_, updatedAt_, answeredInRound_);
    }

    function signed256(uint256 n) internal pure returns (int256) {
        if (n > uint256(type(int256).max)) revert InvalidInt256();
        return int256(n);
    }

    /**
     * @notice Price for the latest round
     * @return The version of the price feed contract
     **/
    function version() external pure returns (uint256) {
        return VERSION;
    }
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.15;

/**
 * @dev Interface for price feeds used by Comet
 * Note This is Chainlink's AggregatorV3Interface, but without the `getRoundData` function.
 */
interface IPriceFeed {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1,
    "details": {
      "yulDetails": {
        "optimizerSteps": "dhfoDgvulfnTUtnIf [xa[r]scLM cCTUtTOntnfDIul Lcul Vcul [j] Tpeul xa[rul] xa[r]cL gvif CTUca[r]LsTOtfDnca[r]Iulc] jmul[jul] VcTOcul jmul"
      }
    }
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "viaIR": true,
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"priceFeedA_","type":"address"},{"internalType":"address","name":"priceFeedB_","type":"address"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"string","name":"description_","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BadDecimals","type":"error"},{"inputs":[],"name":"InvalidInt256","type":"error"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRoundData","outputs":[{"internalType":"uint80","name":"","type":"uint80"},{"internalType":"int256","name":"","type":"int256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint80","name":"","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeedA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeedAScale","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeedB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeedBScale","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeedScale","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"}]

0x610140604081815234620004245762000bc8803803809162000022828662000429565b8439820160808382031262000424576200003c836200044d565b9260206200004c8183016200044d565b946200005a85840162000462565b95606084015160018060401b039485821162000424570190601f92868484011215620004245782518681116200032457885193601f1998620000a3888b89860116018762000429565b82865287838301011162000424578187916000905b8282106200040a575011620003fb575b50508060a0528160c05287519163313ce56760e01b808452868460048160018060a01b038097165afa938415620003f05790879291600095620003ab575b506004908b5194859384928352165afa908115620003a0576000916200034b575b50620001409062000146620001406200014f9462000471565b62000499565b60e05262000471565b96610100978852601260ff8216116200033a5760805280519384116200032457600054926001938481811c9116801562000319575b828210146200030357838111620002b8575b50809285116001146200024e57508394509083929160009462000242575b50501b916000199060031b1c1916176000555b620001d760ff6080511662000471565b90610120918252519061070a9283620004be84396080518361034a015260a0518381816103020152610534015260c0518381816103820152610576015260e0518381816102cb015261062401525182818161027601526105d101525181818161023c01526105f80152f35b015192503880620001b4565b9294849081166000805284600020946000905b888383106200029d575050501062000283575b505050811b01600055620001c7565b015160001960f88460031b161c1916905538808062000274565b85870151885590960195948501948793509081019062000261565b60008052816000208480880160051c820192848910620002f9575b0160051c019085905b828110620002ec57505062000196565b60008155018590620002dc565b92508192620002d3565b634e487b7160e01b600052602260045260246000fd5b90607f169062000184565b634e487b7160e01b600052604160045260246000fd5b8651630456c65960e51b8152600490fd5b908582813d831162000398575b62000364818362000429565b810103126200039557506200014f9162000146620001406200038a620001409462000462565b935050509162000127565b80fd5b503d62000358565b88513d6000823e3d90fd5b919282819692963d8311620003e8575b620003c7818362000429565b81010312620003955750906004620003e0889362000462565b949062000106565b503d620003bb565b8a513d6000823e3d90fd5b600091850101523885620000c8565b9280925081840101518282890101520182908892620000b8565b600080fd5b601f909101601f19168101906001600160401b038211908210176200032457604052565b51906001600160a01b03821682036200042457565b519060ff821682036200042457565b60ff16604d81116200048357600a0a90565b634e487b7160e01b600052601160045260246000fd5b6001600160ff1b038111620004ab5790565b60405163e7e828ad60e01b8152600490fdfe60806040818152600436101561001457600080fd5b600091823560e01c90816314c04ff11461036e57508063313ce56714610331578063383cae1d146102ee5780634a10b647146102b457806354fd4d5014610299578063563561641461025f5780635fd4c7c5146102255780637284e416146100f6578063feaf968c146100ae5763ffa1ad741461009057600080fd5b346100aa57816003193601126100aa576020905160018152f35b5080fd5b50346100aa57816003193601126100aa5760a0906100ca610510565b85516001600160501b039586168152602081019490945294830191909152606082015291166080820152f35b50346100aa57816003193601126100aa578051918080549160019083821c9180851694851561021b575b60209586851081146102075784895288939291879082156101e75750506001146101ab575b50610155925095929503826103b1565b8251938285938452825192838286015282915b8483106101935750508210610187575b50601f01601f19168101030190f35b83828401015238610178565b81830181015188840188015287955091820191610168565b8591508480528185209085915b8583106101cf575050610155935082010138610145565b8054838b0185015289945087939092019181016101b8565b60ff19168582015261015595151560051b85010192503891506101459050565b634e487b7160e01b86526022600452602486fd5b92607f1692610120565b50346100aa57816003193601126100aa57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50346100aa57816003193601126100aa57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50346100aa57816003193601126100aa576020905160018152f35b50346100aa57816003193601126100aa57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50346100aa57816003193601126100aa57517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b50346100aa57816003193601126100aa576020905160ff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b8390346100aa57816003193601126100aa577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b601f909101601f19168101906001600160401b038211908210176103d457604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160501b03821682036103fe57565b600080fd5b908160a09103126103fe57610417816103ea565b916020820151916040810151916104356080606084015193016103ea565b90565b60008082138184136001600160ff1b038282168682048611166104a157600160ff1b92848712929083168685058812166104b5578685871294058612908416166104a157859005841291161661048d57500290565b634e487b7160e01b81526011600452602490fd5b634e487b7160e01b84526011600452602484fd5b634e487b7160e01b85526011600452602485fd5b81156104fa57600160ff1b81146000198314166104e4570590565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b604051633fabe5a360e21b80825290916001600160a01b039160a0919082856004817f000000000000000000000000000000000000000000000000000000000000000088165afa9485156106a2576000956106ae575b50829060046040518096819382527f0000000000000000000000000000000000000000000000000000000000000000165afa9081156106a2576000948590869587958895610664575b505060008113801590610659575b61064f576106499161061d6105f6610622937f000000000000000000000000000000000000000000000000000000000000000090610438565b7f000000000000000000000000000000000000000000000000000000000000000090610438565b6104c9565b7f0000000000000000000000000000000000000000000000000000000000000000906104c9565b93929190565b5050600093929190565b5060008213156105bd565b939650935095505061068b9250803d1061069b575b61068381836103b1565b810190610403565b93959194909392909138806105af565b503d610679565b6040513d6000823e3d90fd5b839195506106c890823d841161069b5761068381836103b1565b5050509050949061056656fea264697066735822122048e53e1896b9ea29670884075e6a355213f7ada5dc02bd35acb6a0a63a32c27d64736f6c634300080f00330000000000000000000000001b39ee86ec5979ba5c322b826b3ecb8c799916990000000000000000000000004f67e4d9bd67efa28236013288737d39aef48e79000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000018434f4d50202f2077737445544820707269636520666565640000000000000000

Deployed Bytecode

0x60806040818152600436101561001457600080fd5b600091823560e01c90816314c04ff11461036e57508063313ce56714610331578063383cae1d146102ee5780634a10b647146102b457806354fd4d5014610299578063563561641461025f5780635fd4c7c5146102255780637284e416146100f6578063feaf968c146100ae5763ffa1ad741461009057600080fd5b346100aa57816003193601126100aa576020905160018152f35b5080fd5b50346100aa57816003193601126100aa5760a0906100ca610510565b85516001600160501b039586168152602081019490945294830191909152606082015291166080820152f35b50346100aa57816003193601126100aa578051918080549160019083821c9180851694851561021b575b60209586851081146102075784895288939291879082156101e75750506001146101ab575b50610155925095929503826103b1565b8251938285938452825192838286015282915b8483106101935750508210610187575b50601f01601f19168101030190f35b83828401015238610178565b81830181015188840188015287955091820191610168565b8591508480528185209085915b8583106101cf575050610155935082010138610145565b8054838b0185015289945087939092019181016101b8565b60ff19168582015261015595151560051b85010192503891506101459050565b634e487b7160e01b86526022600452602486fd5b92607f1692610120565b50346100aa57816003193601126100aa57602090517f0000000000000000000000000000000000000000000000000000000005f5e1008152f35b50346100aa57816003193601126100aa57602090517f0000000000000000000000000000000000000000000000000000000005f5e1008152f35b50346100aa57816003193601126100aa576020905160018152f35b50346100aa57816003193601126100aa57602090517f0000000000000000000000000000000000000000000000000de0b6b3a76400008152f35b50346100aa57816003193601126100aa57517f0000000000000000000000001b39ee86ec5979ba5c322b826b3ecb8c799916996001600160a01b03168152602090f35b50346100aa57816003193601126100aa576020905160ff7f0000000000000000000000000000000000000000000000000000000000000008168152f35b8390346100aa57816003193601126100aa577f0000000000000000000000004f67e4d9bd67efa28236013288737d39aef48e796001600160a01b03168152602090f35b601f909101601f19168101906001600160401b038211908210176103d457604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160501b03821682036103fe57565b600080fd5b908160a09103126103fe57610417816103ea565b916020820151916040810151916104356080606084015193016103ea565b90565b60008082138184136001600160ff1b038282168682048611166104a157600160ff1b92848712929083168685058812166104b5578685871294058612908416166104a157859005841291161661048d57500290565b634e487b7160e01b81526011600452602490fd5b634e487b7160e01b84526011600452602484fd5b634e487b7160e01b85526011600452602485fd5b81156104fa57600160ff1b81146000198314166104e4570590565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b604051633fabe5a360e21b80825290916001600160a01b039160a0919082856004817f0000000000000000000000001b39ee86ec5979ba5c322b826b3ecb8c7999169988165afa9485156106a2576000956106ae575b50829060046040518096819382527f0000000000000000000000004f67e4d9bd67efa28236013288737d39aef48e79165afa9081156106a2576000948590869587958895610664575b505060008113801590610659575b61064f576106499161061d6105f6610622937f0000000000000000000000000000000000000000000000000000000005f5e10090610438565b7f0000000000000000000000000000000000000000000000000000000005f5e10090610438565b6104c9565b7f0000000000000000000000000000000000000000000000000de0b6b3a7640000906104c9565b93929190565b5050600093929190565b5060008213156105bd565b939650935095505061068b9250803d1061069b575b61068381836103b1565b810190610403565b93959194909392909138806105af565b503d610679565b6040513d6000823e3d90fd5b839195506106c890823d841161069b5761068381836103b1565b5050509050949061056656fea264697066735822122048e53e1896b9ea29670884075e6a355213f7ada5dc02bd35acb6a0a63a32c27d64736f6c634300080f0033

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

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.