Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0xa0c624a99Ec87a8010f65F277787f697346196e6
Balance 0 ETH
Nonce 1
Code Size 1686 bytes
Indexed Transactions 0 (1 on-chain, 1.6% indexed)
External Etherscan · Sourcify

Contract Bytecode

1686 bytes
Copy Bytecode
0x608060405234801561000f575f80fd5b506004361061007a575f3560e01c806350d25bcd1161005857806350d25bcd146101155780637284e4161461012b5780639f21814d14610140578063feaf968c14610167575f80fd5b80630eaa63311461007e578063313ce567146100ba5780633a70ff88146100c9575b5f80fd5b6100a57f000000000000000000000000000000000000000000000000000000000000000081565b60405190151581526020015b60405180910390f35b604051601281526020016100b1565b6100f07f000000000000000000000000435419607191f1c1c6809e01bb5c38311957c6a881565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100b1565b61011d6101a6565b6040519081526020016100b1565b6101336101bb565b6040516100b19190610432565b6100f07f000000000000000000000000ae6b44ebdd005669b410524ec076424a7308e9e181565b61016f610246565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a0016100b1565b5f806101b0610246565b509195945050505050565b5f80546101c79061049b565b80601f01602080910402602001604051908101604052809291908181526020018280546101f39061049b565b801561023e5780601f106102155761010080835404028352916020019161023e565b820191905f5260205f20905b81548152906001019060200180831161022157829003601f168201915b505050505081565b5f805f805f805f805f807f000000000000000000000000435419607191f1c1c6809e01bb5c38311957c6a873ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156102b9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102dd919061050a565b945094509450945094505f805f805f7f000000000000000000000000ae6b44ebdd005669b410524ec076424a7308e9e173ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610355573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610379919061050a565b945094509450945094505f7f0000000000000000000000000000000000000000000000000000000000000000156103ce57670de0b6b3a76400006103bd8b87610583565b6103c791906105d4565b90506103ee565b896103e186670de0b6b3a7640000610583565b6103eb91906105d4565b90505b8288101561041157999e50989c50959a5093985091965061042b95505050505050565b949e50939c50909a50985090965061042b95505050505050565b9091929394565b5f6020808352835180828501525f5b8181101561045d57858101830151858201604001528201610441565b505f6040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b600181811c908216806104af57607f821691505b6020821081036104e6577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b805169ffffffffffffffffffff81168114610505575f80fd5b919050565b5f805f805f60a0868803121561051e575f80fd5b610527866104ec565b945060208601519350604086015192506060860151915061054a608087016104ec565b90509295509295909350565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b8082025f82127f8000000000000000000000000000000000000000000000000000000000000000841416156105ba576105ba610556565b81810583148215176105ce576105ce610556565b92915050565b5f82610607577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f80000000000000000000000000000000000000000000000000000000000000008314161561065b5761065b610556565b50059056fea26469706673582212200a3d88c1643136a7d1e31dd26901e705ad96607b9a36faca9c060289d913f41664736f6c63430008140033

Verified Source Code Partial Match

Compiler: v0.8.20+commit.a1b79de6 EVM: shanghai Optimization: Yes (10000 runs)
ChainlinkBridgeAssetFeed.sol 127 lines
pragma solidity ^0.8.13 ^0.8.20;

// src/interfaces/IChainlinkFeed.sol

interface IChainlinkFeed {
    function aggregator() external view returns (address aggregator);

    function decimals() external view returns (uint8 decimals);

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

    function latestAnswer() external view returns (int256 price);

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

interface IChainlinkBasePriceFeed is IChainlinkFeed {
    function assetToUsd() external view returns (IChainlinkFeed);

    function assetToUsdFallback() external view returns (IChainlinkFeed);

