Source Code
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 5451695 | 596 days ago | Contract Creation | 0 FRAX |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
ChainlinkRateProvider
Compiler Version
v0.8.11+commit.d7f03943
Optimization Enabled:
Yes with 9999 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.8.0;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "./interfaces/IRateProvider.sol";
/**
* @title Chainlink Rate Provider
* @notice Returns a Chainlink price feed's quote for the provided currency pair
* @dev This rate provider is a simplification of ChainlinkReistryRateProvider which is fixed to a particular pricefeed.
* This is expected to be used in environments where the Chainlink registry is not available.
*/
contract ChainlinkRateProvider is IRateProvider {
AggregatorV3Interface public immutable pricefeed;
// Rate providers are expected to respond with a fixed-point value with 18 decimals
// We then need to scale the price feed's output to match this.
uint256 internal immutable _scalingFactor;
/**
* @param feed - The Chainlink price feed contract
*/
constructor(AggregatorV3Interface feed) {
pricefeed = feed;
_scalingFactor = 10**SafeMath.sub(18, feed.decimals());
}
/**
* @return the value of the quote currency in terms of the base currency
*/
function getRate() external view override returns (uint256) {
(, int256 price, , , ) = pricefeed.latestRoundData();
require(price > 0, "Invalid price rate response");
return uint256(price) * _scalingFactor;
}
}// 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: MIT
pragma solidity ^0.8.0;
pragma abicoder v2;
import "./AggregatorV2V3Interface.sol";
interface FeedRegistryInterface {
struct Phase {
uint16 phaseId;
uint80 startingAggregatorRoundId;
uint80 endingAggregatorRoundId;
}
event FeedProposed(
address indexed asset,
address indexed denomination,
address indexed proposedAggregator,
address currentAggregator,
address sender
);
event FeedConfirmed(
address indexed asset,
address indexed denomination,
address indexed latestAggregator,
address previousAggregator,
uint16 nextPhaseId,
address sender
);
// V3 AggregatorV3Interface
function decimals(
address base,
address quote
)
external
view
returns (
uint8
);
function description(
address base,
address quote
)
external
view
returns (
string memory
);
function version(
address base,
address quote
)
external
view
returns (
uint256
);
function latestRoundData(
address base,
address quote
)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function getRoundData(
address base,
address quote,
uint80 _roundId
)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
// V2 AggregatorInterface
function latestAnswer(
address base,
address quote
)
external
view
returns (
int256 answer
);
function latestTimestamp(
address base,
address quote
)
external
view
returns (
uint256 timestamp
);
function latestRound(
address base,
address quote
)
external
view
returns (
uint256 roundId
);
function getAnswer(
address base,
address quote,
uint256 roundId
)
external
view
returns (
int256 answer
);
function getTimestamp(
address base,
address quote,
uint256 roundId
)
external
view
returns (
uint256 timestamp
);
// Registry getters
function getFeed(
address base,
address quote
)
external
view
returns (
AggregatorV2V3Interface aggregator
);
function getPhaseFeed(
address base,
address quote,
uint16 phaseId
)
external
view
returns (
AggregatorV2V3Interface aggregator
);
function isFeedEnabled(
address aggregator
)
external
view
returns (
bool
);
function getPhase(
address base,
address quote,
uint16 phaseId
)
external
view
returns (
Phase memory phase
);
// Round helpers
function getRoundFeed(
address base,
address quote,
uint80 roundId
)
external
view
returns (
AggregatorV2V3Interface aggregator
);
function getPhaseRange(
address base,
address quote,
uint16 phaseId
)
external
view
returns (
uint80 startingRoundId,
uint80 endingRoundId
);
function getPreviousRoundId(
address base,
address quote,
uint80 roundId
) external
view
returns (
uint80 previousRoundId
);
function getNextRoundId(
address base,
address quote,
uint80 roundId
) external
view
returns (
uint80 nextRoundId
);
// Feed management
function proposeFeed(
address base,
address quote,
address aggregator
) external;
function confirmFeed(
address base,
address quote,
address aggregator
) external;
// Proposed aggregator
function getProposedFeed(
address base,
address quote
)
external
view
returns (
AggregatorV2V3Interface proposedAggregator
);
function proposedGetRoundData(
address base,
address quote,
uint80 roundId
)
external
view
returns (
uint80 id,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function proposedLatestRoundData(
address base,
address quote
)
external
view
returns (
uint80 id,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
// Phases
function getCurrentPhaseId(
address base,
address quote
)
external
view
returns (
uint16 currentPhaseId
);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.8.0;
// TODO: pull this from the monorepo
interface IRateProvider {
function getRate() external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./AggregatorInterface.sol";
import "./AggregatorV3Interface.sol";
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
{
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AggregatorInterface {
function latestAnswer()
external
view
returns (
int256
);
function latestTimestamp()
external
view
returns (
uint256
);
function latestRound()
external
view
returns (
uint256
);
function getAnswer(
uint256 roundId
)
external
view
returns (
int256
);
function getTimestamp(
uint256 roundId
)
external
view
returns (
uint256
);
event AnswerUpdated(
int256 indexed current,
uint256 indexed roundId,
uint256 updatedAt
);
event NewRound(
uint256 indexed roundId,
address indexed startedBy,
uint256 startedAt
);
}{
"optimizer": {
"enabled": true,
"runs": 9999
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract AggregatorV3Interface","name":"feed","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"getRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pricefeed","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60c060405234801561001057600080fd5b5060405161059838038061059883398101604081905261002f916100eb565b806001600160a01b03166080816001600160a01b0316815250506100c26012826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561008c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b0919061011b565b60ff166100d660201b6101d81760201c565b6100cd90600a610238565b60a0525061025b565b60006100e28284610244565b90505b92915050565b6000602082840312156100fd57600080fd5b81516001600160a01b038116811461011457600080fd5b9392505050565b60006020828403121561012d57600080fd5b815160ff8116811461011457600080fd5b634e487b7160e01b600052601160045260246000fd5b600181815b8085111561018f5781600019048211156101755761017561013e565b8085161561018257918102915b93841c9390800290610159565b509250929050565b6000826101a6575060016100e5565b816101b3575060006100e5565b81600181146101c957600281146101d3576101ef565b60019150506100e5565b60ff8411156101e4576101e461013e565b50506001821b6100e5565b5060208310610133831016604e8410600b8410161715610212575081810a6100e5565b61021c8383610154565b80600019048211156102305761023061013e565b029392505050565b60006100e28383610197565b6000828210156102565761025661013e565b500390565b60805160a05161031361028560003960006101ad0152600081816040015260a701526103136000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063590f21131461003b578063679aefce1461008c575b600080fd5b6100627f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100946100a2565b604051908152602001610083565b6000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610110573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610134919061020a565b505050915050600081136101a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f496e76616c6964207072696365207261746520726573706f6e73650000000000604482015260640160405180910390fd5b6101d27f000000000000000000000000000000000000000000000000000000000000000082610289565b91505090565b60006101e482846102c6565b9392505050565b805169ffffffffffffffffffff8116811461020557600080fd5b919050565b600080600080600060a0868803121561022257600080fd5b61022b866101eb565b945060208601519350604086015192506060860151915061024e608087016101eb565b90509295509295909350565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156102c1576102c161025a565b500290565b6000828210156102d8576102d861025a565b50039056fea2646970667358221220616f1f88194115ce4e7b5c9487117504096aa0c1a6978e58ad2486b1bd93eaae64736f6c634300080b0033000000000000000000000000fde8c36f32bf32e73a1bdeb4ef3e17709674a838
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063590f21131461003b578063679aefce1461008c575b600080fd5b6100627f000000000000000000000000fde8c36f32bf32e73a1bdeb4ef3e17709674a83881565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100946100a2565b604051908152602001610083565b6000807f000000000000000000000000fde8c36f32bf32e73a1bdeb4ef3e17709674a83873ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610110573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610134919061020a565b505050915050600081136101a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f496e76616c6964207072696365207261746520726573706f6e73650000000000604482015260640160405180910390fd5b6101d27f000000000000000000000000000000000000000000000000000000000000000182610289565b91505090565b60006101e482846102c6565b9392505050565b805169ffffffffffffffffffff8116811461020557600080fd5b919050565b600080600080600060a0868803121561022257600080fd5b61022b866101eb565b945060208601519350604086015192506060860151915061024e608087016101eb565b90509295509295909350565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156102c1576102c161025a565b500290565b6000828210156102d8576102d861025a565b50039056fea2646970667358221220616f1f88194115ce4e7b5c9487117504096aa0c1a6978e58ad2486b1bd93eaae64736f6c634300080b0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000fde8c36f32bf32e73a1bdeb4ef3e17709674a838
-----Decoded View---------------
Arg [0] : feed (address): 0xfdE8C36F32Bf32e73A1bdeb4ef3E17709674a838
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000fde8c36f32bf32e73a1bdeb4ef3e17709674a838
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in FRAX
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
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.