Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
FxEETHOracleV2
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity =0.8.20; import { Math } from "@openzeppelin/contracts-v4/utils/math/Math.sol"; import { IFxRateProvider } from "../../interfaces/f(x)/IFxRateProvider.sol"; import { ITwapOracle } from "../../price-oracle/interfaces/ITwapOracle.sol"; import { FxSpotOracleBase } from "./FxSpotOracleBase.sol"; import { FxLSDOracleV2Base } from "./FxLSDOracleV2Base.sol"; contract FxEETHOracleV2 is FxLSDOracleV2Base { /************* * Constants * *************/ /// @dev The address of weETH token. address internal constant weETH = 0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee; /// @notice The address of the RedStone weETH/ETH Twap. address public immutable RedStone_weETH_ETH_Twap; /*************** * Constructor * ***************/ constructor( address _spotPriceOracle, bytes32 _Chainlink_ETH_USD_Spot, address _Chainlink_ETH_USD_Twap, address _RedStone_weETH_ETH_Twap ) FxSpotOracleBase(_spotPriceOracle) FxLSDOracleV2Base(_Chainlink_ETH_USD_Spot, _Chainlink_ETH_USD_Twap) { RedStone_weETH_ETH_Twap = _RedStone_weETH_ETH_Twap; } /********************** * Internal Functions * **********************/ /// @inheritdoc FxLSDOracleV2Base /// @dev [RedStone weETH/ETH twap] * [Chainlink ETH/USD twap] / weETH.getRate() function _getLSDUSDTwap() internal view virtual override returns (uint256) { uint256 weETH_ETH_RedStoneTwap = ITwapOracle(RedStone_weETH_ETH_Twap).getTwap(block.timestamp); uint256 ETH_USD_ChainlinkTwap = _getETHUSDTwap(); unchecked { return (weETH_ETH_RedStoneTwap * ETH_USD_ChainlinkTwap) / IFxRateProvider(weETH).getRate(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol) pragma solidity ^0.8.0; import "./Ownable.sol"; /** * @dev Contract module which provides access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2Step is Ownable { address private _pendingOwner; event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner"); _transferOwnership(sender); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.20; import { Math } from "@openzeppelin/contracts-v4/utils/math/Math.sol"; import { FxSpotOracleBase } from "./FxSpotOracleBase.sol"; import { IFxPriceOracleV2 } from "../../interfaces/f(x)/IFxPriceOracleV2.sol"; import { ITwapOracle } from "../../price-oracle/interfaces/ITwapOracle.sol"; abstract contract FxLSDOracleV2Base is FxSpotOracleBase, IFxPriceOracleV2 { /************* * Constants * *************/ /// @notice The Chainlink ETH/USD price feed. /// @dev See comments of `_readSpotPriceByChainlink` for more details. bytes32 public immutable Chainlink_ETH_USD_Spot; /// @notice The address of the Chainlink ETH/USD Twap. address public immutable Chainlink_ETH_USD_Twap; /************* * Variables * *************/ /// @dev The encodings for ETH/USD spot sources. bytes private onchainSpotEncodings_ETHUSD; /// @dev The encodings for LSD/ETH spot sources. bytes private onchainSpotEncodings_LSDETH; /// @dev The encodings for LSD/USD spot sources. bytes private onchainSpotEncodings_LSDUSD; /// @notice The value of maximum price deviation, multiplied by 1e18. uint256 public maxPriceDeviation; /*************** * Constructor * ***************/ constructor(bytes32 _Chainlink_ETH_USD_Spot, address _Chainlink_ETH_USD_Twap) { Chainlink_ETH_USD_Spot = _Chainlink_ETH_USD_Spot; Chainlink_ETH_USD_Twap = _Chainlink_ETH_USD_Twap; _updateMaxPriceDeviation(1e16); // 1% } /************************* * Public View Functions * *************************/ /// @notice Return the ETH/USD spot price. /// @return chainlinkPrice The spot price from Chainlink price feed. /// @return minPrice The minimum spot price among all available sources. /// @return maxPrice The maximum spot price among all available sources. function getETHUSDSpotPrice() external view returns ( uint256 chainlinkPrice, uint256 minPrice, uint256 maxPrice ) { (chainlinkPrice, minPrice, maxPrice) = _getETHUSDSpotPrice(); } /// @notice Return the ETH/USD spot prices. /// @return prices The list of spot price among all available sources, multiplied by 1e18. function getETHUSDSpotPrices() external view returns (uint256[] memory prices) { prices = _getSpotPriceByEncoding(onchainSpotEncodings_ETHUSD); } /// @notice Return the LSD/ETH spot prices. /// @return prices The list of spot price among all available sources, multiplied by 1e18. function getLSDETHSpotPrices() public view returns (uint256[] memory prices) { prices = _getSpotPriceByEncoding(onchainSpotEncodings_LSDETH); } /// @notice Return the LSD/ETH spot prices. /// @return prices The list of spot price among all available sources, multiplied by 1e18. function getLSDUSDSpotPrices() public view returns (uint256[] memory prices) { prices = _getSpotPriceByEncoding(onchainSpotEncodings_LSDUSD); } /// @notice Return the ETH/USD time-weighted average price. /// @return price The time-weighted average price, multiplied by 1e18. function getETHUSDTwap() external view returns (uint256 price) { price = _getETHUSDTwap(); } /// @notice Return the LSD/USD time-weighted average price. /// @return price The time-weighted average price, multiplied by 1e18. function getLSDUSDTwap() external view returns (uint256 price) { price = _getLSDUSDTwap(); } /// @inheritdoc IFxPriceOracleV2 /// @dev The price is valid iff |maxPrice-minPrice|/minPrice < maxPriceDeviation function getPrice() external view override returns ( bool isValid, uint256 twap, uint256 minPrice, uint256 maxPrice ) { twap = _getLSDUSDTwap(); (minPrice, maxPrice) = _getLSDMinMaxPrice(twap); unchecked { isValid = (maxPrice - minPrice) * PRECISION < maxPriceDeviation * minPrice; } } /************************ * Restricted Functions * ************************/ /// @notice Update the on-chain spot encodings. /// @param encodings The encodings to update. See `_getSpotPriceByEncoding` for more details. /// @param spotType The type of the encodings. function updateOnchainSpotEncodings(bytes memory encodings, uint256 spotType) external onlyOwner { // validate encoding uint256[] memory prices = _getSpotPriceByEncoding(encodings); if (spotType == 0) { onchainSpotEncodings_ETHUSD = encodings; if (prices.length == 0) revert ErrorInvalidEncodings(); } else if (spotType == 1) { onchainSpotEncodings_LSDETH = encodings; } else if (spotType == 2) { onchainSpotEncodings_LSDUSD = encodings; } } /// @notice Update the value of maximum price deviation. /// @param newMaxPriceDeviation The new value of maximum price deviation, multiplied by 1e18. function updateMaxPriceDeviation(uint256 newMaxPriceDeviation) external onlyOwner { _updateMaxPriceDeviation(newMaxPriceDeviation); } /********************** * Internal Functions * **********************/ /// @dev Internal function to update the value of maximum price deviation. /// @param newMaxPriceDeviation The new value of maximum price deviation, multiplied by 1e18. function _updateMaxPriceDeviation(uint256 newMaxPriceDeviation) private { uint256 oldMaxPriceDeviation = maxPriceDeviation; maxPriceDeviation = newMaxPriceDeviation; emit UpdateMaxPriceDeviation(oldMaxPriceDeviation, newMaxPriceDeviation); } /// @dev Internal function to calculate the ETH/USD spot price. /// @return chainlinkPrice The spot price from Chainlink price feed, multiplied by 1e18. /// @return minPrice The minimum spot price among all available sources, multiplied by 1e18. /// @return maxPrice The maximum spot price among all available sources, multiplied by 1e18. function _getETHUSDSpotPrice() internal view returns ( uint256 chainlinkPrice, uint256 minPrice, uint256 maxPrice ) { chainlinkPrice = _readSpotPriceByChainlink(Chainlink_ETH_USD_Spot); uint256[] memory prices = _getSpotPriceByEncoding(onchainSpotEncodings_ETHUSD); minPrice = maxPrice = chainlinkPrice; for (uint256 i = 0; i < prices.length; i++) { if (prices[i] > maxPrice) maxPrice = prices[i]; if (prices[i] < minPrice) minPrice = prices[i]; } } /// @dev Internal function to return the ETH/USD time-weighted average price. /// @return price The time-weighted average price of ETH/USD, multiplied by 1e18. function _getETHUSDTwap() internal view returns (uint256 price) { price = ITwapOracle(Chainlink_ETH_USD_Twap).getTwap(block.timestamp); } /// @dev Internal function to return the min/max LSD/USD prices. /// @param twap The LSD/USD time-weighted average price, multiplied by 1e18. /// @return minPrice The minimum price among all available sources (including twap), multiplied by 1e18. /// @return maxPrice The maximum price among all available sources (including twap), multiplied by 1e18. function _getLSDMinMaxPrice(uint256 twap) internal view returns (uint256 minPrice, uint256 maxPrice) { minPrice = maxPrice = twap; (, uint256 minETHUSDPrice, uint256 maxETHUSDPrice) = _getETHUSDSpotPrice(); uint256[] memory LSD_ETH_prices = getLSDETHSpotPrices(); uint256[] memory LSD_USD_prices = getLSDUSDSpotPrices(); uint256 length = LSD_ETH_prices.length; uint256 LSD_ETH_minPrice = type(uint256).max; uint256 LSD_ETH_maxPrice; unchecked { for (uint256 i = 0; i < length; i++) { uint256 price = LSD_ETH_prices[i]; if (price > LSD_ETH_maxPrice) LSD_ETH_maxPrice = price; if (price < LSD_ETH_minPrice) LSD_ETH_minPrice = price; } if (LSD_ETH_maxPrice != 0) { minPrice = Math.min(minPrice, (LSD_ETH_minPrice * minETHUSDPrice) / PRECISION); maxPrice = Math.max(maxPrice, (LSD_ETH_maxPrice * maxETHUSDPrice) / PRECISION); } length = LSD_USD_prices.length; for (uint256 i = 0; i < length; i++) { uint256 price = LSD_USD_prices[i]; if (price > maxPrice) maxPrice = price; if (price < minPrice) minPrice = price; } } } /// @dev Internal function to return the LSD/USD time-weighted average price. /// @return price The time-weighted average price of LSD/USD, multiplied by 1e18. function _getLSDUSDTwap() internal view virtual returns (uint256 price); }
// SPDX-License-Identifier: MIT pragma solidity =0.8.20; import { Ownable2Step } from "@openzeppelin/contracts-v4/access/Ownable2Step.sol"; import { AggregatorV3Interface } from "../../price-oracle/interfaces/AggregatorV3Interface.sol"; import { ISpotPriceOracle } from "../../price-oracle/interfaces/ISpotPriceOracle.sol"; abstract contract FxSpotOracleBase is Ownable2Step { /********** * Errors * **********/ /// @dev Thrown when the given encodings are invalid. error ErrorInvalidEncodings(); /************* * Constants * *************/ /// @dev The precision for oracle price. uint256 internal constant PRECISION = 1e18; /// @dev The address of `SpotPriceOracle` contract. address immutable spotPriceOracle; /*************** * Constructor * ***************/ constructor(address _spotPriceOracle) { spotPriceOracle = _spotPriceOracle; } /********************** * Internal Functions * **********************/ /// @dev The encoding is below. /// ```text /// | 32 bits | 64 bits | 160 bits | /// | heartbeat | scale | price_feed | /// |low high | /// ``` function _readSpotPriceByChainlink(bytes32 encoding) internal view returns (uint256) { address aggregator; uint256 scale; uint256 heartbeat; assembly { aggregator := shr(96, encoding) scale := and(shr(32, encoding), 0xffffffffffffffff) heartbeat := and(encoding, 0xffffffff) } (, int256 answer, , uint256 updatedAt, ) = AggregatorV3Interface(aggregator).latestRoundData(); if (block.timestamp - updatedAt > heartbeat) revert("expired"); return uint256(answer) * scale; } /// @dev Internal function to calculate spot price by encodings. /// /// The details of the encoding is below /// ```text /// | 1 byte | ... | ... | ... | ... | /// | num_source | source[0] | source[1] | ... | source[n] | /// /// source encoding: /// | 1 byte | 32 bytes | 32 bytes | ... | 32 bytes | /// | num_pool | pool[0] | pool[1] | ... | pool[n] | /// 1 <= num_pool <= 3 /// /// The encoding of each pool can be found in `SpotPriceOracle` contract. /// ``` /// @return prices The list of prices of each source, multiplied by 1e18. function _getSpotPriceByEncoding(bytes memory encodings) internal view returns (uint256[] memory prices) { uint256 ptr; uint256 length; assembly { ptr := add(encodings, 0x21) length := byte(0, mload(sub(ptr, 1))) } prices = new uint256[](length); for (uint256 i = 0; i < length; i++) { uint256 encoding1; uint256 encoding2; uint256 encoding3; assembly { let cnt := byte(0, mload(ptr)) ptr := add(ptr, 0x01) if gt(cnt, 0) { encoding1 := mload(ptr) ptr := add(ptr, 0x20) } if gt(cnt, 1) { encoding2 := mload(ptr) ptr := add(ptr, 0x20) } if gt(cnt, 2) { encoding3 := mload(ptr) ptr := add(ptr, 0x20) } } if (encoding1 == 0) { revert ErrorInvalidEncodings(); } else if (encoding2 == 0) { prices[i] = _readSpotPrice(encoding1); } else if (encoding3 == 0) { prices[i] = _readSpotPrice(encoding1, encoding2); } else { prices[i] = _readSpotPrice(encoding1, encoding2, encoding3); } } } /// @dev Internal function to calculate spot price of single pool. /// @param encoding The encoding for the pool. /// @return price The spot price of the source, multiplied by 1e18. function _readSpotPrice(uint256 encoding) private view returns (uint256 price) { price = ISpotPriceOracle(spotPriceOracle).getSpotPrice(encoding); } /// @dev Internal function to calculate spot price of two pools. /// @param encoding1 The encoding for the first pool. /// @param encoding2 The encoding for the second pool. /// @return price The spot price of the source, multiplied by 1e18. function _readSpotPrice(uint256 encoding1, uint256 encoding2) private view returns (uint256 price) { unchecked { price = (_readSpotPrice(encoding1) * _readSpotPrice(encoding2)) / PRECISION; } } /// @dev Internal function to calculate spot price of three pools. /// @param encoding1 The encoding for the first pool. /// @param encoding2 The encoding for the second pool. /// @param encoding3 The encoding for the third pool. /// @return price The spot price of the source, multiplied by 1e18. function _readSpotPrice( uint256 encoding1, uint256 encoding2, uint256 encoding3 ) private view returns (uint256 price) { unchecked { price = (_readSpotPrice(encoding1, encoding2) * _readSpotPrice(encoding3)) / PRECISION; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0 || ^0.8.0; interface IFxPriceOracleV2 { /********** * Events * **********/ /// @notice Emitted when the value of maximum price deviation is updated. /// @param oldValue The value of the previous maximum price deviation. /// @param newValue The value of the current maximum price deviation. event UpdateMaxPriceDeviation(uint256 oldValue, uint256 newValue); /************************* * Public View Functions * *************************/ /// @notice Return the oracle price with 18 decimal places. /// @return isValid Whether the oracle price is valid -- the difference between `minPrice` and `maxPrice` is reasonable. /// @return twap The time-weighted average price, multiplied by 1e18. It should be the anchor price for this asset, which is hard to manipulate. /// @return minPrice The minimum oracle price among all available price sources (including twap), multiplied by 1e18. /// @return maxPrice The maximum oracle price among all available price sources (including twap), multiplied by 1e18. function getPrice() external view returns ( bool isValid, uint256 twap, uint256 minPrice, uint256 maxPrice ); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0 || ^0.8.0; interface IFxRateProvider { /// @notice Return the exchange rate from wrapped token to underlying rate, /// multiplied by 1e18. function getRate() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0 || ^0.8.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); function latestAnswer() external view returns (uint256); 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.7.0 || ^0.8.0; interface ISpotPriceOracle { /// @notice Return spot price with 18 decimal places. /// /// @dev encoding for single route /// | 8 bits | 160 bits | 88 bits | /// | pool_type | pool | customized | /// assume all base and quote token has no more than 18 decimals. /// /// + pool_type = 0: UniswapV2 /// customized = | 1 bit | 8 bits | 8 bits | ... | /// | base_index | base_scale | quote_scale | ... | /// + pool_type = 1: UniswapV3 /// customized = | 1 bit | 8 bits | 8 bits | ... | /// | base_index | base_scale | quote_scale | ... | /// + pool_type = 2: Balancer V2 Weighted /// customized = | 3 bit | 3 bit | 8 bits | 8 bits | ... | /// | base_index | quote_index | base_scale | quote_scale | ... | /// + pool_type = 3: Balancer V2 Stable /// customized = | 3 bits | 3 bits | ... | /// | base_index | quote_index | ... | /// + pool_type = 4: Curve Plain /// customized = | 3 bits | 3 bits | 3 bits | 1 bits | 8 bits | ... | 8 bits | ... | /// | tokens | base_index | quote_index | has_amm_precise | scale[0] | ... | scale[n] | ... | /// + pool_type = 5: Curve Plain with oracle /// customized = | 1 bit | 1 bit |... | /// | base_index | use_cache | ... | /// + pool_type = 6: Curve Plain NG /// customized = | 3 bits | 3 bits | 1 bit | ... | /// | base_index | quote_index | use_cache | ... | /// + pool_type = 7: Curve Crypto /// customized = | 1 bit | ... | /// | base_index | ... | /// + pool_type = 8: Curve TriCrypto /// customized = | 2 bits | 2 bits | ... | /// | base_index | quote_index | ... | /// + pool_type = 9: ERC4626 /// customized = | 1 bit | ... | /// | base_is_underlying | ... | /// + pool_type = 10: ETHLSD, wstETH, weETH, ezETH /// customized = | 1 bit | ... | /// | base_is_ETH | ... | /// + pool_type = 11: BalancerV2CachedRate /// customized = | 3 bits | ... | /// | base_index | ... | /// /// @param encoding The encoding of the price source. /// @return spotPrice The spot price with 18 decimal places. function getSpotPrice(uint256 encoding) external view returns (uint256 spotPrice); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0 || ^0.8.0; interface ITwapOracle { /// @notice Return TWAP with 18 decimal places in the epoch ending at the specified timestamp. /// Zero is returned if TWAP in the epoch is not available. /// @param timestamp End Timestamp in seconds of the epoch /// @return TWAP (18 decimal places) in the epoch, or zero if not available function getTwap(uint256 timestamp) external view returns (uint256); /// @notice Return the latest price with 18 decimal places. function getLatest() external view returns (uint256); }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "shanghai", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_spotPriceOracle","type":"address"},{"internalType":"bytes32","name":"_Chainlink_ETH_USD_Spot","type":"bytes32"},{"internalType":"address","name":"_Chainlink_ETH_USD_Twap","type":"address"},{"internalType":"address","name":"_RedStone_weETH_ETH_Twap","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ErrorInvalidEncodings","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"UpdateMaxPriceDeviation","type":"event"},{"inputs":[],"name":"Chainlink_ETH_USD_Spot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"Chainlink_ETH_USD_Twap","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RedStone_weETH_ETH_Twap","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getETHUSDSpotPrice","outputs":[{"internalType":"uint256","name":"chainlinkPrice","type":"uint256"},{"internalType":"uint256","name":"minPrice","type":"uint256"},{"internalType":"uint256","name":"maxPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getETHUSDSpotPrices","outputs":[{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getETHUSDTwap","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLSDETHSpotPrices","outputs":[{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLSDUSDSpotPrices","outputs":[{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLSDUSDTwap","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"bool","name":"isValid","type":"bool"},{"internalType":"uint256","name":"twap","type":"uint256"},{"internalType":"uint256","name":"minPrice","type":"uint256"},{"internalType":"uint256","name":"maxPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPriceDeviation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMaxPriceDeviation","type":"uint256"}],"name":"updateMaxPriceDeviation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodings","type":"bytes"},{"internalType":"uint256","name":"spotType","type":"uint256"}],"name":"updateOnchainSpotEncodings","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
61010060405234801562000011575f80fd5b50604051620012f1380380620012f1833981016040819052620000349162000152565b828285620000423362000084565b6001600160a01b0390811660805260a0839052811660c0526200006c662386f26fc10000620000a2565b50506001600160a01b031660e05250620001a3915050565b600180546001600160a01b03191690556200009f81620000e7565b50565b600580549082905560408051828152602081018490527f23df930eba8ee7044ae7ac6a1957ef1e8e314bdcebc6347bc92decdbff21b717910160405180910390a15050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200014d575f80fd5b919050565b5f805f806080858703121562000166575f80fd5b620001718562000136565b935060208501519250620001886040860162000136565b9150620001986060860162000136565b905092959194509250565b60805160a05160c05160e051611105620001ec5f395f8181610160015261078601525f81816101c50152610a8c01525f81816101ec015261089001525f610b1501526111055ff3fe608060405234801561000f575f80fd5b5060043610610111575f3560e01c80638da5cb5b1161009e578063c6bd4b251161006e578063c6bd4b2514610274578063e30c39781461027c578063f2fde38b1461028d578063f65932fe146102a0578063fe6b400d146102a8575f80fd5b80638da5cb5b1461020e5780639224a3351461021e578063975b86621461024157806398d5fdca1461024a575f80fd5b8063715018a6116100e4578063715018a61461019a57806379ba5097146101a25780637b60b8d5146101aa5780638281e85c146101c057806384de4087146101e7575f80fd5b80632427546d1461011557806324f1c5c11461012a5780636b7d41411461013d5780636b90b1161461015b575b5f80fd5b610128610123366004610d60565b6102b0565b005b610128610138366004610e0f565b61032c565b610145610340565b6040516101529190610e26565b60405180910390f35b6101827f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610152565b6101286103d8565b6101286103eb565b6101b2610467565b604051908152602001610152565b6101827f000000000000000000000000000000000000000000000000000000000000000081565b6101b27f000000000000000000000000000000000000000000000000000000000000000081565b5f546001600160a01b0316610182565b610226610470565b60408051938452602084019290925290820152606001610152565b6101b260055481565b610252610487565b6040805194151585526020850193909352918301526060820152608001610152565b6101b26104be565b6001546001600160a01b0316610182565b61012861029b366004610e69565b6104c7565b610145610537565b610145610549565b6102b861055b565b5f6102c2836105b4565b9050815f036102fe5760026102d78482610f14565b5080515f036102f95760405163f23044db60e01b815260040160405180910390fd5b505050565b816001036103185760036103128482610f14565b50505050565b816002036102f95760046103128482610f14565b61033461055b565b61033d81610707565b50565b60606103d36003805461035290610e8f565b80601f016020809104026020016040519081016040528092919081815260200182805461037e90610e8f565b80156103c95780601f106103a0576101008083540402835291602001916103c9565b820191905f5260205f20905b8154815290600101906020018083116103ac57829003601f168201915b50505050506105b4565b905090565b6103e061055b565b6103e95f61074c565b565b60015433906001600160a01b0316811461045e5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084015b60405180910390fd5b61033d8161074c565b5f6103d3610765565b5f805f61047b610888565b91959094509092509050565b5f805f80610493610765565b925061049e8361096f565b6005548202828203670de0b6b3a764000002109694955090939092509050565b5f6103d3610a75565b6104cf61055b565b600180546001600160a01b0383166001600160a01b031990911681179091556104ff5f546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60606103d36004805461035290610e8f565b60606103d36002805461035290610e8f565b5f546001600160a01b031633146103e95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610455565b602081015160609060218301905f1a8067ffffffffffffffff8111156105dc576105dc610d4c565b604051908082528060200260200182016040528015610605578160200160208202803683370190505b5092505f5b818110156106ff575f805f85515f1a6001870196505f81111561063257865193506020870196505b600181111561064657865192506020870196505b600281111561065a57865191506020870196505b50825f0361067b5760405163f23044db60e01b815260040160405180910390fd5b815f036106ae5761068b83610afd565b87858151811061069d5761069d610fd0565b6020026020010181815250506106e9565b805f036106bf5761068b8383610b8c565b6106ca838383610bbe565b8785815181106106dc576106dc610fd0565b6020026020010181815250505b50505080806106f790610ff8565b91505061060a565b505050919050565b600580549082905560408051828152602081018490527f23df930eba8ee7044ae7ac6a1957ef1e8e314bdcebc6347bc92decdbff21b717910160405180910390a15050565b600180546001600160a01b031916905561033d81610bf2565b604051639f05715160e01b81524260048201525f9081906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639f05715190602401602060405180830381865afa1580156107cb573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107ef9190611010565b90505f6107fa610a75565b905073cd5fe23c85820f7b72d0926fc9b05b43e359b7ee6001600160a01b031663679aefce6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561084c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108709190611010565b8183028161088057610880611027565b049250505090565b5f805f6108b47f0000000000000000000000000000000000000000000000000000000000000000610c41565b92505f6108c76002805461035290610e8f565b90508391508192505f5b815181101561096857828282815181106108ed576108ed610fd0565b602002602001015111156109185781818151811061090d5761090d610fd0565b602002602001015192505b8382828151811061092b5761092b610fd0565b602002602001015110156109565781818151811061094b5761094b610fd0565b602002602001015193505b8061096081610ff8565b9150506108d1565b5050909192565b80805f8061097b610888565b92509250505f610989610340565b90505f610994610537565b82519091505f195f805b838110156109e4575f8682815181106109b9576109b9610fd0565b60200260200101519050828111156109cf578092505b838110156109db578093505b5060010161099e565b508015610a1c57610a0189670de0b6b3a7640000848a0204610d27565b9850610a1988670de0b6b3a764000083890204610d3e565b97505b835192505f5b83811015610a68575f858281518110610a3d57610a3d610fd0565b6020026020010151905089811115610a53578099505b8a811015610a5f57809a505b50600101610a22565b5050505050505050915091565b604051639f05715160e01b81524260048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690639f05715190602401602060405180830381865afa158015610ad9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103d39190611010565b604051630fda366d60e01b8152600481018290525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630fda366d90602401602060405180830381865afa158015610b62573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b869190611010565b92915050565b5f670de0b6b3a7640000610b9f83610afd565b610ba885610afd565b0281610bb657610bb6611027565b049392505050565b5f670de0b6b3a7640000610bd183610afd565b610bdb8686610b8c565b0281610be957610be9611027565b04949350505050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f805f808460601c925067ffffffffffffffff8560201c16915063ffffffff851690505f80846001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610ca2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cc69190611059565b50935050925050828142610cda91906110a5565b1115610d125760405162461bcd60e51b8152602060048201526007602482015266195e1c1a5c995960ca1b6044820152606401610455565b610d1c84836110b8565b979650505050505050565b5f818310610d355781610d37565b825b9392505050565b5f818311610d355781610d37565b634e487b7160e01b5f52604160045260245ffd5b5f8060408385031215610d71575f80fd5b823567ffffffffffffffff80821115610d88575f80fd5b818501915085601f830112610d9b575f80fd5b813581811115610dad57610dad610d4c565b604051601f8201601f19908116603f01168101908382118183101715610dd557610dd5610d4c565b81604052828152886020848701011115610ded575f80fd5b826020860160208301375f602093820184015298969091013596505050505050565b5f60208284031215610e1f575f80fd5b5035919050565b602080825282518282018190525f9190848201906040850190845b81811015610e5d57835183529284019291840191600101610e41565b50909695505050505050565b5f60208284031215610e79575f80fd5b81356001600160a01b0381168114610d37575f80fd5b600181811c90821680610ea357607f821691505b602082108103610ec157634e487b7160e01b5f52602260045260245ffd5b50919050565b601f8211156102f9575f81815260208120601f850160051c81016020861015610eed5750805b601f850160051c820191505b81811015610f0c57828155600101610ef9565b505050505050565b815167ffffffffffffffff811115610f2e57610f2e610d4c565b610f4281610f3c8454610e8f565b84610ec7565b602080601f831160018114610f75575f8415610f5e5750858301515b5f19600386901b1c1916600185901b178555610f0c565b5f85815260208120601f198616915b82811015610fa357888601518255948401946001909101908401610f84565b5085821015610fc057878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f6001820161100957611009610fe4565b5060010190565b5f60208284031215611020575f80fd5b5051919050565b634e487b7160e01b5f52601260045260245ffd5b805169ffffffffffffffffffff81168114611054575f80fd5b919050565b5f805f805f60a0868803121561106d575f80fd5b6110768661103b565b94506020860151935060408601519250606086015191506110996080870161103b565b90509295509295909350565b81810381811115610b8657610b86610fe4565b8082028115828204841417610b8657610b86610fe456fea2646970667358221220a587ab7630f3c95401f5e7d41dcfcd674dae62fc25064177c44a1fe7daf4055664736f6c63430008140033000000000000000000000000c2312caf0de62ec9b4adc785c79851cb989c9abc5f4ec3df9cbd43714fe2740f5e3616155c5b841900000002540be40000002a300000000000000000000000002eb56aa6a6e48b142287f723e547c687281580bd00000000000000000000000056bc0ec4049f25e7dd455b64d1c6318c1d9ce789
Deployed Bytecode
0x608060405234801561000f575f80fd5b5060043610610111575f3560e01c80638da5cb5b1161009e578063c6bd4b251161006e578063c6bd4b2514610274578063e30c39781461027c578063f2fde38b1461028d578063f65932fe146102a0578063fe6b400d146102a8575f80fd5b80638da5cb5b1461020e5780639224a3351461021e578063975b86621461024157806398d5fdca1461024a575f80fd5b8063715018a6116100e4578063715018a61461019a57806379ba5097146101a25780637b60b8d5146101aa5780638281e85c146101c057806384de4087146101e7575f80fd5b80632427546d1461011557806324f1c5c11461012a5780636b7d41411461013d5780636b90b1161461015b575b5f80fd5b610128610123366004610d60565b6102b0565b005b610128610138366004610e0f565b61032c565b610145610340565b6040516101529190610e26565b60405180910390f35b6101827f00000000000000000000000056bc0ec4049f25e7dd455b64d1c6318c1d9ce78981565b6040516001600160a01b039091168152602001610152565b6101286103d8565b6101286103eb565b6101b2610467565b604051908152602001610152565b6101827f0000000000000000000000002eb56aa6a6e48b142287f723e547c687281580bd81565b6101b27f5f4ec3df9cbd43714fe2740f5e3616155c5b841900000002540be40000002a3081565b5f546001600160a01b0316610182565b610226610470565b60408051938452602084019290925290820152606001610152565b6101b260055481565b610252610487565b6040805194151585526020850193909352918301526060820152608001610152565b6101b26104be565b6001546001600160a01b0316610182565b61012861029b366004610e69565b6104c7565b610145610537565b610145610549565b6102b861055b565b5f6102c2836105b4565b9050815f036102fe5760026102d78482610f14565b5080515f036102f95760405163f23044db60e01b815260040160405180910390fd5b505050565b816001036103185760036103128482610f14565b50505050565b816002036102f95760046103128482610f14565b61033461055b565b61033d81610707565b50565b60606103d36003805461035290610e8f565b80601f016020809104026020016040519081016040528092919081815260200182805461037e90610e8f565b80156103c95780601f106103a0576101008083540402835291602001916103c9565b820191905f5260205f20905b8154815290600101906020018083116103ac57829003601f168201915b50505050506105b4565b905090565b6103e061055b565b6103e95f61074c565b565b60015433906001600160a01b0316811461045e5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084015b60405180910390fd5b61033d8161074c565b5f6103d3610765565b5f805f61047b610888565b91959094509092509050565b5f805f80610493610765565b925061049e8361096f565b6005548202828203670de0b6b3a764000002109694955090939092509050565b5f6103d3610a75565b6104cf61055b565b600180546001600160a01b0383166001600160a01b031990911681179091556104ff5f546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60606103d36004805461035290610e8f565b60606103d36002805461035290610e8f565b5f546001600160a01b031633146103e95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610455565b602081015160609060218301905f1a8067ffffffffffffffff8111156105dc576105dc610d4c565b604051908082528060200260200182016040528015610605578160200160208202803683370190505b5092505f5b818110156106ff575f805f85515f1a6001870196505f81111561063257865193506020870196505b600181111561064657865192506020870196505b600281111561065a57865191506020870196505b50825f0361067b5760405163f23044db60e01b815260040160405180910390fd5b815f036106ae5761068b83610afd565b87858151811061069d5761069d610fd0565b6020026020010181815250506106e9565b805f036106bf5761068b8383610b8c565b6106ca838383610bbe565b8785815181106106dc576106dc610fd0565b6020026020010181815250505b50505080806106f790610ff8565b91505061060a565b505050919050565b600580549082905560408051828152602081018490527f23df930eba8ee7044ae7ac6a1957ef1e8e314bdcebc6347bc92decdbff21b717910160405180910390a15050565b600180546001600160a01b031916905561033d81610bf2565b604051639f05715160e01b81524260048201525f9081906001600160a01b037f00000000000000000000000056bc0ec4049f25e7dd455b64d1c6318c1d9ce7891690639f05715190602401602060405180830381865afa1580156107cb573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107ef9190611010565b90505f6107fa610a75565b905073cd5fe23c85820f7b72d0926fc9b05b43e359b7ee6001600160a01b031663679aefce6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561084c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108709190611010565b8183028161088057610880611027565b049250505090565b5f805f6108b47f5f4ec3df9cbd43714fe2740f5e3616155c5b841900000002540be40000002a30610c41565b92505f6108c76002805461035290610e8f565b90508391508192505f5b815181101561096857828282815181106108ed576108ed610fd0565b602002602001015111156109185781818151811061090d5761090d610fd0565b602002602001015192505b8382828151811061092b5761092b610fd0565b602002602001015110156109565781818151811061094b5761094b610fd0565b602002602001015193505b8061096081610ff8565b9150506108d1565b5050909192565b80805f8061097b610888565b92509250505f610989610340565b90505f610994610537565b82519091505f195f805b838110156109e4575f8682815181106109b9576109b9610fd0565b60200260200101519050828111156109cf578092505b838110156109db578093505b5060010161099e565b508015610a1c57610a0189670de0b6b3a7640000848a0204610d27565b9850610a1988670de0b6b3a764000083890204610d3e565b97505b835192505f5b83811015610a68575f858281518110610a3d57610a3d610fd0565b6020026020010151905089811115610a53578099505b8a811015610a5f57809a505b50600101610a22565b5050505050505050915091565b604051639f05715160e01b81524260048201525f907f0000000000000000000000002eb56aa6a6e48b142287f723e547c687281580bd6001600160a01b031690639f05715190602401602060405180830381865afa158015610ad9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103d39190611010565b604051630fda366d60e01b8152600481018290525f907f000000000000000000000000c2312caf0de62ec9b4adc785c79851cb989c9abc6001600160a01b031690630fda366d90602401602060405180830381865afa158015610b62573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b869190611010565b92915050565b5f670de0b6b3a7640000610b9f83610afd565b610ba885610afd565b0281610bb657610bb6611027565b049392505050565b5f670de0b6b3a7640000610bd183610afd565b610bdb8686610b8c565b0281610be957610be9611027565b04949350505050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f805f808460601c925067ffffffffffffffff8560201c16915063ffffffff851690505f80846001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610ca2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cc69190611059565b50935050925050828142610cda91906110a5565b1115610d125760405162461bcd60e51b8152602060048201526007602482015266195e1c1a5c995960ca1b6044820152606401610455565b610d1c84836110b8565b979650505050505050565b5f818310610d355781610d37565b825b9392505050565b5f818311610d355781610d37565b634e487b7160e01b5f52604160045260245ffd5b5f8060408385031215610d71575f80fd5b823567ffffffffffffffff80821115610d88575f80fd5b818501915085601f830112610d9b575f80fd5b813581811115610dad57610dad610d4c565b604051601f8201601f19908116603f01168101908382118183101715610dd557610dd5610d4c565b81604052828152886020848701011115610ded575f80fd5b826020860160208301375f602093820184015298969091013596505050505050565b5f60208284031215610e1f575f80fd5b5035919050565b602080825282518282018190525f9190848201906040850190845b81811015610e5d57835183529284019291840191600101610e41565b50909695505050505050565b5f60208284031215610e79575f80fd5b81356001600160a01b0381168114610d37575f80fd5b600181811c90821680610ea357607f821691505b602082108103610ec157634e487b7160e01b5f52602260045260245ffd5b50919050565b601f8211156102f9575f81815260208120601f850160051c81016020861015610eed5750805b601f850160051c820191505b81811015610f0c57828155600101610ef9565b505050505050565b815167ffffffffffffffff811115610f2e57610f2e610d4c565b610f4281610f3c8454610e8f565b84610ec7565b602080601f831160018114610f75575f8415610f5e5750858301515b5f19600386901b1c1916600185901b178555610f0c565b5f85815260208120601f198616915b82811015610fa357888601518255948401946001909101908401610f84565b5085821015610fc057878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f6001820161100957611009610fe4565b5060010190565b5f60208284031215611020575f80fd5b5051919050565b634e487b7160e01b5f52601260045260245ffd5b805169ffffffffffffffffffff81168114611054575f80fd5b919050565b5f805f805f60a0868803121561106d575f80fd5b6110768661103b565b94506020860151935060408601519250606086015191506110996080870161103b565b90509295509295909350565b81810381811115610b8657610b86610fe4565b8082028115828204841417610b8657610b86610fe456fea2646970667358221220a587ab7630f3c95401f5e7d41dcfcd674dae62fc25064177c44a1fe7daf4055664736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c2312caf0de62ec9b4adc785c79851cb989c9abc5f4ec3df9cbd43714fe2740f5e3616155c5b841900000002540be40000002a300000000000000000000000002eb56aa6a6e48b142287f723e547c687281580bd00000000000000000000000056bc0ec4049f25e7dd455b64d1c6318c1d9ce789
-----Decoded View---------------
Arg [0] : _spotPriceOracle (address): 0xc2312CaF0De62eC9b4ADC785C79851Cb989C9abc
Arg [1] : _Chainlink_ETH_USD_Spot (bytes32): 0x5f4ec3df9cbd43714fe2740f5e3616155c5b841900000002540be40000002a30
Arg [2] : _Chainlink_ETH_USD_Twap (address): 0x2EB56aA6A6E48b142287f723E547c687281580bD
Arg [3] : _RedStone_weETH_ETH_Twap (address): 0x56bC0Ec4049f25E7dd455B64d1c6318c1D9Ce789
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000c2312caf0de62ec9b4adc785c79851cb989c9abc
Arg [1] : 5f4ec3df9cbd43714fe2740f5e3616155c5b841900000002540be40000002a30
Arg [2] : 0000000000000000000000002eb56aa6a6e48b142287f723e547c687281580bd
Arg [3] : 00000000000000000000000056bc0ec4049f25e7dd455b64d1c6318c1d9ce789
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.