    function assetToUsdHeartbeat() external view returns (uint256 heartbeat);
}

// src/feeds/ChainlinkBridgeAssetFeed.sol

contract ChainlinkBridgeAssetFeed {
    IChainlinkFeed public immutable collateralToBridgeAsset;
    IChainlinkFeed public immutable bridgeAssetToUsd;
    bool public immutable bridgeAssetDenominator;
    string public description;

    /**
     * @notice Oracle for the USD price of a collateral asset derived by combining a collateral-bridgeAsset oracle and bridgeAsset-USD oracle
     * @param _collateralToBridgeAsset Chainlink oracle returning the collateral/bridgeAsset OR bridgeAsset/collateral price
     * @param _bridgeAssetToUsd Chainlink oracle returning the bridgeAsset/USD price
     * @param _bridgeAssetDenominator If true, the `_collateralToBridgeAsset` oracle will return collateral/bridgeAsset, if false, bridgeAsset/collateral.
     * @dev We assume the underlying oracles have already been normalized using our standard chainlink feed. These feeds should also be used for fallback logic.
     */
    constructor(address _collateralToBridgeAsset, address _bridgeAssetToUsd, bool _bridgeAssetDenominator){
        collateralToBridgeAsset = IChainlinkFeed(_collateralToBridgeAsset);
        bridgeAssetToUsd = IChainlinkFeed(_bridgeAssetToUsd);
        bridgeAssetDenominator = _bridgeAssetDenominator;
        if(_bridgeAssetDenominator){
            description = string(abi.encodePacked(collateralToBridgeAsset.description(), " * ", bridgeAssetToUsd.description()));
        } else {
            description = string(abi.encodePacked(bridgeAssetToUsd.description(), " / (", collateralToBridgeAsset.description(),")"));
        }
        require(collateralToBridgeAsset.decimals() == 18, "collateralToBridgeAsset feed not normalized");
        require(bridgeAssetToUsd.decimals() == 18, "bridgeAssetToUsd feed not normalized");
    }

    function decimals() external view returns (uint8) {
        return 18;
    }

    /**
     * @notice Retrieves the latest round data for the collateral token price feed
     * @dev This function calculates the collateral price in USD by combining the bridgeAsset to USD price from a Chainlink oracle and the collateral to bridgeAsset ratio from the bridgeAsset Chainlink oracle
     * @return roundId The round ID of the Chainlink price feed for the feed with the lowest updatedAt feed
     * @return bridgeAssetToUsdPrice The latest collateral price in USD computed from the collateral/bridgeAsset and bridgeAsset/USD feeds
     * @return startedAt The timestamp when the latest round of Chainlink price feed started of the lowest last updatedAt feed
     * @return updatedAt The lowest timestamp when either of the latest round of Chainlink price feed was updated
     * @return answeredInRound The round ID in which the answer was computed of the lowest updatedAt feed
     */
    function latestRoundData()
        public
        view
        returns (uint80, int256, uint256, uint256, uint80)
    {
        (
            uint80 collateralToBridgeAssetRoundId,
            int256 collateralToBridgeAssetPrice,
            uint collateralToBridgeAssetStartedAt,
            uint collateralToBridgeAssetUpdatedAt,
            uint80 collateralToBridgeAssetAnsweredInRound
        ) = collateralToBridgeAsset.latestRoundData();
        (
            uint80 bridgeAssetToUsdRoundId,
            int256 bridgeAssetToUsdPrice,
            uint bridgeAssetToUsdStartedAt,
            uint bridgeAssetToUsdUpdatedAt,
            uint80 bridgeAssetToUsdAnsweredInRound
        ) = bridgeAssetToUsd.latestRoundData();
        int price;
        if(bridgeAssetDenominator){
            price = bridgeAssetToUsdPrice * collateralToBridgeAssetPrice / 10 ** 18;
        } else {
            price = bridgeAssetToUsdPrice *  10 ** 18 / collateralToBridgeAssetPrice;
        }
        if (collateralToBridgeAssetUpdatedAt < bridgeAssetToUsdUpdatedAt) {
            return (
                collateralToBridgeAssetRoundId,
                price,
                collateralToBridgeAssetStartedAt,
                collateralToBridgeAssetUpdatedAt,
                collateralToBridgeAssetAnsweredInRound
            );
        } else {
            return (
                bridgeAssetToUsdRoundId,
                price,
                bridgeAssetToUsdStartedAt,
                bridgeAssetToUsdUpdatedAt,
                bridgeAssetToUsdAnsweredInRound
            );
        }
    }
    /**
     * @notice Returns the latest price only
     * @dev Unlike chainlink oracles, the latestAnswer will always be the same as in the latestRoundData
     * @return int256 Returns the last finalized price of the chainlink oracle
     */
    function latestAnswer() external view returns (int256) {
        (, int256 latestPrice, , , ) = latestRoundData();
        return latestPrice;
    }
}

Read Contract

bridgeAssetDenominator 0x0eaa6331 → bool
bridgeAssetToUsd 0x9f21814d → address
collateralToBridgeAsset 0x3a70ff88 → address
decimals 0x313ce567 → uint8
description 0x7284e416 → string
latestAnswer 0x50d25bcd → int256
latestRoundData 0xfeaf968c → uint80, int256, uint256, uint256, uint80

Recent Transactions

This address has 1 on-chain transactions, but only 1.6% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →