Contract Overview
Balance:
0 DEV
My Name Tag:
Not Available
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Contract Name:
ChainlinkFeedGetter
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.4; import "../oracle/interfaces/IPrimeOracle.sol"; import "../oracle/interfaces/IPrimeOracleGetter.sol"; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; import "../../util/CommonErrors.sol"; contract ChainlinkFeedGetter is IPrimeOracleGetter, CommonErrors { // Map of asset price feeds (asset => priceSource) mapping(uint256 => mapping(address => AggregatorV3Interface)) private assetFeeds; //TODO: allow transfer of admin address public admin; uint8 public constant RATIO_DECIMALS = 18; /** * @dev Only the admin can call functions marked by this modifier. **/ modifier onlyAdmin { if(msg.sender != admin) revert OnlyAdmin(); _; } constructor() { admin = msg.sender; } /// @inheritdoc IPrimeOracleGetter function getAssetPrice( uint256 chainId, address asset, address /* denomToken */ ) external view override returns (uint256 price, uint8 decimals) { AggregatorV3Interface feed = assetFeeds[chainId][asset]; if (address(feed) != address(0)) { ( /* uint80 roundId */, int256 answer, /* uint256 startedAt */, /* uint256 updatedAt */, /* uint80 answeredInRound */ ) = feed.latestRoundData(); if (answer < 0) return (0,0); price = uint256(answer); decimals = feed.decimals(); } } function getAssetRatio( address overlyingAsset, address underlyingAsset, uint256 underlyingChainId ) external view override returns (uint256 ratio, uint8 decimals) { AggregatorV3Interface numFeed = assetFeeds[block.chainid][overlyingAsset]; AggregatorV3Interface denFeed = assetFeeds[underlyingChainId][underlyingAsset]; if (address(numFeed) != address(0) && address(denFeed) != address(0)) { ( /* uint80 roundId */, int256 numAnswer, /* uint256 startedAt */, /* uint256 updatedAt */, /* uint80 answeredInRound */ ) = numFeed.latestRoundData(); ( /* uint80 roundId */, int256 denAnswer, /* uint256 startedAt */, /* uint256 updatedAt */, /* uint80 answeredInRound */ ) = denFeed.latestRoundData(); if (numAnswer >= 0 && denAnswer >= 0) { ratio = uint256(numAnswer) * 10**(denFeed.decimals() + RATIO_DECIMALS) / uint256(denAnswer) / 10**numFeed.decimals(); decimals = RATIO_DECIMALS; } } } function getPriceDecimals(uint256 chainId, address asset) external view override returns (uint256) { if (asset == address(0)) revert AddressExpected(); AggregatorV3Interface feed = assetFeeds[chainId][asset]; if (address(feed) != address(0)) { return feed.decimals(); } return 0; } function _getAssetFeed(uint256 chainId, address asset) internal view returns (address) { if (asset == address(0)) revert AddressExpected(); return address(assetFeeds[chainId][asset]); } function getAssetFeed(uint256 chainId, address asset) external view override returns (address) { if (asset == address(0)) revert AddressExpected(); return _getAssetFeed(chainId, asset); } /// @inheritdoc IPrimeOracleGetter function setAssetFeed( uint256 chainId, address asset, address feed ) external override onlyAdmin() { assetFeeds[chainId][asset] = AggregatorV3Interface(feed); emit AssetFeedUpdated(chainId, asset, feed); } }
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.4; import "./IPrimeOracleGetter.sol"; import "./PrimeOracleStorage.sol"; /** * @title IPrimeOracle * @author Prime * @notice The core interface for the Prime Oracle */ abstract contract IPrimeOracle is PrimeOracleStorage { /** * @dev Emitted after the price data feed of an asset is set/updated * @param asset The address of the asset * @param chainId The chainId of the asset * @param feed The price feed of the asset */ event SetPrimaryFeed(uint256 chainId, address indexed asset, address indexed feed); /** * @dev Emitted after the price data feed of an asset is set/updated * @param asset The address of the asset * @param feed The price feed of the asset */ event SetSecondaryFeed(uint256 chainId, address indexed asset, address indexed feed); /** * @dev Emitted after the exchange rate data feed of a loan market asset is set/updated * @param asset The address of the asset * @param chainId The chainId of the asset * @param feed The price feed of the asset */ event SetExchangRatePrimaryFeed(uint256 chainId, address indexed asset, address indexed feed); /** * @dev Emitted after the exchange rate data feed of a loan market asset is set/updated * @param asset The address of the asset * @param feed The price feed of the asset */ event SetExchangeRateSecondaryFeed(uint256 chainId, address indexed asset, address indexed feed); /** * @notice Get the underlying price of a cToken asset * @param collateralMarketUnderlying The PToken collateral to get the sasset price of * @param chainId the chainId to get an asset price for * @return The underlying asset price. * Zero means the price is unavailable. */ function getUnderlyingPrice(uint256 chainId, address collateralMarketUnderlying) external view virtual returns (uint256, uint8); /** * @notice Get the underlying borrow price of loanMarketAsset * @return The underlying borrow price * Zero means the price is unavailable. */ function getUnderlyingPriceBorrow( uint256 chainId, address loanMarketUnderlying ) external view virtual returns (uint256, uint8); /** * @notice Get the exchange rate of loanMarketAsset to basis * @return The underlying exchange rate of loanMarketAsset to basis * Zero means the price is unavailable. */ function getBorrowAssetExchangeRate( address loanMarketOverlying, uint256 loanMarketUnderlyingChainId, address loanMarketUnderlying ) external view virtual returns (uint256 /* ratio */, uint8 /* decimals */); /*** Admin Functions ***/ /** * @notice Sets or replaces price feeds of assets * @param asset The addresses of the assets * @param feed The addresses of the price feeds */ function setPrimaryFeed(uint256 chainId, address asset, IPrimeOracleGetter feed) external virtual; /** * @notice Sets or replaces price feeds of assets * @param asset The addresses of the assets * @param feed The addresses of the price feeds */ function setSecondaryFeed(uint256 chainId, address asset, IPrimeOracleGetter feed) external virtual; }
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.4; /** * @title IPrimeOracleGetter * @author Prime * @notice Interface for the Prime price oracle. **/ interface IPrimeOracleGetter { /** * @dev Emitted after the price data feed of an asset is updated * @param asset The address of the asset * @param feed The price feed of the asset */ event AssetFeedUpdated(uint256 chainId, address indexed asset, address indexed feed); /** * @notice Gets the price feed of an asset * @param asset The addresses of the asset * @return address of asset feed */ function getAssetFeed(uint256 chainId, address asset) external view returns (address); /** * @notice Sets or replaces price feeds of assets * @param asset The addresses of the assets * @param feed The addresses of the price feeds */ function setAssetFeed(uint256 chainId, address asset, address feed) external; /** * @notice Returns the price data in the denom currency * @param quoteToken A token to return price data for * @param denomToken A token to price quoteToken against * @param price of the asset from the oracle * @param decimals of the asset from the oracle **/ function getAssetPrice( uint256 chainId, address quoteToken, address denomToken ) external view returns (uint256 price, uint8 decimals); function getAssetRatio( address overlyingAsset, address underlyingAsset, uint256 underlyingChainId ) external view returns (uint256 ratio, uint8 decimals); /** * @notice Returns the price data in the denom currency * @param quoteToken A token to return price data for * @return return price of the asset from the oracle **/ function getPriceDecimals( uint256 chainId, address quoteToken ) external view returns (uint256); }
// 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 ); }
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.4; abstract contract CommonErrors { error AccountNoAssets(address account); error AddressExpected(); error AlreadyInitialized(); error EccMessageAlreadyProcessed(); error EccFailedToValidate(); error ExpectedMintAmount(); error ExpectedBridgeAmount(); error ExpectedBorrowAmount(); error ExpectedWithdrawAmount(); error ExpectedRepayAmount(); error ExpectedTradeAmount(); error ExpectedDepositAmount(); error ExpectedTransferAmount(); error InsufficientReserves(); error InvalidPayload(); error InvalidPrice(); error InvalidPrecision(); error InvalidSelector(); error MarketExists(); error LoanMarketIsListed(bool status); error MarketIsPaused(); error MarketNotListed(); error MsgDataExpected(); error NameExpected(); error NothingToWithdraw(); error NotInMarket(uint256 chainId, address token); error OnlyAdmin(); error OnlyAuth(); error OnlyGateway(); error OnlyMiddleLayer(); error OnlyMintAuth(); error OnlyRoute(); error OnlyRouter(); error OnlyMasterState(); error ParamOutOfBounds(); error RouteExists(); error Reentrancy(); error EnterLoanMarketFailed(); error EnterCollMarketFailed(); error ExitLoanMarketFailed(); error ExitCollMarketFailed(); error RepayTooMuch(uint256 repayAmount, uint256 maxAmount); error WithdrawTooMuch(); error NotEnoughBalance(address token, address who); error LiquidateDisallowed(); error SeizeTooMuch(); error SymbolExpected(); error RouteNotSupported(address route); error MiddleLayerPaused(); error PairNotSupported(address loanAsset, address tradeAsset); error TransferFailed(address from, address dest); error TransferPaused(); error UnknownRevert(); error UnexpectedValueDelta(); error ExpectedValue(); error UnexpectedDelta(); }
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.4; import "./IPrimeOracleGetter.sol"; /** * @title PrimeOracleStorage * @author Prime * @notice The core interface for the Prime Oracle storage variables */ abstract contract PrimeOracleStorage { address public pusdAddress; //TODO: allow transfer of ownership address public admin; // Map of asset price feeds (chainasset => priceSource) mapping(uint256 => mapping(address => IPrimeOracleGetter)) public primaryFeeds; mapping(uint256 => mapping(address => IPrimeOracleGetter)) public secondaryFeeds; mapping(uint256 => mapping(address => IPrimeOracleGetter)) public exchangeRatePrimaryFeeds; mapping(uint256 => mapping(address => IPrimeOracleGetter)) public exchangeRateSecondaryFeeds; }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AccountNoAssets","type":"error"},{"inputs":[],"name":"AddressExpected","type":"error"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"EccFailedToValidate","type":"error"},{"inputs":[],"name":"EccMessageAlreadyProcessed","type":"error"},{"inputs":[],"name":"EnterCollMarketFailed","type":"error"},{"inputs":[],"name":"EnterLoanMarketFailed","type":"error"},{"inputs":[],"name":"ExitCollMarketFailed","type":"error"},{"inputs":[],"name":"ExitLoanMarketFailed","type":"error"},{"inputs":[],"name":"ExpectedBorrowAmount","type":"error"},{"inputs":[],"name":"ExpectedBridgeAmount","type":"error"},{"inputs":[],"name":"ExpectedDepositAmount","type":"error"},{"inputs":[],"name":"ExpectedMintAmount","type":"error"},{"inputs":[],"name":"ExpectedRepayAmount","type":"error"},{"inputs":[],"name":"ExpectedTradeAmount","type":"error"},{"inputs":[],"name":"ExpectedTransferAmount","type":"error"},{"inputs":[],"name":"ExpectedValue","type":"error"},{"inputs":[],"name":"ExpectedWithdrawAmount","type":"error"},{"inputs":[],"name":"InsufficientReserves","type":"error"},{"inputs":[],"name":"InvalidPayload","type":"error"},{"inputs":[],"name":"InvalidPrecision","type":"error"},{"inputs":[],"name":"InvalidPrice","type":"error"},{"inputs":[],"name":"InvalidSelector","type":"error"},{"inputs":[],"name":"LiquidateDisallowed","type":"error"},{"inputs":[{"internalType":"bool","name":"status","type":"bool"}],"name":"LoanMarketIsListed","type":"error"},{"inputs":[],"name":"MarketExists","type":"error"},{"inputs":[],"name":"MarketIsPaused","type":"error"},{"inputs":[],"name":"MarketNotListed","type":"error"},{"inputs":[],"name":"MiddleLayerPaused","type":"error"},{"inputs":[],"name":"MsgDataExpected","type":"error"},{"inputs":[],"name":"NameExpected","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"who","type":"address"}],"name":"NotEnoughBalance","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"token","type":"address"}],"name":"NotInMarket","type":"error"},{"inputs":[],"name":"NothingToWithdraw","type":"error"},{"inputs":[],"name":"OnlyAdmin","type":"error"},{"inputs":[],"name":"OnlyAuth","type":"error"},{"inputs":[],"name":"OnlyGateway","type":"error"},{"inputs":[],"name":"OnlyMasterState","type":"error"},{"inputs":[],"name":"OnlyMiddleLayer","type":"error"},{"inputs":[],"name":"OnlyMintAuth","type":"error"},{"inputs":[],"name":"OnlyRoute","type":"error"},{"inputs":[],"name":"OnlyRouter","type":"error"},{"inputs":[{"internalType":"address","name":"loanAsset","type":"address"},{"internalType":"address","name":"tradeAsset","type":"address"}],"name":"PairNotSupported","type":"error"},{"inputs":[],"name":"ParamOutOfBounds","type":"error"},{"inputs":[],"name":"Reentrancy","type":"error"},{"inputs":[{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"uint256","name":"maxAmount","type":"uint256"}],"name":"RepayTooMuch","type":"error"},{"inputs":[],"name":"RouteExists","type":"error"},{"inputs":[{"internalType":"address","name":"route","type":"address"}],"name":"RouteNotSupported","type":"error"},{"inputs":[],"name":"SeizeTooMuch","type":"error"},{"inputs":[],"name":"SymbolExpected","type":"error"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"dest","type":"address"}],"name":"TransferFailed","type":"error"},{"inputs":[],"name":"TransferPaused","type":"error"},{"inputs":[],"name":"UnexpectedDelta","type":"error"},{"inputs":[],"name":"UnexpectedValueDelta","type":"error"},{"inputs":[],"name":"UnknownRevert","type":"error"},{"inputs":[],"name":"WithdrawTooMuch","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"feed","type":"address"}],"name":"AssetFeedUpdated","type":"event"},{"inputs":[],"name":"RATIO_DECIMALS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"asset","type":"address"}],"name":"getAssetFeed","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"getAssetPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"overlyingAsset","type":"address"},{"internalType":"address","name":"underlyingAsset","type":"address"},{"internalType":"uint256","name":"underlyingChainId","type":"uint256"}],"name":"getAssetRatio","outputs":[{"internalType":"uint256","name":"ratio","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"asset","type":"address"}],"name":"getPriceDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"feed","type":"address"}],"name":"setAssetFeed","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50600180546001600160a01b03191633179055610a21806100326000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063a83622e01161005b578063a83622e0146100d9578063c8aea946146100f3578063eaa3d1ae1461011e578063f851a4401461013f57600080fd5b806318417130146100825780637263a89a146100b157806391bba016146100c6575b600080fd5b610095610090366004610744565b610152565b6040805192835260ff9091166020830152015b60405180910390f35b6100c46100bf366004610780565b6103ed565b005b6100956100d4366004610780565b610487565b6100e1601281565b60405160ff90911681526020016100a8565b6101066101013660046107bc565b6105c3565b6040516001600160a01b0390911681526020016100a8565b61013161012c3660046107bc565b6105ff565b6040519081526020016100a8565b600154610106906001600160a01b031681565b466000908152602081815260408083206001600160a01b0380881685529083528184205485855284845282852087831686529093529083205483928216911681158015906101a857506001600160a01b03811615155b156103e3576000826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b1580156101e857600080fd5b505afa1580156101fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102209190610802565b5050509150506000826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561026157600080fd5b505afa158015610275573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102999190610802565b505050915050600082121580156102b1575060008112155b156103e057836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156102ef57600080fd5b505afa158015610303573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103279190610852565b61033290600a610976565b816012856001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561036e57600080fd5b505afa158015610382573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a69190610852565b6103b09190610985565b6103bb90600a610976565b6103c590856109aa565b6103cf91906109c9565b6103d991906109c9565b9550601294505b50505b5050935093915050565b6001546001600160a01b0316331461041857604051634755657960e01b815260040160405180910390fd5b6000838152602081815260408083206001600160a01b038681168086529184529382902080546001600160a01b0319169486169485179055905186815290917fc709360c31221c0b6eec90fcfc36e335ea5ddfe4fb85722d70d0e54b12f66a32910160405180910390a3505050565b6000838152602081815260408083206001600160a01b038087168552925282205482911680156105b9576000816001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b1580156104ec57600080fd5b505afa158015610500573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105249190610802565b5050509150506000811215610541576000809350935050506105bb565b809350816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561057d57600080fd5b505afa158015610591573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105b59190610852565b9250505b505b935093915050565b60006001600160a01b0382166105ec57604051635f3ee81760e01b815260040160405180910390fd5b6105f683836106d7565b90505b92915050565b60006001600160a01b03821661062857604051635f3ee81760e01b815260040160405180910390fd5b6000838152602081815260408083206001600160a01b0380871685529252909120541680156106cd57806001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561068a57600080fd5b505afa15801561069e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c29190610852565b60ff169150506105f9565b5060009392505050565b60006001600160a01b03821661070057604051635f3ee81760e01b815260040160405180910390fd5b506000918252602082815260408084206001600160a01b039384168552909152909120541690565b80356001600160a01b038116811461073f57600080fd5b919050565b60008060006060848603121561075957600080fd5b61076284610728565b925061077060208501610728565b9150604084013590509250925092565b60008060006060848603121561079557600080fd5b833592506107a560208501610728565b91506107b360408501610728565b90509250925092565b600080604083850312156107cf57600080fd5b823591506107df60208401610728565b90509250929050565b805169ffffffffffffffffffff8116811461073f57600080fd5b600080600080600060a0868803121561081a57600080fd5b610823866107e8565b9450602086015193506040860151925060608601519150610846608087016107e8565b90509295509295909350565b60006020828403121561086457600080fd5b815160ff8116811461087557600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156108cd5781600019048211156108b3576108b361087c565b808516156108c057918102915b93841c9390800290610897565b509250929050565b6000826108e4575060016105f9565b816108f1575060006105f9565b816001811461090757600281146109115761092d565b60019150506105f9565b60ff8411156109225761092261087c565b50506001821b6105f9565b5060208310610133831016604e8410600b8410161715610950575081810a6105f9565b61095a8383610892565b806000190482111561096e5761096e61087c565b029392505050565b60006105f660ff8416836108d5565b600060ff821660ff84168060ff038211156109a2576109a261087c565b019392505050565b60008160001904831182151516156109c4576109c461087c565b500290565b6000826109e657634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220d1380b240bd4ba76e2c1235c24732a04b3e2ae138900da43cc61ed5e40c501b164736f6c63430008090033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|