CustomRateFeedWrapper

Description:

Smart contract deployed on Ethereum with Factory, Oracle features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "src/oracles/CustomRateFeedWrapper.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

/// @title CustomRateFeedWrapper
/// @notice Wraps any contract exposing a custom view function (e.g., exchangeRate())
contract CustomRateFeedWrapper {
    /// @notice Address of the underlying rate provider contract
    address public immutable target;

    /// @notice Number of decimals in the returned rate
    uint8 public immutable decimals_;

    /// @notice Function selector for the rate function
    bytes public callData;

    error InvalidRate();
    error InvalidCall();
    error InvalidTarget();
    error InvalidCalldata();

    constructor(address _target, uint8 _decimals, bytes memory _callData) {
        require(_target != address(0), InvalidTarget());
        require(_callData.length != 0, InvalidCalldata());

        target = _target;
        callData = _callData;
        decimals_ = _decimals;
    }

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

    function latestRoundData()
        public
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        )
    {
        (bool success, bytes memory data) = target.staticcall(callData);
        require(success, InvalidCall());
        uint256 rate = abi.decode(data, (uint256));
        require(rate > 0, InvalidRate());

        return (
            0, // roundId
            int256(rate),
            block.timestamp,
            block.timestamp,
            0 // answeredInRound
        );
    }
}
"
    }
  },
  "settings": {
    "remappings": [
      "@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/",
      "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
      "@chainlink/contracts/=node_modules/@chainlink/contracts/src/v0.8/",
      "@pythnetwork/=node_modules/@pythnetwork/pyth-sdk-solidity/",
      "forge-std/=node_modules/forge-std/src/",
      "cannon-std/=node_modules/cannon-std/src/",
      "@helpers/=test/helpers/",
      "@mocks/=test/mocks/",
      "@interfaces/=src/pike-market/interfaces/",
      "@storage/=src/pike-market/storage/",
      "@modules/=src/pike-market/modules/",
      "@errors/=src/pike-market/errors/",
      "@utils/=src/pike-market/utils/",
      "@oracles/=src/oracles/",
      "@governance/=src/governance/",
      "@factory/=src/",
      "ds-test/=lib/surl/lib/forge-std/lib/ds-test/src/",
      "solidity-stringutils/=lib/surl/lib/solidity-stringutils/",
      "surl/=lib/surl/",
      "v3-core/=lib/v3-core/"
    ],
    "optimizer": {
      "enabled": true,
      "runs": 10000
    },
    "metadata": {
      "useLiteralContent": false,
      "bytecodeHash": "ipfs",
      "appendCBOR": true
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "evmVersion": "cancun",
    "viaIR": false
  }
}}

Tags:
Factory, Oracle|addr:0x8348f5e587b786dc7a2f3aced00d0fcf1dfb30e4|verified:true|block:23656283|tx:0xc8a17ea613b51d49ca096359a0ef5f9aa65bb1b45ac902f90957857b006f52bf|first_check:1761468044

Submitted on: 2025-10-26 09:40:43

Comments

Log in to comment.

No comments yet.