diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c61389a..f96fe960 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,57 @@ +## [1.10.0-dev.8](https://github.com/VenusProtocol/oracle/compare/v1.10.0-dev.7...v1.10.0-dev.8) (2024-02-22) + + +### Bug Fixes + +* chainlink oracle deployment might not be available on some networks ([4868926](https://github.com/VenusProtocol/oracle/commit/4868926be37b57600301587bad4b81bfcc9c41d0)) + +## [1.10.0-dev.7](https://github.com/VenusProtocol/oracle/compare/v1.10.0-dev.6...v1.10.0-dev.7) (2024-02-22) + + +### Features + +* updating deployment files ([a322225](https://github.com/VenusProtocol/oracle/commit/a322225092f349e315dbfe483dd679e6bf698125)) +* updating deployment files ([3e9a5ce](https://github.com/VenusProtocol/oracle/commit/3e9a5cea393ec971271a348896f8818652839593)) + + +### Bug Fixes + +* deploy script ([0a17889](https://github.com/VenusProtocol/oracle/commit/0a17889c6b5c9d43fc119e5ca4514111628d1a81)) + +## [1.10.0-dev.6](https://github.com/VenusProtocol/oracle/compare/v1.10.0-dev.5...v1.10.0-dev.6) (2024-02-21) + +## [1.10.0-dev.5](https://github.com/VenusProtocol/oracle/compare/v1.10.0-dev.4...v1.10.0-dev.5) (2024-02-20) + + +### Bug Fixes + +* remove twap oracle ([85b1021](https://github.com/VenusProtocol/oracle/commit/85b1021928d1faaacf8d9263cf6c3916e1142f43)) + +## [1.10.0-dev.4](https://github.com/VenusProtocol/oracle/compare/v1.10.0-dev.3...v1.10.0-dev.4) (2024-02-07) + +## [1.10.0-dev.3](https://github.com/VenusProtocol/oracle/compare/v1.10.0-dev.2...v1.10.0-dev.3) (2024-02-05) + +## [1.10.0-dev.2](https://github.com/VenusProtocol/oracle/compare/v1.10.0-dev.1...v1.10.0-dev.2) (2024-02-01) + + +### Features + +* add wstETH oracle deployment on Ethereum ([505c721](https://github.com/VenusProtocol/oracle/commit/505c721d43f4dd02c2ae987dd3412a883b7f9bbb)) +* updating deployment files ([0acebd5](https://github.com/VenusProtocol/oracle/commit/0acebd566b0c0bab97bfd37b81ec561a3a493d4c)) + +## [1.10.0-dev.1](https://github.com/VenusProtocol/oracle/compare/v1.9.0...v1.10.0-dev.1) (2024-01-26) + + +### Features + +* add oracle deployments for opbnbmainnet ([f6655e7](https://github.com/VenusProtocol/oracle/commit/f6655e744b64236c65e1099bab1caf237d56eb16)) +* updating deployment files ([5d813b2](https://github.com/VenusProtocol/oracle/commit/5d813b2f9fdd82418f2f888a2f19e2822268a631)) + + +### Bug Fixes + +* hardcoded gas input ([ef80913](https://github.com/VenusProtocol/oracle/commit/ef809133e3cef279495435c6c7fa4062cf41de41)) + ## [1.9.0](https://github.com/VenusProtocol/oracle/compare/v1.8.0...v1.9.0) (2024-01-23) diff --git a/README.md b/README.md index f290451f..a9a0db93 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Resilient Price Feeds is a set of smart contracts that uses multiple oracles and DeFi protocols are vulnerable to incorrectly reported prices which can lead to lost money. A price oracle can be manipulated,fail, or suffer other attacks depending on the type of price oracle. It creates a single point of failure, opening attack vectors to the protocol if not mitigated. -The Resilient Price Feeds uses multiple oracle sources and fallback mechanisms to return accurate prices and protect from oracle failures. Currently, it includes integrations with Chainlink, RedStone, Pyth, Binance Oracle and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source. +The Resilient Price Feeds uses multiple oracle sources and fallback mechanisms to return accurate prices and protect from oracle failures. Currently, it includes integrations with Chainlink, RedStone, Pyth and Binance Oracle oracles. ## Details @@ -21,7 +21,7 @@ anchorRatio = anchorPrice/reporterPrice isValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio ``` -The default configuration uses Chainlink as the main oracle, TWAP, RedStone or Pyth oracle as the pivot oracle depending on which supports the given market and Binance oracle as the fallback oracle. For some markets we may use RedStone or Pyth as the main oracle if the token price is not supported by Chainlink or Binance oracles. +The default configuration uses Chainlink as the main oracle, RedStone or Pyth oracle as the pivot oracle depending on which supports the given market and Binance oracle as the fallback oracle. For some markets we may use RedStone or Pyth as the main oracle if the token price is not supported by Chainlink or Binance oracles. When fetching an oracle price, for the price to be valid it must be positive and not stagnant. If the price is invalid or stagnant it is ignored and a fallback oracle is used. diff --git a/audits/090_wstETHOracle_certik_20240126.pdf b/audits/090_wstETHOracle_certik_20240126.pdf new file mode 100644 index 00000000..d69c9d85 Binary files /dev/null and b/audits/090_wstETHOracle_certik_20240126.pdf differ diff --git a/audits/093_wstETHOracle_quantstamp_20240220.pdf b/audits/093_wstETHOracle_quantstamp_20240220.pdf new file mode 100644 index 00000000..d9e62fc9 Binary files /dev/null and b/audits/093_wstETHOracle_quantstamp_20240220.pdf differ diff --git a/audits/097_twap_hashex_20240201.pdf b/audits/097_twap_hashex_20240201.pdf new file mode 100644 index 00000000..051550c1 Binary files /dev/null and b/audits/097_twap_hashex_20240201.pdf differ diff --git a/contracts/libraries/PancakeLibrary.sol b/contracts/libraries/PancakeLibrary.sol deleted file mode 100644 index e760c5c0..00000000 --- a/contracts/libraries/PancakeLibrary.sol +++ /dev/null @@ -1,68 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.13; - -interface IPancakePair { - function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); - - function price0CumulativeLast() external view returns (uint256); - - function price1CumulativeLast() external view returns (uint256); -} - -library FixedPoint { - // range: [0, 2**112 - 1] - // resolution: 1 / 2**112 - struct uq112x112 { - uint224 _x; - } - - // returns a uq112x112 which represents the ratio of the numerator to the denominator - // equivalent to encode(numerator).div(denominator) - function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) { - require(denominator > 0, "FixedPoint: DIV_BY_ZERO"); - return uq112x112((uint224(numerator) << 112) / denominator); - } - - // decode a uq112x112 into a uint with 18 decimals of precision - function decode112with18(uq112x112 memory self) internal pure returns (uint256) { - // we only have 256 - 224 = 32 bits to spare, so scaling up by ~60 bits is dangerous - // instead, get close to: - // (x * 1e18) >> 112 - // without risk of overflowing, e.g.: - // (x) / 2 ** (112 - lg(1e18)) - return uint256(self._x) / 5192296858534827; - } -} - -// library with helper methods for oracles that are concerned with computing average prices -library PancakeOracleLibrary { - using FixedPoint for *; - - // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] - function currentBlockTimestamp() internal view returns (uint32) { - return uint32(block.timestamp % 2 ** 32); - } - - // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. - function currentCumulativePrices( - address pair - ) internal view returns (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) { - blockTimestamp = currentBlockTimestamp(); - price0Cumulative = IPancakePair(pair).price0CumulativeLast(); - price1Cumulative = IPancakePair(pair).price1CumulativeLast(); - - // if time has elapsed since the last update on the pair, mock the accumulated price values - (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IPancakePair(pair).getReserves(); - if (blockTimestampLast != blockTimestamp) { - unchecked { - // subtraction overflow is desired - uint32 timeElapsed = blockTimestamp - blockTimestampLast; - // addition overflow is desired - // counterfactual - price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; - // counterfactual - price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; - } - } - } -} diff --git a/contracts/oracles/TwapOracle.sol b/contracts/oracles/TwapOracle.sol deleted file mode 100755 index 85628d07..00000000 --- a/contracts/oracles/TwapOracle.sol +++ /dev/null @@ -1,300 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.13; - -import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; -import "../libraries/PancakeLibrary.sol"; -import "../interfaces/OracleInterface.sol"; -import "../interfaces/VBep20Interface.sol"; -import "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol"; - -/** - * @title TwapOracle - * @author Venus - * @notice This oracle fetches price of assets from PancakeSwap. - */ -contract TwapOracle is AccessControlledV8, TwapInterface { - using FixedPoint for *; - - struct Observation { - uint256 timestamp; - uint256 acc; - } - - struct TokenConfig { - /// @notice Asset address, which can't be zero address and can be used for existance check - address asset; - /// @notice Decimals of asset represented as 1e{decimals} - uint256 baseUnit; - /// @notice The address of Pancake pair - address pancakePool; - /// @notice Whether the token is paired with WBNB - bool isBnbBased; - /// @notice A flag identifies whether the Pancake pair is reversed - /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not. - bool isReversedPool; - /// @notice The minimum window in seconds required between TWAP updates - uint256 anchorPeriod; - } - - /// @notice Set this as asset address for BNB. This is the underlying for vBNB - address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB; - - /// @notice WBNB address - /// @custom:oz-upgrades-unsafe-allow state-variable-immutable - address public immutable WBNB; - - /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets - uint256 public constant BNB_BASE_UNIT = 1e18; - uint256 public constant BUSD_BASE_UNIT = 1e18; - - /// @notice Configs by token - mapping(address => TokenConfig) public tokenConfigs; - - /// @notice Stored price by token - mapping(address => uint256) public prices; - - /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation. - mapping(address => Observation[]) public observations; - - /// @notice Observation array index which probably falls in current anchor period mapped by asset address - mapping(address => uint256) public windowStart; - - /// @notice Emit this event when TWAP window is updated - event TwapWindowUpdated( - address indexed asset, - uint256 oldTimestamp, - uint256 oldAcc, - uint256 newTimestamp, - uint256 newAcc - ); - - /// @notice Emit this event when TWAP price is updated - event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp); - - /// @notice Emit this event when new token configs are added - event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod); - - modifier notNullAddress(address someone) { - if (someone == address(0)) revert("can't be zero address"); - _; - } - - /// @notice Constructor for the implementation contract. Sets immutable variables. - /// @param wBnbAddress The address of the WBNB - /// @custom:oz-upgrades-unsafe-allow constructor - constructor(address wBnbAddress) notNullAddress(wBnbAddress) { - WBNB = wBnbAddress; - _disableInitializers(); - } - - /** - * @notice Initializes the owner of the contract - * @param accessControlManager_ Address of the access control manager contract - */ - function initialize(address accessControlManager_) external initializer { - __AccessControlled_init(accessControlManager_); - } - - /** - * @notice Adds multiple token configs at the same time - * @param configs Config array - * @custom:error Zero length error thrown, if length of the config array is 0 - */ - function setTokenConfigs(TokenConfig[] memory configs) external { - if (configs.length == 0) revert("length can't be 0"); - uint256 numTokenConfigs = configs.length; - for (uint256 i; i < numTokenConfigs; ) { - setTokenConfig(configs[i]); - unchecked { - ++i; - } - } - } - - /** - * @notice Get the TWAP price for the given asset - * @param asset asset address - * @return price asset price in USD - * @custom:error Missing error is thrown if the token config does not exist - * @custom:error Range error is thrown if TWAP price is not greater than zero - */ - function getPrice(address asset) external view override returns (uint256) { - uint256 decimals; - - if (asset == BNB_ADDR) { - decimals = 18; - asset = WBNB; - } else { - IERC20Metadata token = IERC20Metadata(asset); - decimals = token.decimals(); - } - - if (tokenConfigs[asset].asset == address(0)) revert("asset not exist"); - uint256 price = prices[asset]; - - // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert - if (price == 0) revert("TWAP price must be positive"); - return (price * (10 ** (18 - decimals))); - } - - /** - * @notice Adds a single token config - * @param config token config struct - * @custom:access Only Governance - * @custom:error Range error is thrown if anchor period is not greater than zero - * @custom:error Range error is thrown if base unit is not greater than zero - * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals - * @custom:error NotNullAddress error is thrown if address of asset is null - * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null - * @custom:event Emits TokenConfigAdded event if new token config are added with - * asset address, PancakePool address, anchor period address - */ - function setTokenConfig( - TokenConfig memory config - ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) { - _checkAccessAllowed("setTokenConfig(TokenConfig)"); - - if (config.anchorPeriod == 0) revert("anchor period must be positive"); - if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals()) - revert("base unit decimals must be same as asset decimals"); - - uint256 cumulativePrice = currentCumulativePrice(config); - - // Initialize observation data - observations[config.asset].push(Observation(block.timestamp, cumulativePrice)); - tokenConfigs[config.asset] = config; - emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod); - } - - /** - * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision. - * @return anchorPrice anchor price of the asset - * @custom:error Missing error is thrown if token config does not exist - */ - function updateTwap(address asset) public returns (uint256) { - if (asset == BNB_ADDR) { - asset = WBNB; - } - - if (tokenConfigs[asset].asset == address(0)) revert("asset not exist"); - // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token - if (asset != WBNB && tokenConfigs[asset].isBnbBased) { - if (tokenConfigs[WBNB].asset == address(0)) revert("WBNB not exist"); - _updateTwapInternal(tokenConfigs[WBNB]); - } - return _updateTwapInternal(tokenConfigs[asset]); - } - - /** - * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap. - * @return cumulative price of target token regardless of pair order - */ - function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) { - (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool); - if (config.isReversedPool) { - return price1; - } else { - return price0; - } - } - - /** - * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision. - * @return price Asset price in USD, with 18 decimals - * @custom:error Timing error is thrown if current time is not greater than old observation timestamp - * @custom:error Zero price error is thrown if token is BNB based and price is zero - * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero - * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address, - * AnchorPrice, old observation timestamp and current timestamp - */ - function _updateTwapInternal(TokenConfig memory config) private returns (uint256) { - // pokeWindowValues already handled reversed pool cases, - // priceAverage will always be Token/BNB or Token/BUSD *twap** price. - (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config); - - if (block.timestamp == oldTimestamp) return prices[config.asset]; - - // This should be impossible, but better safe than sorry - if (block.timestamp < oldTimestamp) revert("now must come after before"); - - uint256 timeElapsed; - unchecked { - timeElapsed = block.timestamp - oldTimestamp; - } - - // Calculate Pancake *twap** - FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112( - uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed) - ); - // *twap** price with 1e18 decimal mantissa - uint256 priceAverageMantissa = priceAverage.decode112with18(); - - // To cancel the decimals in cumulative price, we need to mulitply the average price with - // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18) - uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT; - uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit; - - // if this token is paired with BNB, convert its price to USD - if (config.isBnbBased) { - uint256 bnbPrice = prices[WBNB]; - if (bnbPrice == 0) revert("bnb price is invalid"); - anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT; - } - - if (anchorPriceMantissa == 0) revert("twap price cannot be 0"); - - emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp); - - // save anchor price, which is 1e18 decimals - prices[config.asset] = anchorPriceMantissa; - - return anchorPriceMantissa; - } - - /** - * @notice Appends current observation and pick an observation with a timestamp equal - * or just greater than the window start timestamp. If one is not available, - * then pick the last availableobservation. The window start index is updated in both the cases. - * Only the current observation is saved, prior observations are deleted during this operation. - * @return Tuple of cumulative price, old observation and timestamp - * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address, - * new observation timestamp, current timestamp, new observation price and cumulative price - */ - function pokeWindowValues( - TokenConfig memory config - ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) { - uint256 cumulativePrice = currentCumulativePrice(config); - uint256 currentTimestamp = block.timestamp; - uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod; - Observation[] memory storedObservations = observations[config.asset]; - - uint256 storedObservationsLength = storedObservations.length; - for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) { - if ( - (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) || - (windowStartIndex == storedObservationsLength - 1) - ) { - startCumulativePrice = storedObservations[windowStartIndex].acc; - startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp; - windowStart[config.asset] = windowStartIndex; - break; - } else { - delete observations[config.asset][windowStartIndex]; - } - - unchecked { - ++windowStartIndex; - } - } - - observations[config.asset].push(Observation(currentTimestamp, cumulativePrice)); - emit TwapWindowUpdated( - config.asset, - startCumulativeTimestamp, - startCumulativePrice, - block.timestamp, - cumulativePrice - ); - return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp); - } -} diff --git a/contracts/oracles/WstETHOracle.sol b/contracts/oracles/WstETHOracle.sol index 7278515b..3d1b9be5 100755 --- a/contracts/oracles/WstETHOracle.sol +++ b/contracts/oracles/WstETHOracle.sol @@ -9,9 +9,14 @@ import { EXP_SCALE } from "@venusprotocol/solidity-utilities/contracts/constants /** * @title WstETHOracle * @author Venus - * @notice This oracle fetches the price of wstETH asset + * @notice Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH + * or the price of stETH/USD (secondary market price) is obtained from the oracle. */ contract WstETHOracle is OracleInterface { + /// @notice A flag assuming 1:1 price equivalence between stETH/ETH + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable + bool public immutable ASSUME_STETH_ETH_EQUIVALENCE; + /// @notice Address of stETH /// @custom:oz-upgrades-unsafe-allow state-variable-immutable IStETH public immutable STETH; @@ -30,7 +35,13 @@ contract WstETHOracle is OracleInterface { /// @notice Constructor for the implementation contract. /// @custom:oz-upgrades-unsafe-allow constructor - constructor(address wstETHAddress, address wETHAddress, address stETHAddress, address resilientOracleAddress) { + constructor( + address wstETHAddress, + address wETHAddress, + address stETHAddress, + address resilientOracleAddress, + bool assumeEquivalence + ) { ensureNonzeroAddress(wstETHAddress); ensureNonzeroAddress(wETHAddress); ensureNonzeroAddress(stETHAddress); @@ -39,10 +50,13 @@ contract WstETHOracle is OracleInterface { WETH_ADDRESS = wETHAddress; STETH = IStETH(stETHAddress); RESILIENT_ORACLE = OracleInterface(resilientOracleAddress); + ASSUME_STETH_ETH_EQUIVALENCE = assumeEquivalence; } /** - * @notice Gets the price of wstETH asset + * @notice Gets the USD price of wstETH asset + * @dev Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH + * or the price of stETH/USD (secondary market price) is obtained from the oracle * @param asset Address of wstETH * @return wstETH Price in USD scaled by 1e18 */ @@ -53,9 +67,9 @@ contract WstETHOracle is OracleInterface { uint256 stETHAmount = STETH.getPooledEthByShares(1 ether); // price is scaled 1e18 (oracle returns 36 - asset decimal scale) - uint256 wethUSDPrice = RESILIENT_ORACLE.getPrice(WETH_ADDRESS); + uint256 stETHUSDPrice = RESILIENT_ORACLE.getPrice(ASSUME_STETH_ETH_EQUIVALENCE ? WETH_ADDRESS : address(STETH)); - // stETHAmount (for 1 wstETH) * wethUSDPrice (assuming 1stETH = 1 WETH) / 1e18 - return (stETHAmount * wethUSDPrice) / EXP_SCALE; + // stETHAmount (for 1 wstETH) * stETHUSDPrice / 1e18 + return (stETHAmount * stETHUSDPrice) / EXP_SCALE; } } diff --git a/contracts/oracles/mocks/MockTwapOracle.sol b/contracts/oracles/mocks/MockTwapOracle.sol deleted file mode 100644 index 0d22641b..00000000 --- a/contracts/oracles/mocks/MockTwapOracle.sol +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.13; - -import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import { OracleInterface } from "../../interfaces/OracleInterface.sol"; - -contract MockTwapOracle is OwnableUpgradeable { - mapping(address => uint256) public assetPrices; - - /// @notice vBNB address - address public vBNB; - - //set price in 6 decimal precision - constructor() {} - - function initialize(address vBNB_) public initializer { - __Ownable_init(); - if (vBNB_ == address(0)) revert("vBNB can't be zero address"); - vBNB = vBNB_; - } - - function setPrice(address asset, uint256 price) external { - assetPrices[asset] = price; - } - - //https://compound.finance/docs/prices - function getPrice(address token) public view returns (uint256) { - return assetPrices[token]; - } -} diff --git a/deploy/1-deploy-oracles.ts b/deploy/1-deploy-oracles.ts index 6259c598..d24c9a58 100644 --- a/deploy/1-deploy-oracles.ts +++ b/deploy/1-deploy-oracles.ts @@ -14,7 +14,6 @@ const func: DeployFunction = async function ({ getNamedAccounts, deployments, ne const { vBNBAddress } = ADDRESSES[networkName]; const { VAIAddress } = ADDRESSES[networkName]; - const { WBNBAddress } = ADDRESSES[networkName]; let accessControlManager; if (!network.live) { @@ -78,33 +77,6 @@ const func: DeployFunction = async function ({ getNamedAccounts, deployments, ne }, }); - // Skip deployment if chain is not BNB chain - if (networkName === "bsctetnet" || networkName === "bscmainnet") { - await deploy("TwapOracle", { - contract: network.live ? "TwapOracle" : "MockTwapOracle", - from: deployer, - log: true, - deterministicDeployment: false, - args: network.live ? [WBNBAddress] : [], - proxy: { - owner: proxyOwnerAddress, - proxyContract: "OptimizedTransparentProxy", - execute: { - methodName: "initialize", - args: network.live ? [accessControlManagerAddress] : [vBNBAddress], - }, - }, - }); - - const twapOracle = await hre.ethers.getContract("TwapOracle"); - const twapOracleOwner = await twapOracle.owner(); - - if (twapOracleOwner === deployer) { - await twapOracle.transferOwnership(ADDRESSES[networkName].timelock); - console.log(`Ownership of TwapOracle transfered from deployer to Timelock (${ADDRESSES[networkName].timelock})`); - } - } - const { pythOracleAddress } = ADDRESSES[networkName]; // Skip if no pythOracle address in config diff --git a/deploy/3-vip-based-configuration.ts b/deploy/3-vip-based-configuration.ts index 770bdbfd..509b6e35 100644 --- a/deploy/3-vip-based-configuration.ts +++ b/deploy/3-vip-based-configuration.ts @@ -25,7 +25,7 @@ const configurePriceFeeds = async (hre: HardhatRuntimeEnvironment): Promise 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\\\";\\n\\nimport \\\"./IAccessControlManagerV8.sol\\\";\\n\\n/**\\n * @title Venus Access Control Contract.\\n * @dev The AccessControlledV8 contract is a wrapper around the OpenZeppelin AccessControl contract\\n * It provides a standardized way to control access to methods within the Venus Smart Contract Ecosystem.\\n * The contract allows the owner to set an AccessControlManager contract address.\\n * It can restrict method calls based on the sender's role and the method's signature.\\n */\\n\\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\\n /// @notice Access control manager contract\\n IAccessControlManagerV8 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /// @notice Thrown when the action is prohibited by AccessControlManager\\n error Unauthorized(address sender, address calledContract, string methodSignature);\\n\\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\\n __Ownable2Step_init();\\n __AccessControlled_init_unchained(accessControlManager_);\\n }\\n\\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Sets the address of AccessControlManager\\n * @dev Admin function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n * @custom:event Emits NewAccessControlManager event\\n * @custom:access Only Governance\\n */\\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV8) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert Unauthorized(msg.sender, address(this), signature);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x618d942756b93e02340a42f3c80aa99fc56be1a96861f5464dc23a76bf30b3a5\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/access/IAccessControl.sol\\\";\\n\\ninterface IAccessControlManagerV8 is IAccessControl {\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x41deef84d1839590b243b66506691fde2fb938da01eabde53e82d3b8316fdaf9\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface OracleInterface {\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address vToken) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address vToken,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x8ac0bda5d5789c320bf219dc6691eef0e6617e9653bc0e24f407a44e4281edda\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/VBep20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\ninterface VBep20Interface is IERC20Metadata {\\n /**\\n * @notice Underlying asset for this VToken\\n */\\n function underlying() external view returns (address);\\n}\\n\",\"keccak256\":\"0x3f845cd51b2d82f7932ac6c0ab714df97f733b01ce50f6fb0adb4c28447d4618\",\"license\":\"BSD-3-Clause\"},\"contracts/libraries/PancakeLibrary.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface IPancakePair {\\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\\n\\n function price0CumulativeLast() external view returns (uint256);\\n\\n function price1CumulativeLast() external view returns (uint256);\\n}\\n\\nlibrary FixedPoint {\\n // range: [0, 2**112 - 1]\\n // resolution: 1 / 2**112\\n struct uq112x112 {\\n uint224 _x;\\n }\\n\\n // returns a uq112x112 which represents the ratio of the numerator to the denominator\\n // equivalent to encode(numerator).div(denominator)\\n function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {\\n require(denominator > 0, \\\"FixedPoint: DIV_BY_ZERO\\\");\\n return uq112x112((uint224(numerator) << 112) / denominator);\\n }\\n\\n // decode a uq112x112 into a uint with 18 decimals of precision\\n function decode112with18(uq112x112 memory self) internal pure returns (uint256) {\\n // we only have 256 - 224 = 32 bits to spare, so scaling up by ~60 bits is dangerous\\n // instead, get close to:\\n // (x * 1e18) >> 112\\n // without risk of overflowing, e.g.:\\n // (x) / 2 ** (112 - lg(1e18))\\n return uint256(self._x) / 5192296858534827;\\n }\\n}\\n\\n// library with helper methods for oracles that are concerned with computing average prices\\nlibrary PancakeOracleLibrary {\\n using FixedPoint for *;\\n\\n // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]\\n function currentBlockTimestamp() internal view returns (uint32) {\\n return uint32(block.timestamp % 2 ** 32);\\n }\\n\\n // produces the cumulative price using counterfactuals to save gas and avoid a call to sync.\\n function currentCumulativePrices(\\n address pair\\n ) internal view returns (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) {\\n blockTimestamp = currentBlockTimestamp();\\n price0Cumulative = IPancakePair(pair).price0CumulativeLast();\\n price1Cumulative = IPancakePair(pair).price1CumulativeLast();\\n\\n // if time has elapsed since the last update on the pair, mock the accumulated price values\\n (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IPancakePair(pair).getReserves();\\n if (blockTimestampLast != blockTimestamp) {\\n unchecked {\\n // subtraction overflow is desired\\n uint32 timeElapsed = blockTimestamp - blockTimestampLast;\\n // addition overflow is desired\\n // counterfactual\\n price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;\\n // counterfactual\\n price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2c8179ebad223998514d6f25ebd90f80ecb294b562d9fbc4a42bf6710486c25b\",\"license\":\"BSD-3-Clause\"},\"contracts/oracles/TwapOracle.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"../libraries/PancakeLibrary.sol\\\";\\nimport \\\"../interfaces/OracleInterface.sol\\\";\\nimport \\\"../interfaces/VBep20Interface.sol\\\";\\nimport \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\\\";\\n\\ncontract TwapOracle is AccessControlledV8, TwapInterface {\\n using FixedPoint for *;\\n\\n struct Observation {\\n uint256 timestamp;\\n uint256 acc;\\n }\\n\\n struct TokenConfig {\\n /// @notice Asset address, which can't be zero address and can be used for existance check\\n address asset;\\n /// @notice Decimals of underlying asset respresented as 1e{decimals}\\n uint256 baseUnit;\\n /// @notice The address of Pancake pair\\n address pancakePool;\\n /// @notice Whether the token is paired with WBNB\\n bool isBnbBased;\\n /// @notice A flag identifies whether the Pancake pair is reversed\\n /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not.\\n bool isReversedPool;\\n /// @notice The minimum window in seconds required between TWAP updates\\n uint256 anchorPeriod;\\n }\\n\\n /// @notice WBNB address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable WBNB;\\n\\n /// @notice vBNB address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable vBnb;\\n\\n /// @notice VAI address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable vai;\\n\\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\\n uint256 public constant BNB_BASE_UNIT = 1e18;\\n uint256 public constant BUSD_BASE_UNIT = 1e18;\\n\\n /// @notice Configs by token\\n mapping(address => TokenConfig) public tokenConfigs;\\n\\n /// @notice Stored price by token\\n mapping(address => uint256) public prices;\\n\\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\\n mapping(address => Observation[]) public observations;\\n\\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\\n mapping(address => uint256) public windowStart;\\n\\n /// @notice Emit this event when TWAP window is updated\\n event TwapWindowUpdated(\\n address indexed asset,\\n uint256 oldTimestamp,\\n uint256 oldAcc,\\n uint256 newTimestamp,\\n uint256 newAcc\\n );\\n\\n /// @notice Emit this event when TWAP price is updated\\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\\n\\n /// @notice Emit this event when new token configs are added\\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\\n\\n modifier notNullAddress(address someone) {\\n if (someone == address(0)) revert(\\\"can't be zero address\\\");\\n _;\\n }\\n\\n /// @notice Constructor for the implementation contract. Sets immutable variables.\\n /// @param vBnbAddress The address of the VBNB\\n /// @param wBnbAddress The address of the WBNB\\n /// @param vaiAddress The address of the WBNB\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n address vBnbAddress,\\n address wBnbAddress,\\n address vaiAddress\\n ) notNullAddress(vBnbAddress) notNullAddress(wBnbAddress) notNullAddress(vaiAddress) {\\n vBnb = vBnbAddress;\\n WBNB = wBnbAddress;\\n vai = vaiAddress;\\n _disableInitializers();\\n }\\n\\n /**\\n * @notice Adds multiple token configs at the same time\\n * @param configs Config array\\n * @custom:error Zero length error thrown, if length of the config array is 0\\n */\\n function setTokenConfigs(TokenConfig[] memory configs) external {\\n if (configs.length == 0) revert(\\\"length can't be 0\\\");\\n uint256 numTokenConfigs = configs.length;\\n for (uint256 i; i < numTokenConfigs; ) {\\n setTokenConfig(configs[i]);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Initializes the owner of the contract\\n * @param accessControlManager_ Address of the access control manager contract\\n */\\n function initialize(address accessControlManager_) external initializer {\\n __AccessControlled_init(accessControlManager_);\\n }\\n\\n /**\\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\\n * @return anchorPrice anchor price of the underlying asset of the vToken\\n * @custom:error Missing error is thrown if token config does not exist\\n */\\n function updateTwap(address vToken) external returns (uint256) {\\n address asset = _getUnderlyingAsset(vToken);\\n\\n if (tokenConfigs[asset].asset == address(0)) revert(\\\"asset not exist\\\");\\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\\n if (tokenConfigs[WBNB].asset == address(0)) revert(\\\"WBNB not exist\\\");\\n _updateTwapInternal(tokenConfigs[WBNB]);\\n }\\n return _updateTwapInternal(tokenConfigs[asset]);\\n }\\n\\n /**\\n * @notice Get the underlying TWAP price for the given vToken\\n * @param vToken vToken address\\n * @return price Underlying price in USD\\n * @custom:error Missing error is thrown if the token config does not exist\\n * @custom:error Range error is thrown if TWAP price is not greater than zero\\n */\\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\\n address asset = _getUnderlyingAsset(vToken);\\n\\n if (tokenConfigs[asset].asset == address(0)) revert(\\\"asset not exist\\\");\\n uint256 price = prices[asset];\\n\\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\\n if (price == 0) revert(\\\"TWAP price must be positive\\\");\\n return (price * (10 ** (18 - IERC20Metadata(asset).decimals())));\\n }\\n\\n /**\\n * @notice Adds a single token config\\n * @param config token config struct\\n * @custom:access Only Governance\\n * @custom:error Range error is thrown if anchor period is not greater than zero\\n * @custom:error Range error is thrown if base unit is not greater than zero\\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\\n * @custom:error NotNullAddress error is thrown if address of asset is null\\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\\n * @custom:event Emits TokenConfigAdded event if new token config are added with\\n * asset address, PancakePool address, anchor period address\\n */\\n function setTokenConfig(\\n TokenConfig memory config\\n ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) {\\n _checkAccessAllowed(\\\"setTokenConfig(TokenConfig)\\\");\\n\\n if (config.anchorPeriod == 0) revert(\\\"anchor period must be positive\\\");\\n if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals())\\n revert(\\\"base unit decimals must be same as asset decimals\\\");\\n\\n uint256 cumulativePrice = currentCumulativePrice(config);\\n\\n // Initialize observation data\\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\\n tokenConfigs[config.asset] = config;\\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\\n }\\n\\n /**\\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\\n * @return cumulative price of target token regardless of pair order\\n */\\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\\n if (config.isReversedPool) {\\n return price1;\\n } else {\\n return price0;\\n }\\n }\\n\\n /**\\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\\n * @return price Underlying price in USD, with 18 decimals\\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\\n * AnchorPrice, old observation timestamp and current timestamp\\n */\\n function _updateTwapInternal(TokenConfig memory config) private returns (uint256) {\\n // pokeWindowValues already handled reversed pool cases,\\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\\n\\n if (block.timestamp == oldTimestamp) return prices[config.asset];\\n\\n // This should be impossible, but better safe than sorry\\n if (block.timestamp < oldTimestamp) revert(\\\"now must come after before\\\");\\n\\n uint256 timeElapsed;\\n unchecked {\\n timeElapsed = block.timestamp - oldTimestamp;\\n }\\n\\n // Calculate Pancake *twap**\\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\\n );\\n // *twap** price with 1e18 decimal mantissa\\n uint256 priceAverageMantissa = priceAverage.decode112with18();\\n\\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\\n // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18)\\n uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT;\\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\\n\\n // if this token is paired with BNB, convert its price to USD\\n if (config.isBnbBased) {\\n uint256 bnbPrice = prices[WBNB];\\n if (bnbPrice == 0) revert(\\\"bnb price is invalid\\\");\\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT;\\n }\\n\\n if (anchorPriceMantissa == 0) revert(\\\"twap price cannot be 0\\\");\\n\\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\\n\\n // save anchor price, which is 1e18 decimals\\n prices[config.asset] = anchorPriceMantissa;\\n\\n return anchorPriceMantissa;\\n }\\n\\n /**\\n * @notice Appends current observation and pick an observation with a timestamp equal\\n * or just greater than the window start timestamp. If one is not available,\\n * then pick the last availableobservation. The window start index is updated in both the cases.\\n * Only the current observation is saved, prior observations are deleted during this operation.\\n * @return Tuple of cumulative price, old observation and timestamp\\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\\n * new observation timestamp, current timestamp, new observation price and cumulative price\\n */\\n function pokeWindowValues(\\n TokenConfig memory config\\n ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\\n uint256 cumulativePrice = currentCumulativePrice(config);\\n uint256 currentTimestamp = block.timestamp;\\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\\n Observation[] memory storedObservations = observations[config.asset];\\n\\n uint256 storedObservationsLength = storedObservations.length;\\n for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) {\\n if (\\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\\n (windowStartIndex == storedObservationsLength - 1)\\n ) {\\n startCumulativePrice = storedObservations[windowStartIndex].acc;\\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\\n windowStart[config.asset] = windowStartIndex;\\n break;\\n } else {\\n delete observations[config.asset][windowStartIndex];\\n }\\n\\n unchecked {\\n ++windowStartIndex;\\n }\\n }\\n\\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\\n emit TwapWindowUpdated(\\n config.asset,\\n startCumulativeTimestamp,\\n startCumulativePrice,\\n block.timestamp,\\n cumulativePrice\\n );\\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\\n }\\n\\n /**\\n * @dev This function returns the underlying asset of a vToken\\n * @param vToken vToken address\\n * @return asset underlying asset address\\n */\\n function _getUnderlyingAsset(address vToken) private view returns (address asset) {\\n if (vToken == vBnb) {\\n asset = WBNB;\\n } else if (vToken == vai) {\\n asset = vai;\\n } else {\\n asset = VBep20Interface(vToken).underlying();\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc6fc865649b9b47c0a76916d13469c88fc33220f7413173273f304def04bb9a3\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", - "bytecode": "0x60e06040523480156200001157600080fd5b506040516200223c3803806200223c83398101604081905262000034916200021b565b826001600160a01b038116620000805760405162461bcd60e51b815260206004820152601560248201526000805160206200221c83398151915260448201526064015b60405180910390fd5b826001600160a01b038116620000c85760405162461bcd60e51b815260206004820152601560248201526000805160206200221c833981519152604482015260640162000077565b826001600160a01b038116620001105760405162461bcd60e51b815260206004820152601560248201526000805160206200221c833981519152604482015260640162000077565b6001600160a01b0380871660a052858116608052841660c052620001336200013f565b50505050505062000265565b600054610100900460ff1615620001a95760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840162000077565b60005460ff9081161015620001fc576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b03811681146200021657600080fd5b919050565b6000806000606084860312156200023157600080fd5b6200023c84620001fe565b92506200024c60208501620001fe565b91506200025c60408501620001fe565b90509250925092565b60805160a05160c051611f4f620002cd6000396000818161033601528181611112015261114c01526000818161028b01526110b20152600081816102fe01528181610558015281816105c901528181610641015281816110ec01526113050152611f4f6000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c80638da5cb5b116100b8578063cbf679191161007c578063cbf679191461036b578063cfed246b1461037e578063e24343ff14610257578063e30c39781461039e578063f2fde38b146103af578063fc57d4df146103c257600080fd5b80638da5cb5b146102e85780638dd95002146102f9578063b4a0bdf314610320578063b62e4c9214610331578063c4d66de81461035857600080fd5b80633125d3c81161010a5780633125d3c8146102575780633334ecc5146102665780635ba3792d14610286578063715018a6146102c5578063725068a5146102cd57806379ba5097146102e057600080fd5b806302459966146101475780630e32cb86146101745780631b69dc5f14610189578063234a3446146102235780632b9d9dea14610236575b600080fd5b61015a610155366004611969565b6103d5565b604080519283526020830191909152015b60405180910390f35b610187610182366004611995565b610411565b005b6101e1610197366004611995565b60c96020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919282169160ff600160a01b8204811692600160a81b909204169086565b604080516001600160a01b03978816815260208101969096529390951692840192909252151560608301521515608082015260a081019190915260c00161016b565b610187610231366004611aa3565b610425565b610249610244366004611b53565b6104ab565b60405190815260200161016b565b610249670de0b6b3a764000081565b610249610274366004611995565b60cc6020526000908152604090205481565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161016b565b6101876104da565b6102496102db366004611995565b6104ee565b610187610758565b6033546001600160a01b03166102ad565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b6097546001600160a01b03166102ad565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b610187610366366004611995565b6107cf565b610187610379366004611b53565b6108e3565b61024961038c366004611995565b60ca6020526000908152604090205481565b6065546001600160a01b03166102ad565b6101876103bd366004611995565b610c09565b6102496103d0366004611995565b610c7a565b60cb60205281600052604060002081815481106103f157600080fd5b600091825260209091206002909102018054600190910154909250905082565b610419610dd5565b61042281610e2f565b50565b805160000361046f5760405162461bcd60e51b815260206004820152601160248201527006c656e6774682063616e2774206265203607c1b60448201526064015b60405180910390fd5b805160005b818110156104a65761049e83828151811061049157610491611b6f565b60200260200101516108e3565b600101610474565b505050565b60008060006104bd8460400151610eed565b50915091508360800151156104d3579392505050565b5092915050565b6104e2610dd5565b6104ec6000611095565b565b6000806104fa836110ae565b6001600160a01b03808216600090815260c96020526040902054919250166105565760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b6044820152606401610466565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316141580156105ba57506001600160a01b038116600090815260c96020526040902060020154600160a01b900460ff165b156106d5576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260c96020526040902054166106375760405162461bcd60e51b815260206004820152600e60248201526d15d09390881b9bdd08195e1a5cdd60921b6044820152606401610466565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260c96020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a08201526106d3906111da565b505b6001600160a01b03808216600090815260c96020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a0820152610751906111da565b9392505050565b60655433906001600160a01b031681146107c65760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610466565b61042281611095565b600054610100900460ff16158080156107ef5750600054600160ff909116105b806108095750303b158015610809575060005460ff166001145b61086c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610466565b6000805460ff19166001179055801561088f576000805461ff0019166101001790555b6108988261145b565b80156108df576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b80516001600160a01b0381166109335760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b6044820152606401610466565b60408201516001600160a01b0381166109865760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b6044820152606401610466565b6109c46040518060400160405280601b81526020017f736574546f6b656e436f6e66696728546f6b656e436f6e666967290000000000815250611493565b8260a00151600003610a185760405162461bcd60e51b815260206004820152601e60248201527f616e63686f7220706572696f64206d75737420626520706f73697469766500006044820152606401610466565b82600001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7e9190611b85565b610a8990600a611ca2565b836020015114610af55760405162461bcd60e51b815260206004820152603160248201527f6261736520756e697420646563696d616c73206d7573742062652073616d6520604482015270617320617373657420646563696d616c7360781b6064820152608401610466565b6000610b00846104ab565b84516001600160a01b03908116600090815260cb6020908152604080832081518083018352428152808401878152825460018181018555938752858720925160029182029093019283559051918301919091558a518616855260c984528285208b5181549088166001600160a01b031990911681178255948c015192810192909255828b0151908201805460608d015160808e01511515600160a81b0260ff60a81b19911515600160a01b026001600160a81b03199093169490991693841791909117169690961790955560a08a0151600390910181905590519495509390917f3cc8d9cb9370a23a8b9ffa75efa24cecb65c4693980e58260841adc474983c5f91a450505050565b610c11610dd5565b606580546001600160a01b0383166001600160a01b03199091168117909155610c426033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b600080610c86836110ae565b6001600160a01b03808216600090815260c9602052604090205491925016610ce25760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b6044820152606401610466565b6001600160a01b038116600090815260ca602052604081205490819003610d4b5760405162461bcd60e51b815260206004820152601b60248201527f54574150207072696365206d75737420626520706f73697469766500000000006044820152606401610466565b816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dad9190611b85565b610db8906012611cb1565b610dc390600a611ca2565b610dcd9082611cd4565b949350505050565b6033546001600160a01b031633146104ec5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610466565b6001600160a01b038116610e935760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610466565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa091016108d6565b6000806000610efa61152d565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5e9190611cf3565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc29190611cf3565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611007573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102b9190611d23565b9250925092508363ffffffff168163ffffffff161461108b5780840363ffffffff81166110588486611543565b516001600160e01b031602969096019563ffffffff81166110798585611543565b516001600160e01b0316029590950194505b5050509193909250565b606580546001600160a01b0319169055610422816115f5565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03160361111057507f0000000000000000000000000000000000000000000000000000000000000000919050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03160361117057507f0000000000000000000000000000000000000000000000000000000000000000919050565b816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d29190611d73565b90505b919050565b6000806000806111e985611647565b92509250925080420361121857505091516001600160a01b0316600090815260ca602052604090205492915050565b804210156112685760405162461bcd60e51b815260206004820152601a60248201527f6e6f77206d75737420636f6d65206166746572206265666f72650000000000006044820152606401610466565b60008142039050600060405180602001604052808386886112899190611d90565b6112939190611dbd565b6001600160e01b03169052905060006112ab826118ae565b9050600088606001516112c657670de0b6b3a76400006112d0565b670de0b6b3a76400005b90506000818a60200151846112e59190611cd4565b6112ef9190611dbd565b905089606001511561139c576001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600090815260ca60205260408120549081900361137b5760405162461bcd60e51b8152602060048201526014602482015273189b98881c1c9a58d9481a5cc81a5b9d985b1a5960621b6044820152606401610466565b670de0b6b3a764000061138e8284611cd4565b6113989190611dbd565b9150505b806000036113e55760405162461bcd60e51b81526020600482015260166024820152750747761702070726963652063616e6e6f7420626520360541b6044820152606401610466565b89516040805183815260208101899052428183015290516001600160a01b03909216917f7d881580fb2bb7844e8ecf8df26510247c4bbea2735d40bf0d9ac33c0d9acd819181900360600190a298516001600160a01b0316600090815260ca602052604090208990555096979650505050505050565b600054610100900460ff166114825760405162461bcd60e51b815260040161046690611dd1565b61148a6118ce565b610422816118fd565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906114c69033908690600401611e69565b602060405180830381865afa1580156114e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115079190611e8d565b9050806108df57333083604051634a3fa29360e01b815260040161046693929190611eaa565b600061153e64010000000042611edf565b905090565b6040805160208101909152600081526000826001600160701b0316116115ab5760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f0000000000000000006044820152606401610466565b6040805160208101909152806115e16001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611ef3565b6001600160e01b0316905290505b92915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080600080611656856104ab565b60a0860151909150429060009061166d9083611d90565b87516001600160a01b0316600090815260cb6020908152604080832080548251818502810185019093528083529495509293909291849084015b828210156116ed578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906116a7565b505082518b516001600160a01b0316600090815260cc6020526040902054939450929150505b81811015611801578383828151811061172e5761172e611b6f565b602002602001015160000151101580611750575061174d600183611d90565b81145b156117b85782818151811061176757611767611b6f565b602002602001015160200151975082818151811061178757611787611b6f565b602090810291909101810151518b516001600160a01b0316600090815260cc90925260409091208290559650611801565b89516001600160a01b0316600090815260cb602052604090208054829081106117e3576117e3611b6f565b60009182526020822060029091020181815560010155600101611713565b5088516001600160a01b03908116600090815260cb60209081526040808320815180830183528981528084018b81528254600180820185559387529585902091516002909602909101948555519301929092558b5182518a81529182018b90524292820192909252606081018890529116907f87208a84ec7402c933c70c261e53b733a9f1c893d73e941a152435d58177a2649060800160405180910390a2509295505050509193909250565b80516000906111d2906612725dd1d243ab906001600160e01b0316611dbd565b600054610100900460ff166118f55760405162461bcd60e51b815260040161046690611dd1565b6104ec611924565b600054610100900460ff166104195760405162461bcd60e51b815260040161046690611dd1565b600054610100900460ff1661194b5760405162461bcd60e51b815260040161046690611dd1565b6104ec33611095565b6001600160a01b038116811461042257600080fd5b6000806040838503121561197c57600080fd5b823561198781611954565b946020939093013593505050565b6000602082840312156119a757600080fd5b813561075181611954565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156119f1576119f16119b2565b604052919050565b801515811461042257600080fd5b600060c08284031215611a1957600080fd5b60405160c0810181811067ffffffffffffffff82111715611a3c57611a3c6119b2565b6040529050808235611a4d81611954565b8152602083810135908201526040830135611a6781611954565b60408201526060830135611a7a816119f9565b60608201526080830135611a8d816119f9565b608082015260a092830135920191909152919050565b60006020808385031215611ab657600080fd5b823567ffffffffffffffff80821115611ace57600080fd5b818501915085601f830112611ae257600080fd5b813581811115611af457611af46119b2565b611b02848260051b016119c8565b818152848101925060c0918202840185019188831115611b2157600080fd5b938501935b82851015611b4757611b388986611a07565b84529384019392850192611b26565b50979650505050505050565b600060c08284031215611b6557600080fd5b6107518383611a07565b634e487b7160e01b600052603260045260246000fd5b600060208284031215611b9757600080fd5b815160ff8116811461075157600080fd5b634e487b7160e01b600052601160045260246000fd5b600181815b80851115611bf9578160001904821115611bdf57611bdf611ba8565b80851615611bec57918102915b93841c9390800290611bc3565b509250929050565b600082611c10575060016115ef565b81611c1d575060006115ef565b8160018114611c335760028114611c3d57611c59565b60019150506115ef565b60ff841115611c4e57611c4e611ba8565b50506001821b6115ef565b5060208310610133831016604e8410600b8410161715611c7c575081810a6115ef565b611c868383611bbe565b8060001904821115611c9a57611c9a611ba8565b029392505050565b600061075160ff841683611c01565b600060ff821660ff841680821015611ccb57611ccb611ba8565b90039392505050565b6000816000190483118215151615611cee57611cee611ba8565b500290565b600060208284031215611d0557600080fd5b5051919050565b80516001600160701b03811681146111d557600080fd5b600080600060608486031215611d3857600080fd5b611d4184611d0c565b9250611d4f60208501611d0c565b9150604084015163ffffffff81168114611d6857600080fd5b809150509250925092565b600060208284031215611d8557600080fd5b815161075181611954565b600082821015611da257611da2611ba8565b500390565b634e487b7160e01b600052601260045260246000fd5b600082611dcc57611dcc611da7565b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000815180845260005b81811015611e4257602081850181015186830182015201611e26565b81811115611e54576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090610dcd90830184611e1c565b600060208284031215611e9f57600080fd5b8151610751816119f9565b6001600160a01b03848116825283166020820152606060408201819052600090611ed690830184611e1c565b95945050505050565b600082611eee57611eee611da7565b500690565b60006001600160e01b0383811680611f0d57611f0d611da7565b9216919091049291505056fea2646970667358221220822f4f52e46661c73eda90cf732d8be4a901c69712c3f13bb4702f1bf5d18dd964736f6c634300080d003363616e2774206265207a65726f20616464726573730000000000000000000000", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101425760003560e01c80638da5cb5b116100b8578063cbf679191161007c578063cbf679191461036b578063cfed246b1461037e578063e24343ff14610257578063e30c39781461039e578063f2fde38b146103af578063fc57d4df146103c257600080fd5b80638da5cb5b146102e85780638dd95002146102f9578063b4a0bdf314610320578063b62e4c9214610331578063c4d66de81461035857600080fd5b80633125d3c81161010a5780633125d3c8146102575780633334ecc5146102665780635ba3792d14610286578063715018a6146102c5578063725068a5146102cd57806379ba5097146102e057600080fd5b806302459966146101475780630e32cb86146101745780631b69dc5f14610189578063234a3446146102235780632b9d9dea14610236575b600080fd5b61015a610155366004611969565b6103d5565b604080519283526020830191909152015b60405180910390f35b610187610182366004611995565b610411565b005b6101e1610197366004611995565b60c96020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919282169160ff600160a01b8204811692600160a81b909204169086565b604080516001600160a01b03978816815260208101969096529390951692840192909252151560608301521515608082015260a081019190915260c00161016b565b610187610231366004611aa3565b610425565b610249610244366004611b53565b6104ab565b60405190815260200161016b565b610249670de0b6b3a764000081565b610249610274366004611995565b60cc6020526000908152604090205481565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161016b565b6101876104da565b6102496102db366004611995565b6104ee565b610187610758565b6033546001600160a01b03166102ad565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b6097546001600160a01b03166102ad565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b610187610366366004611995565b6107cf565b610187610379366004611b53565b6108e3565b61024961038c366004611995565b60ca6020526000908152604090205481565b6065546001600160a01b03166102ad565b6101876103bd366004611995565b610c09565b6102496103d0366004611995565b610c7a565b60cb60205281600052604060002081815481106103f157600080fd5b600091825260209091206002909102018054600190910154909250905082565b610419610dd5565b61042281610e2f565b50565b805160000361046f5760405162461bcd60e51b815260206004820152601160248201527006c656e6774682063616e2774206265203607c1b60448201526064015b60405180910390fd5b805160005b818110156104a65761049e83828151811061049157610491611b6f565b60200260200101516108e3565b600101610474565b505050565b60008060006104bd8460400151610eed565b50915091508360800151156104d3579392505050565b5092915050565b6104e2610dd5565b6104ec6000611095565b565b6000806104fa836110ae565b6001600160a01b03808216600090815260c96020526040902054919250166105565760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b6044820152606401610466565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316141580156105ba57506001600160a01b038116600090815260c96020526040902060020154600160a01b900460ff165b156106d5576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260c96020526040902054166106375760405162461bcd60e51b815260206004820152600e60248201526d15d09390881b9bdd08195e1a5cdd60921b6044820152606401610466565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260c96020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a08201526106d3906111da565b505b6001600160a01b03808216600090815260c96020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a0820152610751906111da565b9392505050565b60655433906001600160a01b031681146107c65760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610466565b61042281611095565b600054610100900460ff16158080156107ef5750600054600160ff909116105b806108095750303b158015610809575060005460ff166001145b61086c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610466565b6000805460ff19166001179055801561088f576000805461ff0019166101001790555b6108988261145b565b80156108df576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b80516001600160a01b0381166109335760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b6044820152606401610466565b60408201516001600160a01b0381166109865760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b6044820152606401610466565b6109c46040518060400160405280601b81526020017f736574546f6b656e436f6e66696728546f6b656e436f6e666967290000000000815250611493565b8260a00151600003610a185760405162461bcd60e51b815260206004820152601e60248201527f616e63686f7220706572696f64206d75737420626520706f73697469766500006044820152606401610466565b82600001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7e9190611b85565b610a8990600a611ca2565b836020015114610af55760405162461bcd60e51b815260206004820152603160248201527f6261736520756e697420646563696d616c73206d7573742062652073616d6520604482015270617320617373657420646563696d616c7360781b6064820152608401610466565b6000610b00846104ab565b84516001600160a01b03908116600090815260cb6020908152604080832081518083018352428152808401878152825460018181018555938752858720925160029182029093019283559051918301919091558a518616855260c984528285208b5181549088166001600160a01b031990911681178255948c015192810192909255828b0151908201805460608d015160808e01511515600160a81b0260ff60a81b19911515600160a01b026001600160a81b03199093169490991693841791909117169690961790955560a08a0151600390910181905590519495509390917f3cc8d9cb9370a23a8b9ffa75efa24cecb65c4693980e58260841adc474983c5f91a450505050565b610c11610dd5565b606580546001600160a01b0383166001600160a01b03199091168117909155610c426033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b600080610c86836110ae565b6001600160a01b03808216600090815260c9602052604090205491925016610ce25760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b6044820152606401610466565b6001600160a01b038116600090815260ca602052604081205490819003610d4b5760405162461bcd60e51b815260206004820152601b60248201527f54574150207072696365206d75737420626520706f73697469766500000000006044820152606401610466565b816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dad9190611b85565b610db8906012611cb1565b610dc390600a611ca2565b610dcd9082611cd4565b949350505050565b6033546001600160a01b031633146104ec5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610466565b6001600160a01b038116610e935760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610466565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa091016108d6565b6000806000610efa61152d565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5e9190611cf3565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc29190611cf3565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611007573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102b9190611d23565b9250925092508363ffffffff168163ffffffff161461108b5780840363ffffffff81166110588486611543565b516001600160e01b031602969096019563ffffffff81166110798585611543565b516001600160e01b0316029590950194505b5050509193909250565b606580546001600160a01b0319169055610422816115f5565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03160361111057507f0000000000000000000000000000000000000000000000000000000000000000919050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03160361117057507f0000000000000000000000000000000000000000000000000000000000000000919050565b816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d29190611d73565b90505b919050565b6000806000806111e985611647565b92509250925080420361121857505091516001600160a01b0316600090815260ca602052604090205492915050565b804210156112685760405162461bcd60e51b815260206004820152601a60248201527f6e6f77206d75737420636f6d65206166746572206265666f72650000000000006044820152606401610466565b60008142039050600060405180602001604052808386886112899190611d90565b6112939190611dbd565b6001600160e01b03169052905060006112ab826118ae565b9050600088606001516112c657670de0b6b3a76400006112d0565b670de0b6b3a76400005b90506000818a60200151846112e59190611cd4565b6112ef9190611dbd565b905089606001511561139c576001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600090815260ca60205260408120549081900361137b5760405162461bcd60e51b8152602060048201526014602482015273189b98881c1c9a58d9481a5cc81a5b9d985b1a5960621b6044820152606401610466565b670de0b6b3a764000061138e8284611cd4565b6113989190611dbd565b9150505b806000036113e55760405162461bcd60e51b81526020600482015260166024820152750747761702070726963652063616e6e6f7420626520360541b6044820152606401610466565b89516040805183815260208101899052428183015290516001600160a01b03909216917f7d881580fb2bb7844e8ecf8df26510247c4bbea2735d40bf0d9ac33c0d9acd819181900360600190a298516001600160a01b0316600090815260ca602052604090208990555096979650505050505050565b600054610100900460ff166114825760405162461bcd60e51b815260040161046690611dd1565b61148a6118ce565b610422816118fd565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906114c69033908690600401611e69565b602060405180830381865afa1580156114e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115079190611e8d565b9050806108df57333083604051634a3fa29360e01b815260040161046693929190611eaa565b600061153e64010000000042611edf565b905090565b6040805160208101909152600081526000826001600160701b0316116115ab5760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f0000000000000000006044820152606401610466565b6040805160208101909152806115e16001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611ef3565b6001600160e01b0316905290505b92915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080600080611656856104ab565b60a0860151909150429060009061166d9083611d90565b87516001600160a01b0316600090815260cb6020908152604080832080548251818502810185019093528083529495509293909291849084015b828210156116ed578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906116a7565b505082518b516001600160a01b0316600090815260cc6020526040902054939450929150505b81811015611801578383828151811061172e5761172e611b6f565b602002602001015160000151101580611750575061174d600183611d90565b81145b156117b85782818151811061176757611767611b6f565b602002602001015160200151975082818151811061178757611787611b6f565b602090810291909101810151518b516001600160a01b0316600090815260cc90925260409091208290559650611801565b89516001600160a01b0316600090815260cb602052604090208054829081106117e3576117e3611b6f565b60009182526020822060029091020181815560010155600101611713565b5088516001600160a01b03908116600090815260cb60209081526040808320815180830183528981528084018b81528254600180820185559387529585902091516002909602909101948555519301929092558b5182518a81529182018b90524292820192909252606081018890529116907f87208a84ec7402c933c70c261e53b733a9f1c893d73e941a152435d58177a2649060800160405180910390a2509295505050509193909250565b80516000906111d2906612725dd1d243ab906001600160e01b0316611dbd565b600054610100900460ff166118f55760405162461bcd60e51b815260040161046690611dd1565b6104ec611924565b600054610100900460ff166104195760405162461bcd60e51b815260040161046690611dd1565b600054610100900460ff1661194b5760405162461bcd60e51b815260040161046690611dd1565b6104ec33611095565b6001600160a01b038116811461042257600080fd5b6000806040838503121561197c57600080fd5b823561198781611954565b946020939093013593505050565b6000602082840312156119a757600080fd5b813561075181611954565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156119f1576119f16119b2565b604052919050565b801515811461042257600080fd5b600060c08284031215611a1957600080fd5b60405160c0810181811067ffffffffffffffff82111715611a3c57611a3c6119b2565b6040529050808235611a4d81611954565b8152602083810135908201526040830135611a6781611954565b60408201526060830135611a7a816119f9565b60608201526080830135611a8d816119f9565b608082015260a092830135920191909152919050565b60006020808385031215611ab657600080fd5b823567ffffffffffffffff80821115611ace57600080fd5b818501915085601f830112611ae257600080fd5b813581811115611af457611af46119b2565b611b02848260051b016119c8565b818152848101925060c0918202840185019188831115611b2157600080fd5b938501935b82851015611b4757611b388986611a07565b84529384019392850192611b26565b50979650505050505050565b600060c08284031215611b6557600080fd5b6107518383611a07565b634e487b7160e01b600052603260045260246000fd5b600060208284031215611b9757600080fd5b815160ff8116811461075157600080fd5b634e487b7160e01b600052601160045260246000fd5b600181815b80851115611bf9578160001904821115611bdf57611bdf611ba8565b80851615611bec57918102915b93841c9390800290611bc3565b509250929050565b600082611c10575060016115ef565b81611c1d575060006115ef565b8160018114611c335760028114611c3d57611c59565b60019150506115ef565b60ff841115611c4e57611c4e611ba8565b50506001821b6115ef565b5060208310610133831016604e8410600b8410161715611c7c575081810a6115ef565b611c868383611bbe565b8060001904821115611c9a57611c9a611ba8565b029392505050565b600061075160ff841683611c01565b600060ff821660ff841680821015611ccb57611ccb611ba8565b90039392505050565b6000816000190483118215151615611cee57611cee611ba8565b500290565b600060208284031215611d0557600080fd5b5051919050565b80516001600160701b03811681146111d557600080fd5b600080600060608486031215611d3857600080fd5b611d4184611d0c565b9250611d4f60208501611d0c565b9150604084015163ffffffff81168114611d6857600080fd5b809150509250925092565b600060208284031215611d8557600080fd5b815161075181611954565b600082821015611da257611da2611ba8565b500390565b634e487b7160e01b600052601260045260246000fd5b600082611dcc57611dcc611da7565b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000815180845260005b81811015611e4257602081850181015186830182015201611e26565b81811115611e54576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090610dcd90830184611e1c565b600060208284031215611e9f57600080fd5b8151610751816119f9565b6001600160a01b03848116825283166020820152606060408201819052600090611ed690830184611e1c565b95945050505050565b600082611eee57611eee611da7565b500690565b60006001600160e01b0383811680611f0d57611f0d611da7565b9216919091049291505056fea2646970667358221220822f4f52e46661c73eda90cf732d8be4a901c69712c3f13bb4702f1bf5d18dd964736f6c634300080d0033", - "devdoc": { - "kind": "dev", - "methods": { - "acceptOwnership()": { - "details": "The new owner accepts the ownership transfer." - }, - "constructor": { - "custom:oz-upgrades-unsafe-allow": "constructor", - "params": { - "vBnbAddress": "The address of the VBNB", - "vaiAddress": "The address of the WBNB", - "wBnbAddress": "The address of the WBNB" - } - }, - "currentCumulativePrice((address,uint256,address,bool,bool,uint256))": { - "returns": { - "_0": "cumulative price of target token regardless of pair order" - } - }, - "getUnderlyingPrice(address)": { - "custom:error": "Missing error is thrown if the token config does not existRange error is thrown if TWAP price is not greater than zero", - "params": { - "vToken": "vToken address" - }, - "returns": { - "_0": "price Underlying price in USD" - } - }, - "initialize(address)": { - "params": { - "accessControlManager_": "Address of the access control manager contract" - } - }, - "owner()": { - "details": "Returns the address of the current owner." - }, - "pendingOwner()": { - "details": "Returns the address of the pending owner." - }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." - }, - "setAccessControlManager(address)": { - "custom:access": "Only Governance", - "custom:event": "Emits NewAccessControlManager event", - "details": "Admin function to set address of AccessControlManager", - "params": { - "accessControlManager_": "The new address of the AccessControlManager" - } - }, - "setTokenConfig((address,uint256,address,bool,bool,uint256))": { - "custom:access": "Only Governance", - "custom:error": "Range error is thrown if anchor period is not greater than zeroRange error is thrown if base unit is not greater than zeroValue error is thrown if base unit decimals is not the same as asset decimalsNotNullAddress error is thrown if address of asset is nullNotNullAddress error is thrown if PancakeSwap pool address is null", - "custom:event": "Emits TokenConfigAdded event if new token config are added with asset address, PancakePool address, anchor period address", - "params": { - "config": "token config struct" - } - }, - "setTokenConfigs((address,uint256,address,bool,bool,uint256)[])": { - "custom:error": "Zero length error thrown, if length of the config array is 0", - "params": { - "configs": "Config array" - } - }, - "transferOwnership(address)": { - "details": "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." - }, - "updateTwap(address)": { - "custom:error": "Missing error is thrown if token config does not exist", - "returns": { - "_0": "anchorPrice anchor price of the underlying asset of the vToken" - } - } - }, - "stateVariables": { - "WBNB": { - "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" - }, - "vBnb": { - "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" - }, - "vai": { - "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" - } - }, - "version": 1 - }, - "userdoc": { - "errors": { - "Unauthorized(address,address,string)": [ - { - "notice": "Thrown when the action is prohibited by AccessControlManager" - } - ] - }, - "events": { - "AnchorPriceUpdated(address,uint256,uint256,uint256)": { - "notice": "Emit this event when TWAP price is updated" - }, - "NewAccessControlManager(address,address)": { - "notice": "Emitted when access control manager contract address is changed" - }, - "TokenConfigAdded(address,address,uint256)": { - "notice": "Emit this event when new token configs are added" - }, - "TwapWindowUpdated(address,uint256,uint256,uint256,uint256)": { - "notice": "Emit this event when TWAP window is updated" - } - }, - "kind": "user", - "methods": { - "BNB_BASE_UNIT()": { - "notice": "the base unit of WBNB and BUSD, which are the paired tokens for all assets" - }, - "WBNB()": { - "notice": "WBNB address" - }, - "accessControlManager()": { - "notice": "Returns the address of the access control manager contract" - }, - "constructor": { - "notice": "Constructor for the implementation contract. Sets immutable variables." - }, - "currentCumulativePrice((address,uint256,address,bool,bool,uint256))": { - "notice": "Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap." - }, - "getUnderlyingPrice(address)": { - "notice": "Get the underlying TWAP price for the given vToken" - }, - "initialize(address)": { - "notice": "Initializes the owner of the contract" - }, - "observations(address,uint256)": { - "notice": "Keeps a record of token observations mapped by address, updated on every updateTwap invocation." - }, - "prices(address)": { - "notice": "Stored price by token" - }, - "setAccessControlManager(address)": { - "notice": "Sets the address of AccessControlManager" - }, - "setTokenConfig((address,uint256,address,bool,bool,uint256))": { - "notice": "Adds a single token config" - }, - "setTokenConfigs((address,uint256,address,bool,bool,uint256)[])": { - "notice": "Adds multiple token configs at the same time" - }, - "tokenConfigs(address)": { - "notice": "Configs by token" - }, - "updateTwap(address)": { - "notice": "Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision." - }, - "vBnb()": { - "notice": "vBNB address" - }, - "vai()": { - "notice": "VAI address" - }, - "windowStart(address)": { - "notice": "Observation array index which probably falls in current anchor period mapped by asset address" - } - }, - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 290, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "_initialized", - "offset": 0, - "slot": "0", - "type": "t_uint8" - }, - { - "astId": 293, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "_initializing", - "offset": 1, - "slot": "0", - "type": "t_bool" - }, - { - "astId": 904, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "__gap", - "offset": 0, - "slot": "1", - "type": "t_array(t_uint256)50_storage" - }, - { - "astId": 162, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "_owner", - "offset": 0, - "slot": "51", - "type": "t_address" - }, - { - "astId": 282, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "__gap", - "offset": 0, - "slot": "52", - "type": "t_array(t_uint256)49_storage" - }, - { - "astId": 71, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "_pendingOwner", - "offset": 0, - "slot": "101", - "type": "t_address" - }, - { - "astId": 150, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "__gap", - "offset": 0, - "slot": "102", - "type": "t_array(t_uint256)49_storage" - }, - { - "astId": 3350, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "_accessControlManager", - "offset": 0, - "slot": "151", - "type": "t_contract(IAccessControlManagerV8)3534" - }, - { - "astId": 3355, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "__gap", - "offset": 0, - "slot": "152", - "type": "t_array(t_uint256)49_storage" - }, - { - "astId": 6769, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "tokenConfigs", - "offset": 0, - "slot": "201", - "type": "t_mapping(t_address,t_struct(TokenConfig)6747_storage)" - }, - { - "astId": 6774, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "prices", - "offset": 0, - "slot": "202", - "type": "t_mapping(t_address,t_uint256)" - }, - { - "astId": 6781, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "observations", - "offset": 0, - "slot": "203", - "type": "t_mapping(t_address,t_array(t_struct(Observation)6728_storage)dyn_storage)" - }, - { - "astId": 6786, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "windowStart", - "offset": 0, - "slot": "204", - "type": "t_mapping(t_address,t_uint256)" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_struct(Observation)6728_storage)dyn_storage": { - "base": "t_struct(Observation)6728_storage", - "encoding": "dynamic_array", - "label": "struct TwapOracle.Observation[]", - "numberOfBytes": "32" - }, - "t_array(t_uint256)49_storage": { - "base": "t_uint256", - "encoding": "inplace", - "label": "uint256[49]", - "numberOfBytes": "1568" - }, - "t_array(t_uint256)50_storage": { - "base": "t_uint256", - "encoding": "inplace", - "label": "uint256[50]", - "numberOfBytes": "1600" - }, - "t_bool": { - "encoding": "inplace", - "label": "bool", - "numberOfBytes": "1" - }, - "t_contract(IAccessControlManagerV8)3534": { - "encoding": "inplace", - "label": "contract IAccessControlManagerV8", - "numberOfBytes": "20" - }, - "t_mapping(t_address,t_array(t_struct(Observation)6728_storage)dyn_storage)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => struct TwapOracle.Observation[])", - "numberOfBytes": "32", - "value": "t_array(t_struct(Observation)6728_storage)dyn_storage" - }, - "t_mapping(t_address,t_struct(TokenConfig)6747_storage)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => struct TwapOracle.TokenConfig)", - "numberOfBytes": "32", - "value": "t_struct(TokenConfig)6747_storage" - }, - "t_mapping(t_address,t_uint256)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_struct(Observation)6728_storage": { - "encoding": "inplace", - "label": "struct TwapOracle.Observation", - "members": [ - { - "astId": 6725, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "timestamp", - "offset": 0, - "slot": "0", - "type": "t_uint256" - }, - { - "astId": 6727, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "acc", - "offset": 0, - "slot": "1", - "type": "t_uint256" - } - ], - "numberOfBytes": "64" - }, - "t_struct(TokenConfig)6747_storage": { - "encoding": "inplace", - "label": "struct TwapOracle.TokenConfig", - "members": [ - { - "astId": 6731, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "asset", - "offset": 0, - "slot": "0", - "type": "t_address" - }, - { - "astId": 6734, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "baseUnit", - "offset": 0, - "slot": "1", - "type": "t_uint256" - }, - { - "astId": 6737, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "pancakePool", - "offset": 0, - "slot": "2", - "type": "t_address" - }, - { - "astId": 6740, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "isBnbBased", - "offset": 20, - "slot": "2", - "type": "t_bool" - }, - { - "astId": 6743, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "isReversedPool", - "offset": 21, - "slot": "2", - "type": "t_bool" - }, - { - "astId": 6746, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "anchorPeriod", - "offset": 0, - "slot": "3", - "type": "t_uint256" - } - ], - "numberOfBytes": "128" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - }, - "t_uint8": { - "encoding": "inplace", - "label": "uint8", - "numberOfBytes": "1" - } - } - } -} diff --git a/deployments/bscmainnet/solcInputs/aae9f1601b873a5a4704ede73ede10cb.json b/deployments/bscmainnet/solcInputs/aae9f1601b873a5a4704ede73ede10cb.json index bbf1e172..7cdbb936 100644 --- a/deployments/bscmainnet/solcInputs/aae9f1601b873a5a4704ede73ede10cb.json +++ b/deployments/bscmainnet/solcInputs/aae9f1601b873a5a4704ede73ede10cb.json @@ -88,9 +88,6 @@ "contracts/oracles/PythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"../interfaces/PythInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores the\n * updated prices from external sources\n */\ncontract PythOracle is AccessControlledV8, OracleInterface {\n // To calculate 10 ** n(which is a signed type)\n using SignedMath for int256;\n\n // To cast int64/int8 types from Pyth to unsigned types\n using SafeCast for int256;\n\n struct TokenConfig {\n bytes32 pythId;\n address asset;\n uint64 maxStalePeriod;\n }\n\n /// @notice Exponent scale (decimal precision) of prices\n uint256 public constant EXP_SCALE = 1e18;\n\n /// @notice vBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vBnb;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice The actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n /// @notice Token configs by asset address\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when setting a new pyth oracle address\n event PythOracleSet(address indexed oldPythOracle, address indexed newPythOracle);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed vToken, bytes32 indexed pythId, uint64 indexed maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param vBnbAddress The address of the vBNB\n /// @param vaiAddress The address of the VAI\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address vBnbAddress, address vaiAddress) notNullAddress(vBnbAddress) notNullAddress(vaiAddress) {\n vBnb = vBnbAddress;\n vai = vaiAddress;\n _disableInitializers();\n }\n\n /**\n * @notice Batch set token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the underlying Pyth oracle contract address\n * @param underlyingPythOracle_ Pyth oracle contract address\n * @custom:access Only Governance\n * @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero\n * @custom:event Emits PythOracleSet event with address of Pyth oracle.\n */\n function setUnderlyingPythOracle(\n IPyth underlyingPythOracle_\n ) external notNullAddress(address(underlyingPythOracle_)) {\n _checkAccessAllowed(\"setUnderlyingPythOracle(address)\");\n IPyth oldUnderlyingPythOracle = underlyingPythOracle;\n underlyingPythOracle = underlyingPythOracle_;\n emit PythOracleSet(address(oldUnderlyingPythOracle), address(underlyingPythOracle_));\n }\n\n /**\n * @notice Initializes the owner of the contract and sets required contracts\n * @param underlyingPythOracle_ Address of the Pyth oracle\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(\n address underlyingPythOracle_,\n address accessControlManager_\n ) external initializer notNullAddress(underlyingPythOracle_) {\n __AccessControlled_init(accessControlManager_);\n\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n emit PythOracleSet(address(0), underlyingPythOracle_);\n }\n\n /**\n * @notice Get price of underlying asset of the input vToken, under the hood this function\n * get price from Pyth contract, the prices of which are updated externally\n * @param vToken vToken address\n * @return price Underlying price with a precision of 18 decimals\n * @custom:error Zero address error thrown if underlyingPythOracle address is null\n * @custom:error Zero address error thrown if asset address is null\n * @custom:error Range error thrown if price of Pyth oracle is not greater than zero\n */\n function getUnderlyingPrice(\n address vToken\n ) external view override notNullAddress(address(underlyingPythOracle)) returns (uint256) {\n address asset;\n uint256 decimals;\n\n // VBNB token doesn't have `underlying` method\n if (vToken == vBnb) {\n asset = BNB_ADDR;\n decimals = 18;\n } else if (vToken == vai) {\n asset = vai;\n decimals = 18;\n } else {\n asset = VBep20Interface(vToken).underlying();\n decimals = VBep20Interface(asset).decimals();\n }\n\n TokenConfig storage tokenConfig = tokenConfigs[asset];\n if (tokenConfig.asset == address(0)) revert(\"asset doesn't exist\");\n\n // if the price is expired after it's compared against `maxStalePeriod`, the following call will revert\n PythStructs.Price memory priceInfo = underlyingPythOracle.getPriceNoOlderThan(\n tokenConfig.pythId,\n tokenConfig.maxStalePeriod\n );\n\n uint256 price = int256(priceInfo.price).toUint256();\n\n if (price == 0) revert(\"invalid pyth oracle price\");\n\n // the price returned from Pyth is price ** 10^expo, which is the real dollar price of the assets\n // we need to multiply it by 1e18 to make the price 18 decimals\n if (priceInfo.expo > 0) {\n return price * EXP_SCALE * (10 ** int256(priceInfo.expo).toUint256()) * (10 ** (18 - decimals));\n } else {\n return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));\n }\n }\n\n /**\n * @notice Set single token config. `maxStalePeriod` cannot be 0 and `vToken` can be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if max stale period is zero\n * @custom:error NotNullAddress error is thrown if asset address is null\n */\n function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n if (tokenConfig.maxStalePeriod == 0) revert(\"max stale period cannot be 0\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);\n }\n}\n" }, - "contracts/oracles/TwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../libraries/PancakeLibrary.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\ncontract TwapOracle is AccessControlledV8, TwapInterface {\n using FixedPoint for *;\n\n struct Observation {\n uint256 timestamp;\n uint256 acc;\n }\n\n struct TokenConfig {\n /// @notice Asset address, which can't be zero address and can be used for existance check\n address asset;\n /// @notice Decimals of underlying asset respresented as 1e{decimals}\n uint256 baseUnit;\n /// @notice The address of Pancake pair\n address pancakePool;\n /// @notice Whether the token is paired with WBNB\n bool isBnbBased;\n /// @notice A flag identifies whether the Pancake pair is reversed\n /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not.\n bool isReversedPool;\n /// @notice The minimum window in seconds required between TWAP updates\n uint256 anchorPeriod;\n }\n\n /// @notice WBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WBNB;\n\n /// @notice vBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vBnb;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\n uint256 public constant BNB_BASE_UNIT = 1e18;\n uint256 public constant BUSD_BASE_UNIT = 1e18;\n\n /// @notice Configs by token\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Stored price by token\n mapping(address => uint256) public prices;\n\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\n mapping(address => Observation[]) public observations;\n\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\n mapping(address => uint256) public windowStart;\n\n /// @notice Emit this event when TWAP window is updated\n event TwapWindowUpdated(\n address indexed asset,\n uint256 oldTimestamp,\n uint256 oldAcc,\n uint256 newTimestamp,\n uint256 newAcc\n );\n\n /// @notice Emit this event when TWAP price is updated\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\n\n /// @notice Emit this event when new token configs are added\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param vBnbAddress The address of the VBNB\n /// @param wBnbAddress The address of the WBNB\n /// @param vaiAddress The address of the WBNB\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address vBnbAddress,\n address wBnbAddress,\n address vaiAddress\n ) notNullAddress(vBnbAddress) notNullAddress(wBnbAddress) notNullAddress(vaiAddress) {\n vBnb = vBnbAddress;\n WBNB = wBnbAddress;\n vai = vaiAddress;\n _disableInitializers();\n }\n\n /**\n * @notice Adds multiple token configs at the same time\n * @param configs Config array\n * @custom:error Zero length error thrown, if length of the config array is 0\n */\n function setTokenConfigs(TokenConfig[] memory configs) external {\n if (configs.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = configs.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(configs[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return anchorPrice anchor price of the underlying asset of the vToken\n * @custom:error Missing error is thrown if token config does not exist\n */\n function updateTwap(address vToken) external returns (uint256) {\n address asset = _getUnderlyingAsset(vToken);\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\n if (tokenConfigs[WBNB].asset == address(0)) revert(\"WBNB not exist\");\n _updateTwapInternal(tokenConfigs[WBNB]);\n }\n return _updateTwapInternal(tokenConfigs[asset]);\n }\n\n /**\n * @notice Get the underlying TWAP price for the given vToken\n * @param vToken vToken address\n * @return price Underlying price in USD\n * @custom:error Missing error is thrown if the token config does not exist\n * @custom:error Range error is thrown if TWAP price is not greater than zero\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n address asset = _getUnderlyingAsset(vToken);\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n uint256 price = prices[asset];\n\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\n if (price == 0) revert(\"TWAP price must be positive\");\n return (price * (10 ** (18 - IERC20Metadata(asset).decimals())));\n }\n\n /**\n * @notice Adds a single token config\n * @param config token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if anchor period is not greater than zero\n * @custom:error Range error is thrown if base unit is not greater than zero\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\n * @custom:error NotNullAddress error is thrown if address of asset is null\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\n * @custom:event Emits TokenConfigAdded event if new token config are added with\n * asset address, PancakePool address, anchor period address\n */\n function setTokenConfig(\n TokenConfig memory config\n ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n if (config.anchorPeriod == 0) revert(\"anchor period must be positive\");\n if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals())\n revert(\"base unit decimals must be same as asset decimals\");\n\n uint256 cumulativePrice = currentCumulativePrice(config);\n\n // Initialize observation data\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\n tokenConfigs[config.asset] = config;\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\n }\n\n /**\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\n * @return cumulative price of target token regardless of pair order\n */\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\n if (config.isReversedPool) {\n return price1;\n } else {\n return price0;\n }\n }\n\n /**\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return price Underlying price in USD, with 18 decimals\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\n * AnchorPrice, old observation timestamp and current timestamp\n */\n function _updateTwapInternal(TokenConfig memory config) private returns (uint256) {\n // pokeWindowValues already handled reversed pool cases,\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\n\n if (block.timestamp == oldTimestamp) return prices[config.asset];\n\n // This should be impossible, but better safe than sorry\n if (block.timestamp < oldTimestamp) revert(\"now must come after before\");\n\n uint256 timeElapsed;\n unchecked {\n timeElapsed = block.timestamp - oldTimestamp;\n }\n\n // Calculate Pancake *twap**\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\n );\n // *twap** price with 1e18 decimal mantissa\n uint256 priceAverageMantissa = priceAverage.decode112with18();\n\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\n // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18)\n uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT;\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\n\n // if this token is paired with BNB, convert its price to USD\n if (config.isBnbBased) {\n uint256 bnbPrice = prices[WBNB];\n if (bnbPrice == 0) revert(\"bnb price is invalid\");\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT;\n }\n\n if (anchorPriceMantissa == 0) revert(\"twap price cannot be 0\");\n\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\n\n // save anchor price, which is 1e18 decimals\n prices[config.asset] = anchorPriceMantissa;\n\n return anchorPriceMantissa;\n }\n\n /**\n * @notice Appends current observation and pick an observation with a timestamp equal\n * or just greater than the window start timestamp. If one is not available,\n * then pick the last availableobservation. The window start index is updated in both the cases.\n * Only the current observation is saved, prior observations are deleted during this operation.\n * @return Tuple of cumulative price, old observation and timestamp\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\n * new observation timestamp, current timestamp, new observation price and cumulative price\n */\n function pokeWindowValues(\n TokenConfig memory config\n ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\n uint256 cumulativePrice = currentCumulativePrice(config);\n uint256 currentTimestamp = block.timestamp;\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\n Observation[] memory storedObservations = observations[config.asset];\n\n uint256 storedObservationsLength = storedObservations.length;\n for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) {\n if (\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\n (windowStartIndex == storedObservationsLength - 1)\n ) {\n startCumulativePrice = storedObservations[windowStartIndex].acc;\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\n windowStart[config.asset] = windowStartIndex;\n break;\n } else {\n delete observations[config.asset][windowStartIndex];\n }\n\n unchecked {\n ++windowStartIndex;\n }\n }\n\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\n emit TwapWindowUpdated(\n config.asset,\n startCumulativeTimestamp,\n startCumulativePrice,\n block.timestamp,\n cumulativePrice\n );\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view returns (address asset) {\n if (vToken == vBnb) {\n asset = WBNB;\n } else if (vToken == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" - }, "contracts/ResilientOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n /**\n * @dev Oracle roles:\n * **main**: The most trustworthy price source\n * **pivot**: Price oracle used as a loose sanity checker\n * **fallback**: The backup source when main oracle price is invalidated\n */\n enum OracleRole {\n MAIN,\n PIVOT,\n FALLBACK\n }\n\n struct TokenConfig {\n /// @notice asset address\n address asset;\n /// @notice `oracles` stores the oracles based on their role in the following order:\n /// [main, pivot, fallback],\n /// It can be indexed with the corresponding enum OracleRole value\n address[3] oracles;\n /// @notice `enableFlagsForOracles` stores the enabled state\n /// for each oracle in the same order as `oracles`\n bool[3] enableFlagsForOracles;\n }\n\n uint256 public constant INVALID_PRICE = 0;\n\n /// @notice vBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vBnb;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Bound validator contract address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n BoundValidatorInterface public immutable boundValidator;\n\n mapping(address => TokenConfig) private tokenConfigs;\n\n event TokenConfigAdded(\n address indexed asset,\n address indexed mainOracle,\n address indexed pivotOracle,\n address fallbackOracle\n );\n\n /// Event emitted when an oracle is set\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n /// Event emitted when an oracle is enabled or disabled\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /**\n * @notice Checks whether token config exists by checking whether vToken is null address\n * @dev vToken can't be null, so it's suitable to be used to check the validity of the config\n * @param asset asset address\n */\n modifier checkTokenConfigExistence(address asset) {\n if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param vBnbAddress The address of the vBNB\n /// @param vaiAddress The address of the VAI\n /// @param _boundValidator Address of the bound validator contract\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address vBnbAddress,\n address vaiAddress,\n BoundValidatorInterface _boundValidator\n ) notNullAddress(vBnbAddress) notNullAddress(vaiAddress) notNullAddress(address(_boundValidator)) {\n vBnb = vBnbAddress;\n vai = vaiAddress;\n boundValidator = _boundValidator;\n\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract admin and sets the BoundValidator contract address\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n }\n\n /**\n * @notice Pauses oracle\n * @custom:access Only Governance\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n _pause();\n }\n\n /**\n * @notice Unpauses oracle\n * @custom:access Only Governance\n */\n function unpause() external {\n _checkAccessAllowed(\"unpause()\");\n _unpause();\n }\n\n /**\n * @notice Batch sets token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Throws a length error if the length of the token configs array is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Sets oracle for a given vToken and role.\n * @dev Supplied vToken **must** exist and main oracle may not be null\n * @param asset Asset address\n * @param oracle Oracle address\n * @param role Oracle role\n * @custom:access Only Governance\n * @custom:error Null address error if main-role oracle address is null\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n */\n function setOracle(\n address asset,\n address oracle,\n OracleRole role\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\n emit OracleSet(asset, oracle, uint256(role));\n }\n\n /**\n * @notice Enables/ disables oracle for the input vToken, input vToken **must** exist\n * @param asset Asset address\n * @param role Oracle role\n * @param enable Enabled boolean of the oracle\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n */\n function enableOracle(\n address asset,\n OracleRole role,\n bool enable\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n emit OracleEnabled(asset, uint256(role), enable);\n }\n\n /**\n * @notice Updates the TWAP pivot oracle price.\n * @dev This function should always be called before calling getUnderlyingPrice\n * @param vToken vToken address\n */\n function updatePrice(address vToken) external override {\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(vToken, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(vToken) {} catch {}\n }\n }\n\n /**\n * @dev Gets token config by vToken address\n * @param vToken vToken address\n * @return tokenConfig Config for the vToken\n */\n function getTokenConfig(address vToken) external view returns (TokenConfig memory) {\n address asset = _getUnderlyingAsset(vToken);\n return tokenConfigs[asset];\n }\n\n /**\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n * - Check if the oracle is paused globally\n * - Validate price from main oracle against pivot oracle\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\n * - Validate price from main oracle against fallback oracle if the second validation failed\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\n * main oracle price is returned.\n * @param vToken vToken address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n uint256 pivotPrice = INVALID_PRICE;\n\n // Get pivot oracle price, Invalid price if not available or error\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(vToken, OracleRole.PIVOT);\n if (pivotOracleEnabled && pivotOracle != address(0)) {\n try OracleInterface(pivotOracle).getUnderlyingPrice(vToken) returns (uint256 pricePivot) {\n pivotPrice = pricePivot;\n } catch {}\n }\n\n // Compare main price and pivot price, return main price and if validation was successful\n // note: In case pivot oracle is not available but main price is available and\n // validation is successful, the main oracle price is returned.\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n vToken,\n pivotPrice,\n pivotOracleEnabled && pivotOracle != address(0)\n );\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n // Compare fallback and pivot if main oracle comparision fails with pivot\n // Return fallback price when fallback price is validated successfully with pivot oracle\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(vToken, pivotPrice);\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n // Lastly compare main price and fallback price\n if (\n mainPrice != INVALID_PRICE &&\n fallbackPrice != INVALID_PRICE &&\n boundValidator.validatePriceWithAnchorPrice(vToken, mainPrice, fallbackPrice)\n ) {\n return mainPrice;\n }\n\n revert(\"invalid resilient oracle price\");\n }\n\n /**\n * @notice Sets/resets single token configs.\n * @dev main oracle **must not** be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress is thrown if asset address is null\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n * @custom:event Emits TokenConfigAdded event when vToken config is set successfully by governnace\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(\n tokenConfig.asset,\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n );\n }\n\n /**\n * @notice Gets oracle and enabled status by vToken address\n * @param vToken vToken address\n * @param role Oracle role\n * @return oracle Oracle address based on role\n * @return enabled Enabled flag of the oracle based on token config\n */\n function getOracle(address vToken, OracleRole role) public view returns (address oracle, bool enabled) {\n address asset = _getUnderlyingAsset(vToken);\n\n oracle = tokenConfigs[asset].oracles[uint256(role)];\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n }\n\n /**\n * @notice Gets underlying asset price for the provided vToken\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\n * able to fetch a correct price\n * @param vToken vToken address\n * @param pivotPrice Pivot oracle price\n * @param pivotEnabled If pivot oracle is not empty and enabled\n * @return price USD price in scaled decimals\n * e.g. vToken decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n * @return pivotValidated Boolean representing if the validation of main oracle price\n * and pivot oracle price were successful\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of underlying asset\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n * address is null\n */\n function _getMainOraclePrice(\n address vToken,\n uint256 pivotPrice,\n bool pivotEnabled\n ) private view returns (uint256, bool) {\n (address mainOracle, bool mainOracleEnabled) = getOracle(vToken, OracleRole.MAIN);\n if (mainOracleEnabled && mainOracle != address(0)) {\n try OracleInterface(mainOracle).getUnderlyingPrice(vToken) returns (uint256 mainOraclePrice) {\n if (!pivotEnabled) {\n return (mainOraclePrice, true);\n }\n if (pivotPrice == INVALID_PRICE) {\n return (mainOraclePrice, false);\n }\n return (\n mainOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(vToken, mainOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function won't revert when the price is 0 because getUnderlyingPrice checks if price is > 0\n * @param vToken vToken address\n * @return price USD price in 18 decimals\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\n * and pivot oracle price were successfull\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of underlying asset\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n * address is null\n */\n function _getFallbackOraclePrice(address vToken, uint256 pivotPrice) private view returns (uint256, bool) {\n (address fallbackOracle, bool fallbackEnabled) = getOracle(vToken, OracleRole.FALLBACK);\n if (fallbackEnabled && fallbackOracle != address(0)) {\n try OracleInterface(fallbackOracle).getUnderlyingPrice(vToken) returns (uint256 fallbackOraclePrice) {\n if (pivotPrice == INVALID_PRICE) {\n return (fallbackOraclePrice, false);\n }\n return (\n fallbackOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(vToken, fallbackOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view returns (address asset) {\n if (address(vToken) == vBnb) {\n asset = BNB_ADDR;\n } else if (address(vToken) == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" }, diff --git a/deployments/bscmainnet/solcInputs/d647123072ba05451b756817f39951df.json b/deployments/bscmainnet/solcInputs/d647123072ba05451b756817f39951df.json index bf3ce92a..ecff34e1 100644 --- a/deployments/bscmainnet/solcInputs/d647123072ba05451b756817f39951df.json +++ b/deployments/bscmainnet/solcInputs/d647123072ba05451b756817f39951df.json @@ -109,15 +109,9 @@ "contracts/oracles/mocks/MockPythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { IPyth } from \"../PythOracle.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockPythOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice the actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n function initialize(address underlyingPythOracle_) public initializer {\n __Ownable_init();\n if (underlyingPythOracle_ == address(0)) revert(\"pyth oracle cannot be zero address\");\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" }, - "contracts/oracles/mocks/MockTwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockTwapOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice vBNB address\n address public vBNB;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n function initialize(address vBNB_) public initializer {\n __Ownable_init();\n if (vBNB_ == address(0)) revert(\"vBNB can't be zero address\");\n vBNB = vBNB_;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" - }, "contracts/oracles/PythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"../interfaces/PythInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title PythOracle\n * @author Venus\n * @notice PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores\n * the updated prices from external sources\n */\ncontract PythOracle is AccessControlledV8, OracleInterface {\n // To calculate 10 ** n(which is a signed type)\n using SignedMath for int256;\n\n // To cast int64/int8 types from Pyth to unsigned types\n using SafeCast for int256;\n\n struct TokenConfig {\n bytes32 pythId;\n address asset;\n uint64 maxStalePeriod;\n }\n\n /// @notice Exponent scale (decimal precision) of prices\n uint256 public constant EXP_SCALE = 1e18;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice The actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n /// @notice Token configs by asset address\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when setting a new pyth oracle address\n event PythOracleSet(address indexed oldPythOracle, address indexed newPythOracle);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed asset, bytes32 indexed pythId, uint64 indexed maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Batch set token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the underlying Pyth oracle contract address\n * @param underlyingPythOracle_ Pyth oracle contract address\n * @custom:access Only Governance\n * @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero\n * @custom:event Emits PythOracleSet event with address of Pyth oracle.\n */\n function setUnderlyingPythOracle(\n IPyth underlyingPythOracle_\n ) external notNullAddress(address(underlyingPythOracle_)) {\n _checkAccessAllowed(\"setUnderlyingPythOracle(address)\");\n IPyth oldUnderlyingPythOracle = underlyingPythOracle;\n underlyingPythOracle = underlyingPythOracle_;\n emit PythOracleSet(address(oldUnderlyingPythOracle), address(underlyingPythOracle_));\n }\n\n /**\n * @notice Initializes the owner of the contract and sets required contracts\n * @param underlyingPythOracle_ Address of the Pyth oracle\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(\n address underlyingPythOracle_,\n address accessControlManager_\n ) external initializer notNullAddress(underlyingPythOracle_) {\n __AccessControlled_init(accessControlManager_);\n\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n emit PythOracleSet(address(0), underlyingPythOracle_);\n }\n\n /**\n * @notice Set single token config. `maxStalePeriod` cannot be 0 and `asset` cannot be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if max stale period is zero\n * @custom:error NotNullAddress error is thrown if asset address is null\n */\n function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n if (tokenConfig.maxStalePeriod == 0) revert(\"max stale period cannot be 0\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);\n }\n\n /**\n * @notice Gets the price of a asset from the pyth oracle\n * @param asset Address of the asset\n * @return Price in USD\n */\n function getPrice(address asset) public view returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n return _getPriceInternal(asset, decimals);\n }\n\n function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256) {\n TokenConfig storage tokenConfig = tokenConfigs[asset];\n if (tokenConfig.asset == address(0)) revert(\"asset doesn't exist\");\n\n // if the price is expired after it's compared against `maxStalePeriod`, the following call will revert\n PythStructs.Price memory priceInfo = underlyingPythOracle.getPriceNoOlderThan(\n tokenConfig.pythId,\n tokenConfig.maxStalePeriod\n );\n\n uint256 price = int256(priceInfo.price).toUint256();\n\n if (price == 0) revert(\"invalid pyth oracle price\");\n\n // the price returned from Pyth is price ** 10^expo, which is the real dollar price of the assets\n // we need to multiply it by 1e18 to make the price 18 decimals\n if (priceInfo.expo > 0) {\n return price * EXP_SCALE * (10 ** int256(priceInfo.expo).toUint256()) * (10 ** (18 - decimals));\n } else {\n return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));\n }\n }\n}\n" }, - "contracts/oracles/TwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../libraries/PancakeLibrary.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title TwapOracle\n * @author Venus\n * @notice This oracle fetches price of assets from PancakeSwap.\n */\ncontract TwapOracle is AccessControlledV8, TwapInterface {\n using FixedPoint for *;\n\n struct Observation {\n uint256 timestamp;\n uint256 acc;\n }\n\n struct TokenConfig {\n /// @notice Asset address, which can't be zero address and can be used for existance check\n address asset;\n /// @notice Decimals of asset represented as 1e{decimals}\n uint256 baseUnit;\n /// @notice The address of Pancake pair\n address pancakePool;\n /// @notice Whether the token is paired with WBNB\n bool isBnbBased;\n /// @notice A flag identifies whether the Pancake pair is reversed\n /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not.\n bool isReversedPool;\n /// @notice The minimum window in seconds required between TWAP updates\n uint256 anchorPeriod;\n }\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice WBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WBNB;\n\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\n uint256 public constant BNB_BASE_UNIT = 1e18;\n uint256 public constant BUSD_BASE_UNIT = 1e18;\n\n /// @notice Configs by token\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Stored price by token\n mapping(address => uint256) public prices;\n\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\n mapping(address => Observation[]) public observations;\n\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\n mapping(address => uint256) public windowStart;\n\n /// @notice Emit this event when TWAP window is updated\n event TwapWindowUpdated(\n address indexed asset,\n uint256 oldTimestamp,\n uint256 oldAcc,\n uint256 newTimestamp,\n uint256 newAcc\n );\n\n /// @notice Emit this event when TWAP price is updated\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\n\n /// @notice Emit this event when new token configs are added\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param wBnbAddress The address of the WBNB\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address wBnbAddress) notNullAddress(wBnbAddress) {\n WBNB = wBnbAddress;\n _disableInitializers();\n }\n\n /**\n * @notice Adds multiple token configs at the same time\n * @param configs Config array\n * @custom:error Zero length error thrown, if length of the config array is 0\n */\n function setTokenConfigs(TokenConfig[] memory configs) external {\n if (configs.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = configs.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(configs[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Get the TWAP price for the given asset\n * @param asset asset address\n * @return price asset price in USD\n * @custom:error Missing error is thrown if the token config does not exist\n * @custom:error Range error is thrown if TWAP price is not greater than zero\n */\n function getPrice(address asset) external view override returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n asset = WBNB;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n uint256 price = prices[asset];\n\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\n if (price == 0) revert(\"TWAP price must be positive\");\n return (price * (10 ** (18 - decimals)));\n }\n\n /**\n * @notice Adds a single token config\n * @param config token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if anchor period is not greater than zero\n * @custom:error Range error is thrown if base unit is not greater than zero\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\n * @custom:error NotNullAddress error is thrown if address of asset is null\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\n * @custom:event Emits TokenConfigAdded event if new token config are added with\n * asset address, PancakePool address, anchor period address\n */\n function setTokenConfig(\n TokenConfig memory config\n ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n if (config.anchorPeriod == 0) revert(\"anchor period must be positive\");\n if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals())\n revert(\"base unit decimals must be same as asset decimals\");\n\n uint256 cumulativePrice = currentCumulativePrice(config);\n\n // Initialize observation data\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\n tokenConfigs[config.asset] = config;\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\n }\n\n /**\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return anchorPrice anchor price of the asset\n * @custom:error Missing error is thrown if token config does not exist\n */\n function updateTwap(address asset) public returns (uint256) {\n if (asset == BNB_ADDR) {\n asset = WBNB;\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\n if (tokenConfigs[WBNB].asset == address(0)) revert(\"WBNB not exist\");\n _updateTwapInternal(tokenConfigs[WBNB]);\n }\n return _updateTwapInternal(tokenConfigs[asset]);\n }\n\n /**\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\n * @return cumulative price of target token regardless of pair order\n */\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\n if (config.isReversedPool) {\n return price1;\n } else {\n return price0;\n }\n }\n\n /**\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return price Asset price in USD, with 18 decimals\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\n * AnchorPrice, old observation timestamp and current timestamp\n */\n function _updateTwapInternal(TokenConfig memory config) private returns (uint256) {\n // pokeWindowValues already handled reversed pool cases,\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\n\n if (block.timestamp == oldTimestamp) return prices[config.asset];\n\n // This should be impossible, but better safe than sorry\n if (block.timestamp < oldTimestamp) revert(\"now must come after before\");\n\n uint256 timeElapsed;\n unchecked {\n timeElapsed = block.timestamp - oldTimestamp;\n }\n\n // Calculate Pancake *twap**\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\n );\n // *twap** price with 1e18 decimal mantissa\n uint256 priceAverageMantissa = priceAverage.decode112with18();\n\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\n // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18)\n uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT;\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\n\n // if this token is paired with BNB, convert its price to USD\n if (config.isBnbBased) {\n uint256 bnbPrice = prices[WBNB];\n if (bnbPrice == 0) revert(\"bnb price is invalid\");\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT;\n }\n\n if (anchorPriceMantissa == 0) revert(\"twap price cannot be 0\");\n\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\n\n // save anchor price, which is 1e18 decimals\n prices[config.asset] = anchorPriceMantissa;\n\n return anchorPriceMantissa;\n }\n\n /**\n * @notice Appends current observation and pick an observation with a timestamp equal\n * or just greater than the window start timestamp. If one is not available,\n * then pick the last availableobservation. The window start index is updated in both the cases.\n * Only the current observation is saved, prior observations are deleted during this operation.\n * @return Tuple of cumulative price, old observation and timestamp\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\n * new observation timestamp, current timestamp, new observation price and cumulative price\n */\n function pokeWindowValues(\n TokenConfig memory config\n ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\n uint256 cumulativePrice = currentCumulativePrice(config);\n uint256 currentTimestamp = block.timestamp;\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\n Observation[] memory storedObservations = observations[config.asset];\n\n uint256 storedObservationsLength = storedObservations.length;\n for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) {\n if (\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\n (windowStartIndex == storedObservationsLength - 1)\n ) {\n startCumulativePrice = storedObservations[windowStartIndex].acc;\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\n windowStart[config.asset] = windowStartIndex;\n break;\n } else {\n delete observations[config.asset][windowStartIndex];\n }\n\n unchecked {\n ++windowStartIndex;\n }\n }\n\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\n emit TwapWindowUpdated(\n config.asset,\n startCumulativeTimestamp,\n startCumulativePrice,\n block.timestamp,\n cumulativePrice\n );\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\n }\n}\n" - }, "contracts/ResilientOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ResilientOracle\n * @author Venus\n * @notice The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets.\n * \n * DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly\n * reported prices. If only one oracle is used, this creates a single point of failure and opens a vector\n * for attacking the protocol.\n * \n * The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect\n * the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle\n * and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.\n * \n * For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per \n * vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot \n * oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. \n * \n * To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every\n * market. The upper bound ratio represents the deviation between reported price (the price that’s being\n * validated) and the anchor price (the price we are validating against) above which the reported price will\n * be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below\n * which the reported price will be invalidated. So for oracle price to be considered valid the below statement\n * should be true:\n\n```\nanchorRatio = anchorPrice/reporterPrice\nisValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio\n```\n\n * In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending\n * on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may\n * use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. \n * \n * For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the\n * oracle to be stagnant and treat it like it's disabled.\n */\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n /**\n * @dev Oracle roles:\n * **main**: The most trustworthy price source\n * **pivot**: Price oracle used as a loose sanity checker\n * **fallback**: The backup source when main oracle price is invalidated\n */\n enum OracleRole {\n MAIN,\n PIVOT,\n FALLBACK\n }\n\n struct TokenConfig {\n /// @notice asset address\n address asset;\n /// @notice `oracles` stores the oracles based on their role in the following order:\n /// [main, pivot, fallback],\n /// It can be indexed with the corresponding enum OracleRole value\n address[3] oracles;\n /// @notice `enableFlagsForOracles` stores the enabled state\n /// for each oracle in the same order as `oracles`\n bool[3] enableFlagsForOracles;\n }\n\n uint256 public constant INVALID_PRICE = 0;\n\n /// @notice vBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vBnb;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Bound validator contract address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n BoundValidatorInterface public immutable boundValidator;\n\n mapping(address => TokenConfig) private tokenConfigs;\n\n event TokenConfigAdded(\n address indexed asset,\n address indexed mainOracle,\n address indexed pivotOracle,\n address fallbackOracle\n );\n\n /// Event emitted when an oracle is set\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n /// Event emitted when an oracle is enabled or disabled\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /**\n * @notice Checks whether token config exists by checking whether asset is null address\n * @dev address can't be null, so it's suitable to be used to check the validity of the config\n * @param asset asset address\n */\n modifier checkTokenConfigExistence(address asset) {\n if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param vBnbAddress The address of the vBNB\n /// @param vaiAddress The address of the VAI\n /// @param _boundValidator Address of the bound validator contract\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address vBnbAddress,\n address vaiAddress,\n BoundValidatorInterface _boundValidator\n ) notNullAddress(vBnbAddress) notNullAddress(vaiAddress) notNullAddress(address(_boundValidator)) {\n vBnb = vBnbAddress;\n vai = vaiAddress;\n boundValidator = _boundValidator;\n\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract admin and sets the BoundValidator contract address\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n }\n\n /**\n * @notice Pauses oracle\n * @custom:access Only Governance\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n _pause();\n }\n\n /**\n * @notice Unpauses oracle\n * @custom:access Only Governance\n */\n function unpause() external {\n _checkAccessAllowed(\"unpause()\");\n _unpause();\n }\n\n /**\n * @notice Batch sets token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Throws a length error if the length of the token configs array is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Sets oracle for a given asset and role.\n * @dev Supplied asset **must** exist and main oracle may not be null\n * @param asset Asset address\n * @param oracle Oracle address\n * @param role Oracle role\n * @custom:access Only Governance\n * @custom:error Null address error if main-role oracle address is null\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n */\n function setOracle(\n address asset,\n address oracle,\n OracleRole role\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\n emit OracleSet(asset, oracle, uint256(role));\n }\n\n /**\n * @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\n * @dev Configuration for the asset **must** already exist and the asset cannot be 0 address\n * @param asset Asset address\n * @param role Oracle role\n * @param enable Enabled boolean of the oracle\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n */\n function enableOracle(\n address asset,\n OracleRole role,\n bool enable\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n emit OracleEnabled(asset, uint256(role), enable);\n }\n\n /**\n * @notice Updates the TWAP pivot oracle price.\n * @dev This function should always be called before calling getUnderlyingPrice\n * @param vToken vToken address\n */\n function updatePrice(address vToken) external override {\n address asset = _getUnderlyingAsset(vToken);\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @notice Updates the pivot oracle price. Currently using TWAP\n * @dev This function should always be called before calling getPrice\n * @param asset asset address\n */\n function updateAssetPrice(address asset) external {\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @dev Gets token config by asset address\n * @param asset asset address\n * @return tokenConfig Config for the asset\n */\n function getTokenConfig(address asset) external view returns (TokenConfig memory) {\n return tokenConfigs[asset];\n }\n\n /**\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n * - Check if the oracle is paused globally\n * - Validate price from main oracle against pivot oracle\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\n * - Validate price from main oracle against fallback oracle if the second validation failed\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\n * main oracle price is returned.\n * @param vToken vToken address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n\n address asset = _getUnderlyingAsset(vToken);\n return _getPrice(asset);\n }\n\n /**\n * @notice Gets price of the asset\n * @param asset asset address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getPrice(address asset) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n return _getPrice(asset);\n }\n\n /**\n * @notice Sets/resets single token configs.\n * @dev main oracle **must not** be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress is thrown if asset address is null\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n * @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(\n tokenConfig.asset,\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n );\n }\n\n /**\n * @notice Gets oracle and enabled status by asset address\n * @param asset asset address\n * @param role Oracle role\n * @return oracle Oracle address based on role\n * @return enabled Enabled flag of the oracle based on token config\n */\n function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {\n oracle = tokenConfigs[asset].oracles[uint256(role)];\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n }\n\n function _getPrice(address asset) internal view returns (uint256) {\n uint256 pivotPrice = INVALID_PRICE;\n\n // Get pivot oracle price, Invalid price if not available or error\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracleEnabled && pivotOracle != address(0)) {\n try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {\n pivotPrice = pricePivot;\n } catch {}\n }\n\n // Compare main price and pivot price, return main price and if validation was successful\n // note: In case pivot oracle is not available but main price is available and\n // validation is successful, the main oracle price is returned.\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n asset,\n pivotPrice,\n pivotOracleEnabled && pivotOracle != address(0)\n );\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n // Compare fallback and pivot if main oracle comparision fails with pivot\n // Return fallback price when fallback price is validated successfully with pivot oracle\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n // Lastly compare main price and fallback price\n if (\n mainPrice != INVALID_PRICE &&\n fallbackPrice != INVALID_PRICE &&\n boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)\n ) {\n return mainPrice;\n }\n\n revert(\"invalid resilient oracle price\");\n }\n\n /**\n * @notice Gets a price for the provided asset\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\n * able to fetch a correct price\n * @param asset asset address\n * @param pivotPrice Pivot oracle price\n * @param pivotEnabled If pivot oracle is not empty and enabled\n * @return price USD price in scaled decimals\n * e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n * @return pivotValidated Boolean representing if the validation of main oracle price\n * and pivot oracle price were successful\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n * address is null\n */\n function _getMainOraclePrice(\n address asset,\n uint256 pivotPrice,\n bool pivotEnabled\n ) internal view returns (uint256, bool) {\n (address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);\n if (mainOracleEnabled && mainOracle != address(0)) {\n try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {\n if (!pivotEnabled) {\n return (mainOraclePrice, true);\n }\n if (pivotPrice == INVALID_PRICE) {\n return (mainOraclePrice, false);\n }\n return (\n mainOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function won't revert when the price is 0 because getPrice checks if price is > 0\n * @param asset asset address\n * @return price USD price in 18 decimals\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\n * and pivot oracle price were successfull\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n * address is null\n */\n function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {\n (address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);\n if (fallbackEnabled && fallbackOracle != address(0)) {\n try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {\n if (pivotPrice == INVALID_PRICE) {\n return (fallbackOraclePrice, false);\n }\n return (\n fallbackOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view returns (address asset) {\n if (address(vToken) == vBnb) {\n asset = BNB_ADDR;\n } else if (address(vToken) == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" }, diff --git a/deployments/bscmainnet_addresses.json b/deployments/bscmainnet_addresses.json index a08313ca..e39a711b 100644 --- a/deployments/bscmainnet_addresses.json +++ b/deployments/bscmainnet_addresses.json @@ -20,9 +20,6 @@ "RedStoneOracle_Proxy": "0x8455EFA4D7Ff63b8BFD96AdD889483Ea7d39B70a", "ResilientOracle": "0x6592b5DE802159F3E74B2486b091D11a8256ab8A", "ResilientOracle_Implementation": "0xB5d7A073d77102ad56B7482b18E7204c1a71C8B9", - "ResilientOracle_Proxy": "0x6592b5DE802159F3E74B2486b091D11a8256ab8A", - "TwapOracle": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", - "TwapOracle_Implementation": "0x67c549A18AbfAd127b13F8d56738F43A21bB62A7", - "TwapOracle_Proxy": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867" + "ResilientOracle_Proxy": "0x6592b5DE802159F3E74B2486b091D11a8256ab8A" } } diff --git a/deployments/bsctestnet.json b/deployments/bsctestnet.json index 9b471fa6..dd5ffe27 100644 --- a/deployments/bsctestnet.json +++ b/deployments/bsctestnet.json @@ -7000,1566 +7000,6 @@ "type": "receive" } ] - }, - "TwapOracle": { - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "admin_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "calledContract", - "type": "address" - }, - { - "internalType": "string", - "name": "methodSignature", - "type": "string" - } - ], - "name": "Unauthorized", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newTimestamp", - "type": "uint256" - } - ], - "name": "AnchorPriceUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "oldAccessControlManager", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAccessControlManager", - "type": "address" - } - ], - "name": "NewAccessControlManager", - "type": "event" - }, - { - "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": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "name": "TokenConfigAdded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldAcc", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newAcc", - "type": "uint256" - } - ], - "name": "TwapWindowUpdated", - "type": "event" - }, - { - "inputs": [], - "name": "BNB_BASE_UNIT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "BUSD_BASE_UNIT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "WBNB", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "acceptOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "accessControlManager", - "outputs": [ - { - "internalType": "contract IAccessControlManagerV8", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "currentCumulativePrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "vToken", - "type": "address" - } - ], - "name": "getUnderlyingPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "accessControlManager_", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "observations", - "outputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "acc", - "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": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "prices", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "accessControlManager_", - "type": "address" - } - ], - "name": "setAccessControlManager", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "setTokenConfig", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig[]", - "name": "configs", - "type": "tuple[]" - } - ], - "name": "setTokenConfigs", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "tokenConfigs", - "outputs": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "vToken", - "type": "address" - } - ], - "name": "updateTwap", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "vBnb", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "vai", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "windowStart", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_logic", - "type": "address" - }, - { - "internalType": "address", - "name": "admin_", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_data", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "constructor" - } - ] - }, - "TwapOracle_Implementation": { - "address": "0x572ec272B4Ae3a50B99905AFd78671F84474ffd1", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "vBnbAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "wBnbAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "vaiAddress", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "calledContract", - "type": "address" - }, - { - "internalType": "string", - "name": "methodSignature", - "type": "string" - } - ], - "name": "Unauthorized", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newTimestamp", - "type": "uint256" - } - ], - "name": "AnchorPriceUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "oldAccessControlManager", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAccessControlManager", - "type": "address" - } - ], - "name": "NewAccessControlManager", - "type": "event" - }, - { - "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": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "name": "TokenConfigAdded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldAcc", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newAcc", - "type": "uint256" - } - ], - "name": "TwapWindowUpdated", - "type": "event" - }, - { - "inputs": [], - "name": "BNB_BASE_UNIT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "BUSD_BASE_UNIT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "WBNB", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "acceptOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "accessControlManager", - "outputs": [ - { - "internalType": "contract IAccessControlManagerV8", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "currentCumulativePrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "vToken", - "type": "address" - } - ], - "name": "getUnderlyingPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "accessControlManager_", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "observations", - "outputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "acc", - "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": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "prices", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "accessControlManager_", - "type": "address" - } - ], - "name": "setAccessControlManager", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "setTokenConfig", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig[]", - "name": "configs", - "type": "tuple[]" - } - ], - "name": "setTokenConfigs", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "tokenConfigs", - "outputs": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "vToken", - "type": "address" - } - ], - "name": "updateTwap", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "vBnb", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "vai", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "windowStart", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } - ] - }, - "TwapOracle_Proxy": { - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_logic", - "type": "address" - }, - { - "internalType": "address", - "name": "admin_", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_data", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "admin_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ] } } } diff --git a/deployments/bsctestnet/TwapOracle_Implementation.json b/deployments/bsctestnet/TwapOracle_Implementation.json deleted file mode 100644 index e03c08ba..00000000 --- a/deployments/bsctestnet/TwapOracle_Implementation.json +++ /dev/null @@ -1,1111 +0,0 @@ -{ - "address": "0x572ec272B4Ae3a50B99905AFd78671F84474ffd1", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "vBnbAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "wBnbAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "vaiAddress", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "calledContract", - "type": "address" - }, - { - "internalType": "string", - "name": "methodSignature", - "type": "string" - } - ], - "name": "Unauthorized", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newTimestamp", - "type": "uint256" - } - ], - "name": "AnchorPriceUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "oldAccessControlManager", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAccessControlManager", - "type": "address" - } - ], - "name": "NewAccessControlManager", - "type": "event" - }, - { - "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": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "name": "TokenConfigAdded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldAcc", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newAcc", - "type": "uint256" - } - ], - "name": "TwapWindowUpdated", - "type": "event" - }, - { - "inputs": [], - "name": "BNB_BASE_UNIT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "BUSD_BASE_UNIT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "WBNB", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "acceptOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "accessControlManager", - "outputs": [ - { - "internalType": "contract IAccessControlManagerV8", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "currentCumulativePrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "vToken", - "type": "address" - } - ], - "name": "getUnderlyingPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "accessControlManager_", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "observations", - "outputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "acc", - "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": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "prices", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "accessControlManager_", - "type": "address" - } - ], - "name": "setAccessControlManager", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "setTokenConfig", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig[]", - "name": "configs", - "type": "tuple[]" - } - ], - "name": "setTokenConfigs", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "tokenConfigs", - "outputs": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "vToken", - "type": "address" - } - ], - "name": "updateTwap", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "vBnb", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "vai", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "windowStart", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "transactionHash": "0x402d32b0ce7fd96d402fe76dfd89593d262af764f6eb8117abf10f1db61021a4", - "receipt": { - "to": null, - "from": "0x8BDA9f9E1fEF0DFd404Fef338D9fE4c543d172e1", - "contractAddress": "0xA65d9c3593B8ca0EF4C475E16Eb93f92Ca81F98B", - "transactionIndex": 1, - "gasUsed": "1815984", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x15c971ec2e16b7b425a7f6c7e35333a9d510beb014b0dceba7b63d5d0b1d6475", - "transactionHash": "0x402d32b0ce7fd96d402fe76dfd89593d262af764f6eb8117abf10f1db61021a4", - "logs": [ - { - "transactionIndex": 1, - "blockNumber": 30137622, - "transactionHash": "0x402d32b0ce7fd96d402fe76dfd89593d262af764f6eb8117abf10f1db61021a4", - "address": "0xA65d9c3593B8ca0EF4C475E16Eb93f92Ca81F98B", - "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], - "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", - "logIndex": 1, - "blockHash": "0x15c971ec2e16b7b425a7f6c7e35333a9d510beb014b0dceba7b63d5d0b1d6475" - } - ], - "blockNumber": 30137622, - "cumulativeGasUsed": "1868910", - "status": 1, - "byzantium": true - }, - "args": [ - "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", - "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", - "0x5fFbE5302BadED40941A403228E6AD03f93752d9" - ], - "numDeployments": 1, - "solcInputHash": "131f58942628e21632de19506977a910", - "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vBnbAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"wBnbAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"vaiAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"calledContract\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"methodSignature\",\"type\":\"string\"}],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"name\":\"AnchorPriceUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAccessControlManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAccessControlManager\",\"type\":\"address\"}],\"name\":\"NewAccessControlManager\",\"type\":\"event\"},{\"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\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"name\":\"TokenConfigAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldAcc\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAcc\",\"type\":\"uint256\"}],\"name\":\"TwapWindowUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BNB_BASE_UNIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"BUSD_BASE_UNIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WBNB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accessControlManager\",\"outputs\":[{\"internalType\":\"contract IAccessControlManagerV8\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct TwapOracle.TokenConfig\",\"name\":\"config\",\"type\":\"tuple\"}],\"name\":\"currentCumulativePrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"getUnderlyingPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"observations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"acc\",\"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\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"prices\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"setAccessControlManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct TwapOracle.TokenConfig\",\"name\":\"config\",\"type\":\"tuple\"}],\"name\":\"setTokenConfig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct TwapOracle.TokenConfig[]\",\"name\":\"configs\",\"type\":\"tuple[]\"}],\"name\":\"setTokenConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"tokenConfigs\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"updateTwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"vBnb\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"vai\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"windowStart\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\",\"params\":{\"vBnbAddress\":\"The address of the VBNB\",\"vaiAddress\":\"The address of the WBNB\",\"wBnbAddress\":\"The address of the WBNB\"}},\"currentCumulativePrice((address,uint256,address,bool,bool,uint256))\":{\"returns\":{\"_0\":\"cumulative price of target token regardless of pair order\"}},\"getUnderlyingPrice(address)\":{\"custom:error\":\"Missing error is thrown if the token config does not existRange error is thrown if TWAP price is not greater than zero\",\"params\":{\"vToken\":\"vToken address\"},\"returns\":{\"_0\":\"price Underlying price in USD\"}},\"initialize(address)\":{\"params\":{\"accessControlManager_\":\"Address of the access control manager contract\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"setAccessControlManager(address)\":{\"custom:access\":\"Only Governance\",\"custom:event\":\"Emits NewAccessControlManager event\",\"details\":\"Admin function to set address of AccessControlManager\",\"params\":{\"accessControlManager_\":\"The new address of the AccessControlManager\"}},\"setTokenConfig((address,uint256,address,bool,bool,uint256))\":{\"custom:access\":\"Only Governance\",\"custom:error\":\"Range error is thrown if anchor period is not greater than zeroRange error is thrown if base unit is not greater than zeroValue error is thrown if base unit decimals is not the same as asset decimalsNotNullAddress error is thrown if address of asset is nullNotNullAddress error is thrown if PancakeSwap pool address is null\",\"custom:event\":\"Emits TokenConfigAdded event if new token config are added with asset address, PancakePool address, anchor period address\",\"params\":{\"config\":\"token config struct\"}},\"setTokenConfigs((address,uint256,address,bool,bool,uint256)[])\":{\"custom:error\":\"Zero length error thrown, if length of the config array is 0\",\"params\":{\"configs\":\"Config array\"}},\"transferOwnership(address)\":{\"details\":\"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.\"},\"updateTwap(address)\":{\"custom:error\":\"Missing error is thrown if token config does not exist\",\"returns\":{\"_0\":\"anchorPrice anchor price of the underlying asset of the vToken\"}}},\"stateVariables\":{\"WBNB\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"vBnb\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"vai\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"version\":1},\"userdoc\":{\"errors\":{\"Unauthorized(address,address,string)\":[{\"notice\":\"Thrown when the action is prohibited by AccessControlManager\"}]},\"events\":{\"AnchorPriceUpdated(address,uint256,uint256,uint256)\":{\"notice\":\"Emit this event when TWAP price is updated\"},\"NewAccessControlManager(address,address)\":{\"notice\":\"Emitted when access control manager contract address is changed\"},\"TokenConfigAdded(address,address,uint256)\":{\"notice\":\"Emit this event when new token configs are added\"},\"TwapWindowUpdated(address,uint256,uint256,uint256,uint256)\":{\"notice\":\"Emit this event when TWAP window is updated\"}},\"kind\":\"user\",\"methods\":{\"BNB_BASE_UNIT()\":{\"notice\":\"the base unit of WBNB and BUSD, which are the paired tokens for all assets\"},\"WBNB()\":{\"notice\":\"WBNB address\"},\"accessControlManager()\":{\"notice\":\"Returns the address of the access control manager contract\"},\"constructor\":{\"notice\":\"Constructor for the implementation contract. Sets immutable variables.\"},\"currentCumulativePrice((address,uint256,address,bool,bool,uint256))\":{\"notice\":\"Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\"},\"getUnderlyingPrice(address)\":{\"notice\":\"Get the underlying TWAP price for the given vToken\"},\"initialize(address)\":{\"notice\":\"Initializes the owner of the contract\"},\"observations(address,uint256)\":{\"notice\":\"Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\"},\"prices(address)\":{\"notice\":\"Stored price by token\"},\"setAccessControlManager(address)\":{\"notice\":\"Sets the address of AccessControlManager\"},\"setTokenConfig((address,uint256,address,bool,bool,uint256))\":{\"notice\":\"Adds a single token config\"},\"setTokenConfigs((address,uint256,address,bool,bool,uint256)[])\":{\"notice\":\"Adds multiple token configs at the same time\"},\"tokenConfigs(address)\":{\"notice\":\"Configs by token\"},\"updateTwap(address)\":{\"notice\":\"Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\"},\"vBnb()\":{\"notice\":\"vBNB address\"},\"vai()\":{\"notice\":\"VAI address\"},\"windowStart(address)\":{\"notice\":\"Observation array index which probably falls in current anchor period mapped by asset address\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/oracles/TwapOracle.sol\":\"TwapOracle\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./OwnableUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\\n function __Ownable2Step_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable2Step_init_unchained() internal onlyInitializing {\\n }\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() external {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xd712fb45b3ea0ab49679164e3895037adc26ce12879d5184feb040e01c1c07a9\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\\\";\\n\\nimport \\\"./IAccessControlManagerV8.sol\\\";\\n\\n/**\\n * @title Venus Access Control Contract.\\n * @dev The AccessControlledV8 contract is a wrapper around the OpenZeppelin AccessControl contract\\n * It provides a standardized way to control access to methods within the Venus Smart Contract Ecosystem.\\n * The contract allows the owner to set an AccessControlManager contract address.\\n * It can restrict method calls based on the sender's role and the method's signature.\\n */\\n\\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\\n /// @notice Access control manager contract\\n IAccessControlManagerV8 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /// @notice Thrown when the action is prohibited by AccessControlManager\\n error Unauthorized(address sender, address calledContract, string methodSignature);\\n\\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\\n __Ownable2Step_init();\\n __AccessControlled_init_unchained(accessControlManager_);\\n }\\n\\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Sets the address of AccessControlManager\\n * @dev Admin function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n * @custom:event Emits NewAccessControlManager event\\n * @custom:access Only Governance\\n */\\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV8) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert Unauthorized(msg.sender, address(this), signature);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x618d942756b93e02340a42f3c80aa99fc56be1a96861f5464dc23a76bf30b3a5\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/access/IAccessControl.sol\\\";\\n\\ninterface IAccessControlManagerV8 is IAccessControl {\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x41deef84d1839590b243b66506691fde2fb938da01eabde53e82d3b8316fdaf9\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface OracleInterface {\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address vToken) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address vToken,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x8ac0bda5d5789c320bf219dc6691eef0e6617e9653bc0e24f407a44e4281edda\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/VBep20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\ninterface VBep20Interface is IERC20Metadata {\\n /**\\n * @notice Underlying asset for this VToken\\n */\\n function underlying() external view returns (address);\\n}\\n\",\"keccak256\":\"0x3f845cd51b2d82f7932ac6c0ab714df97f733b01ce50f6fb0adb4c28447d4618\",\"license\":\"BSD-3-Clause\"},\"contracts/libraries/PancakeLibrary.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface IPancakePair {\\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\\n\\n function price0CumulativeLast() external view returns (uint256);\\n\\n function price1CumulativeLast() external view returns (uint256);\\n}\\n\\nlibrary FixedPoint {\\n // range: [0, 2**112 - 1]\\n // resolution: 1 / 2**112\\n struct uq112x112 {\\n uint224 _x;\\n }\\n\\n // returns a uq112x112 which represents the ratio of the numerator to the denominator\\n // equivalent to encode(numerator).div(denominator)\\n function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {\\n require(denominator > 0, \\\"FixedPoint: DIV_BY_ZERO\\\");\\n return uq112x112((uint224(numerator) << 112) / denominator);\\n }\\n\\n // decode a uq112x112 into a uint with 18 decimals of precision\\n function decode112with18(uq112x112 memory self) internal pure returns (uint256) {\\n // we only have 256 - 224 = 32 bits to spare, so scaling up by ~60 bits is dangerous\\n // instead, get close to:\\n // (x * 1e18) >> 112\\n // without risk of overflowing, e.g.:\\n // (x) / 2 ** (112 - lg(1e18))\\n return uint256(self._x) / 5192296858534827;\\n }\\n}\\n\\n// library with helper methods for oracles that are concerned with computing average prices\\nlibrary PancakeOracleLibrary {\\n using FixedPoint for *;\\n\\n // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]\\n function currentBlockTimestamp() internal view returns (uint32) {\\n return uint32(block.timestamp % 2 ** 32);\\n }\\n\\n // produces the cumulative price using counterfactuals to save gas and avoid a call to sync.\\n function currentCumulativePrices(\\n address pair\\n ) internal view returns (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) {\\n blockTimestamp = currentBlockTimestamp();\\n price0Cumulative = IPancakePair(pair).price0CumulativeLast();\\n price1Cumulative = IPancakePair(pair).price1CumulativeLast();\\n\\n // if time has elapsed since the last update on the pair, mock the accumulated price values\\n (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IPancakePair(pair).getReserves();\\n if (blockTimestampLast != blockTimestamp) {\\n unchecked {\\n // subtraction overflow is desired\\n uint32 timeElapsed = blockTimestamp - blockTimestampLast;\\n // addition overflow is desired\\n // counterfactual\\n price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;\\n // counterfactual\\n price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2c8179ebad223998514d6f25ebd90f80ecb294b562d9fbc4a42bf6710486c25b\",\"license\":\"BSD-3-Clause\"},\"contracts/oracles/TwapOracle.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"../libraries/PancakeLibrary.sol\\\";\\nimport \\\"../interfaces/OracleInterface.sol\\\";\\nimport \\\"../interfaces/VBep20Interface.sol\\\";\\nimport \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\\\";\\n\\ncontract TwapOracle is AccessControlledV8, TwapInterface {\\n using FixedPoint for *;\\n\\n struct Observation {\\n uint256 timestamp;\\n uint256 acc;\\n }\\n\\n struct TokenConfig {\\n /// @notice Asset address, which can't be zero address and can be used for existance check\\n address asset;\\n /// @notice Decimals of underlying asset respresented as 1e{decimals}\\n uint256 baseUnit;\\n /// @notice The address of Pancake pair\\n address pancakePool;\\n /// @notice Whether the token is paired with WBNB\\n bool isBnbBased;\\n /// @notice A flag identifies whether the Pancake pair is reversed\\n /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not.\\n bool isReversedPool;\\n /// @notice The minimum window in seconds required between TWAP updates\\n uint256 anchorPeriod;\\n }\\n\\n /// @notice WBNB address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable WBNB;\\n\\n /// @notice vBNB address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable vBnb;\\n\\n /// @notice VAI address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable vai;\\n\\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\\n uint256 public constant BNB_BASE_UNIT = 1e18;\\n uint256 public constant BUSD_BASE_UNIT = 1e18;\\n\\n /// @notice Configs by token\\n mapping(address => TokenConfig) public tokenConfigs;\\n\\n /// @notice Stored price by token\\n mapping(address => uint256) public prices;\\n\\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\\n mapping(address => Observation[]) public observations;\\n\\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\\n mapping(address => uint256) public windowStart;\\n\\n /// @notice Emit this event when TWAP window is updated\\n event TwapWindowUpdated(\\n address indexed asset,\\n uint256 oldTimestamp,\\n uint256 oldAcc,\\n uint256 newTimestamp,\\n uint256 newAcc\\n );\\n\\n /// @notice Emit this event when TWAP price is updated\\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\\n\\n /// @notice Emit this event when new token configs are added\\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\\n\\n modifier notNullAddress(address someone) {\\n if (someone == address(0)) revert(\\\"can't be zero address\\\");\\n _;\\n }\\n\\n /// @notice Constructor for the implementation contract. Sets immutable variables.\\n /// @param vBnbAddress The address of the VBNB\\n /// @param wBnbAddress The address of the WBNB\\n /// @param vaiAddress The address of the WBNB\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n address vBnbAddress,\\n address wBnbAddress,\\n address vaiAddress\\n ) notNullAddress(vBnbAddress) notNullAddress(wBnbAddress) notNullAddress(vaiAddress) {\\n vBnb = vBnbAddress;\\n WBNB = wBnbAddress;\\n vai = vaiAddress;\\n _disableInitializers();\\n }\\n\\n /**\\n * @notice Adds multiple token configs at the same time\\n * @param configs Config array\\n * @custom:error Zero length error thrown, if length of the config array is 0\\n */\\n function setTokenConfigs(TokenConfig[] memory configs) external {\\n if (configs.length == 0) revert(\\\"length can't be 0\\\");\\n uint256 numTokenConfigs = configs.length;\\n for (uint256 i; i < numTokenConfigs; ) {\\n setTokenConfig(configs[i]);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Initializes the owner of the contract\\n * @param accessControlManager_ Address of the access control manager contract\\n */\\n function initialize(address accessControlManager_) external initializer {\\n __AccessControlled_init(accessControlManager_);\\n }\\n\\n /**\\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\\n * @return anchorPrice anchor price of the underlying asset of the vToken\\n * @custom:error Missing error is thrown if token config does not exist\\n */\\n function updateTwap(address vToken) external returns (uint256) {\\n address asset = _getUnderlyingAsset(vToken);\\n\\n if (tokenConfigs[asset].asset == address(0)) revert(\\\"asset not exist\\\");\\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\\n if (tokenConfigs[WBNB].asset == address(0)) revert(\\\"WBNB not exist\\\");\\n _updateTwapInternal(tokenConfigs[WBNB]);\\n }\\n return _updateTwapInternal(tokenConfigs[asset]);\\n }\\n\\n /**\\n * @notice Get the underlying TWAP price for the given vToken\\n * @param vToken vToken address\\n * @return price Underlying price in USD\\n * @custom:error Missing error is thrown if the token config does not exist\\n * @custom:error Range error is thrown if TWAP price is not greater than zero\\n */\\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\\n address asset = _getUnderlyingAsset(vToken);\\n\\n if (tokenConfigs[asset].asset == address(0)) revert(\\\"asset not exist\\\");\\n uint256 price = prices[asset];\\n\\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\\n if (price == 0) revert(\\\"TWAP price must be positive\\\");\\n return (price * (10 ** (18 - IERC20Metadata(asset).decimals())));\\n }\\n\\n /**\\n * @notice Adds a single token config\\n * @param config token config struct\\n * @custom:access Only Governance\\n * @custom:error Range error is thrown if anchor period is not greater than zero\\n * @custom:error Range error is thrown if base unit is not greater than zero\\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\\n * @custom:error NotNullAddress error is thrown if address of asset is null\\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\\n * @custom:event Emits TokenConfigAdded event if new token config are added with\\n * asset address, PancakePool address, anchor period address\\n */\\n function setTokenConfig(\\n TokenConfig memory config\\n ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) {\\n _checkAccessAllowed(\\\"setTokenConfig(TokenConfig)\\\");\\n\\n if (config.anchorPeriod == 0) revert(\\\"anchor period must be positive\\\");\\n if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals())\\n revert(\\\"base unit decimals must be same as asset decimals\\\");\\n\\n uint256 cumulativePrice = currentCumulativePrice(config);\\n\\n // Initialize observation data\\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\\n tokenConfigs[config.asset] = config;\\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\\n }\\n\\n /**\\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\\n * @return cumulative price of target token regardless of pair order\\n */\\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\\n if (config.isReversedPool) {\\n return price1;\\n } else {\\n return price0;\\n }\\n }\\n\\n /**\\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\\n * @return price Underlying price in USD, with 18 decimals\\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\\n * AnchorPrice, old observation timestamp and current timestamp\\n */\\n function _updateTwapInternal(TokenConfig memory config) private returns (uint256) {\\n // pokeWindowValues already handled reversed pool cases,\\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\\n\\n if (block.timestamp == oldTimestamp) return prices[config.asset];\\n\\n // This should be impossible, but better safe than sorry\\n if (block.timestamp < oldTimestamp) revert(\\\"now must come after before\\\");\\n\\n uint256 timeElapsed;\\n unchecked {\\n timeElapsed = block.timestamp - oldTimestamp;\\n }\\n\\n // Calculate Pancake *twap**\\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\\n );\\n // *twap** price with 1e18 decimal mantissa\\n uint256 priceAverageMantissa = priceAverage.decode112with18();\\n\\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\\n // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18)\\n uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT;\\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\\n\\n // if this token is paired with BNB, convert its price to USD\\n if (config.isBnbBased) {\\n uint256 bnbPrice = prices[WBNB];\\n if (bnbPrice == 0) revert(\\\"bnb price is invalid\\\");\\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT;\\n }\\n\\n if (anchorPriceMantissa == 0) revert(\\\"twap price cannot be 0\\\");\\n\\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\\n\\n // save anchor price, which is 1e18 decimals\\n prices[config.asset] = anchorPriceMantissa;\\n\\n return anchorPriceMantissa;\\n }\\n\\n /**\\n * @notice Appends current observation and pick an observation with a timestamp equal\\n * or just greater than the window start timestamp. If one is not available,\\n * then pick the last availableobservation. The window start index is updated in both the cases.\\n * Only the current observation is saved, prior observations are deleted during this operation.\\n * @return Tuple of cumulative price, old observation and timestamp\\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\\n * new observation timestamp, current timestamp, new observation price and cumulative price\\n */\\n function pokeWindowValues(\\n TokenConfig memory config\\n ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\\n uint256 cumulativePrice = currentCumulativePrice(config);\\n uint256 currentTimestamp = block.timestamp;\\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\\n Observation[] memory storedObservations = observations[config.asset];\\n\\n uint256 storedObservationsLength = storedObservations.length;\\n for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) {\\n if (\\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\\n (windowStartIndex == storedObservationsLength - 1)\\n ) {\\n startCumulativePrice = storedObservations[windowStartIndex].acc;\\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\\n windowStart[config.asset] = windowStartIndex;\\n break;\\n } else {\\n delete observations[config.asset][windowStartIndex];\\n }\\n\\n unchecked {\\n ++windowStartIndex;\\n }\\n }\\n\\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\\n emit TwapWindowUpdated(\\n config.asset,\\n startCumulativeTimestamp,\\n startCumulativePrice,\\n block.timestamp,\\n cumulativePrice\\n );\\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\\n }\\n\\n /**\\n * @dev This function returns the underlying asset of a vToken\\n * @param vToken vToken address\\n * @return asset underlying asset address\\n */\\n function _getUnderlyingAsset(address vToken) private view returns (address asset) {\\n if (vToken == vBnb) {\\n asset = WBNB;\\n } else if (vToken == vai) {\\n asset = vai;\\n } else {\\n asset = VBep20Interface(vToken).underlying();\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc6fc865649b9b47c0a76916d13469c88fc33220f7413173273f304def04bb9a3\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", - "bytecode": "0x60e06040523480156200001157600080fd5b506040516200223c3803806200223c83398101604081905262000034916200021b565b826001600160a01b038116620000805760405162461bcd60e51b815260206004820152601560248201526000805160206200221c83398151915260448201526064015b60405180910390fd5b826001600160a01b038116620000c85760405162461bcd60e51b815260206004820152601560248201526000805160206200221c833981519152604482015260640162000077565b826001600160a01b038116620001105760405162461bcd60e51b815260206004820152601560248201526000805160206200221c833981519152604482015260640162000077565b6001600160a01b0380871660a052858116608052841660c052620001336200013f565b50505050505062000265565b600054610100900460ff1615620001a95760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840162000077565b60005460ff9081161015620001fc576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b03811681146200021657600080fd5b919050565b6000806000606084860312156200023157600080fd5b6200023c84620001fe565b92506200024c60208501620001fe565b91506200025c60408501620001fe565b90509250925092565b60805160a05160c051611f4f620002cd6000396000818161033601528181611112015261114c01526000818161028b01526110b20152600081816102fe01528181610558015281816105c901528181610641015281816110ec01526113050152611f4f6000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c80638da5cb5b116100b8578063cbf679191161007c578063cbf679191461036b578063cfed246b1461037e578063e24343ff14610257578063e30c39781461039e578063f2fde38b146103af578063fc57d4df146103c257600080fd5b80638da5cb5b146102e85780638dd95002146102f9578063b4a0bdf314610320578063b62e4c9214610331578063c4d66de81461035857600080fd5b80633125d3c81161010a5780633125d3c8146102575780633334ecc5146102665780635ba3792d14610286578063715018a6146102c5578063725068a5146102cd57806379ba5097146102e057600080fd5b806302459966146101475780630e32cb86146101745780631b69dc5f14610189578063234a3446146102235780632b9d9dea14610236575b600080fd5b61015a610155366004611969565b6103d5565b604080519283526020830191909152015b60405180910390f35b610187610182366004611995565b610411565b005b6101e1610197366004611995565b60c96020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919282169160ff600160a01b8204811692600160a81b909204169086565b604080516001600160a01b03978816815260208101969096529390951692840192909252151560608301521515608082015260a081019190915260c00161016b565b610187610231366004611aa3565b610425565b610249610244366004611b53565b6104ab565b60405190815260200161016b565b610249670de0b6b3a764000081565b610249610274366004611995565b60cc6020526000908152604090205481565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161016b565b6101876104da565b6102496102db366004611995565b6104ee565b610187610758565b6033546001600160a01b03166102ad565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b6097546001600160a01b03166102ad565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b610187610366366004611995565b6107cf565b610187610379366004611b53565b6108e3565b61024961038c366004611995565b60ca6020526000908152604090205481565b6065546001600160a01b03166102ad565b6101876103bd366004611995565b610c09565b6102496103d0366004611995565b610c7a565b60cb60205281600052604060002081815481106103f157600080fd5b600091825260209091206002909102018054600190910154909250905082565b610419610dd5565b61042281610e2f565b50565b805160000361046f5760405162461bcd60e51b815260206004820152601160248201527006c656e6774682063616e2774206265203607c1b60448201526064015b60405180910390fd5b805160005b818110156104a65761049e83828151811061049157610491611b6f565b60200260200101516108e3565b600101610474565b505050565b60008060006104bd8460400151610eed565b50915091508360800151156104d3579392505050565b5092915050565b6104e2610dd5565b6104ec6000611095565b565b6000806104fa836110ae565b6001600160a01b03808216600090815260c96020526040902054919250166105565760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b6044820152606401610466565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316141580156105ba57506001600160a01b038116600090815260c96020526040902060020154600160a01b900460ff165b156106d5576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260c96020526040902054166106375760405162461bcd60e51b815260206004820152600e60248201526d15d09390881b9bdd08195e1a5cdd60921b6044820152606401610466565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260c96020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a08201526106d3906111da565b505b6001600160a01b03808216600090815260c96020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a0820152610751906111da565b9392505050565b60655433906001600160a01b031681146107c65760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610466565b61042281611095565b600054610100900460ff16158080156107ef5750600054600160ff909116105b806108095750303b158015610809575060005460ff166001145b61086c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610466565b6000805460ff19166001179055801561088f576000805461ff0019166101001790555b6108988261145b565b80156108df576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b80516001600160a01b0381166109335760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b6044820152606401610466565b60408201516001600160a01b0381166109865760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b6044820152606401610466565b6109c46040518060400160405280601b81526020017f736574546f6b656e436f6e66696728546f6b656e436f6e666967290000000000815250611493565b8260a00151600003610a185760405162461bcd60e51b815260206004820152601e60248201527f616e63686f7220706572696f64206d75737420626520706f73697469766500006044820152606401610466565b82600001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7e9190611b85565b610a8990600a611ca2565b836020015114610af55760405162461bcd60e51b815260206004820152603160248201527f6261736520756e697420646563696d616c73206d7573742062652073616d6520604482015270617320617373657420646563696d616c7360781b6064820152608401610466565b6000610b00846104ab565b84516001600160a01b03908116600090815260cb6020908152604080832081518083018352428152808401878152825460018181018555938752858720925160029182029093019283559051918301919091558a518616855260c984528285208b5181549088166001600160a01b031990911681178255948c015192810192909255828b0151908201805460608d015160808e01511515600160a81b0260ff60a81b19911515600160a01b026001600160a81b03199093169490991693841791909117169690961790955560a08a0151600390910181905590519495509390917f3cc8d9cb9370a23a8b9ffa75efa24cecb65c4693980e58260841adc474983c5f91a450505050565b610c11610dd5565b606580546001600160a01b0383166001600160a01b03199091168117909155610c426033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b600080610c86836110ae565b6001600160a01b03808216600090815260c9602052604090205491925016610ce25760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b6044820152606401610466565b6001600160a01b038116600090815260ca602052604081205490819003610d4b5760405162461bcd60e51b815260206004820152601b60248201527f54574150207072696365206d75737420626520706f73697469766500000000006044820152606401610466565b816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dad9190611b85565b610db8906012611cb1565b610dc390600a611ca2565b610dcd9082611cd4565b949350505050565b6033546001600160a01b031633146104ec5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610466565b6001600160a01b038116610e935760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610466565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa091016108d6565b6000806000610efa61152d565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5e9190611cf3565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc29190611cf3565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611007573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102b9190611d23565b9250925092508363ffffffff168163ffffffff161461108b5780840363ffffffff81166110588486611543565b516001600160e01b031602969096019563ffffffff81166110798585611543565b516001600160e01b0316029590950194505b5050509193909250565b606580546001600160a01b0319169055610422816115f5565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03160361111057507f0000000000000000000000000000000000000000000000000000000000000000919050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03160361117057507f0000000000000000000000000000000000000000000000000000000000000000919050565b816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d29190611d73565b90505b919050565b6000806000806111e985611647565b92509250925080420361121857505091516001600160a01b0316600090815260ca602052604090205492915050565b804210156112685760405162461bcd60e51b815260206004820152601a60248201527f6e6f77206d75737420636f6d65206166746572206265666f72650000000000006044820152606401610466565b60008142039050600060405180602001604052808386886112899190611d90565b6112939190611dbd565b6001600160e01b03169052905060006112ab826118ae565b9050600088606001516112c657670de0b6b3a76400006112d0565b670de0b6b3a76400005b90506000818a60200151846112e59190611cd4565b6112ef9190611dbd565b905089606001511561139c576001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600090815260ca60205260408120549081900361137b5760405162461bcd60e51b8152602060048201526014602482015273189b98881c1c9a58d9481a5cc81a5b9d985b1a5960621b6044820152606401610466565b670de0b6b3a764000061138e8284611cd4565b6113989190611dbd565b9150505b806000036113e55760405162461bcd60e51b81526020600482015260166024820152750747761702070726963652063616e6e6f7420626520360541b6044820152606401610466565b89516040805183815260208101899052428183015290516001600160a01b03909216917f7d881580fb2bb7844e8ecf8df26510247c4bbea2735d40bf0d9ac33c0d9acd819181900360600190a298516001600160a01b0316600090815260ca602052604090208990555096979650505050505050565b600054610100900460ff166114825760405162461bcd60e51b815260040161046690611dd1565b61148a6118ce565b610422816118fd565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906114c69033908690600401611e69565b602060405180830381865afa1580156114e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115079190611e8d565b9050806108df57333083604051634a3fa29360e01b815260040161046693929190611eaa565b600061153e64010000000042611edf565b905090565b6040805160208101909152600081526000826001600160701b0316116115ab5760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f0000000000000000006044820152606401610466565b6040805160208101909152806115e16001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611ef3565b6001600160e01b0316905290505b92915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080600080611656856104ab565b60a0860151909150429060009061166d9083611d90565b87516001600160a01b0316600090815260cb6020908152604080832080548251818502810185019093528083529495509293909291849084015b828210156116ed578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906116a7565b505082518b516001600160a01b0316600090815260cc6020526040902054939450929150505b81811015611801578383828151811061172e5761172e611b6f565b602002602001015160000151101580611750575061174d600183611d90565b81145b156117b85782818151811061176757611767611b6f565b602002602001015160200151975082818151811061178757611787611b6f565b602090810291909101810151518b516001600160a01b0316600090815260cc90925260409091208290559650611801565b89516001600160a01b0316600090815260cb602052604090208054829081106117e3576117e3611b6f565b60009182526020822060029091020181815560010155600101611713565b5088516001600160a01b03908116600090815260cb60209081526040808320815180830183528981528084018b81528254600180820185559387529585902091516002909602909101948555519301929092558b5182518a81529182018b90524292820192909252606081018890529116907f87208a84ec7402c933c70c261e53b733a9f1c893d73e941a152435d58177a2649060800160405180910390a2509295505050509193909250565b80516000906111d2906612725dd1d243ab906001600160e01b0316611dbd565b600054610100900460ff166118f55760405162461bcd60e51b815260040161046690611dd1565b6104ec611924565b600054610100900460ff166104195760405162461bcd60e51b815260040161046690611dd1565b600054610100900460ff1661194b5760405162461bcd60e51b815260040161046690611dd1565b6104ec33611095565b6001600160a01b038116811461042257600080fd5b6000806040838503121561197c57600080fd5b823561198781611954565b946020939093013593505050565b6000602082840312156119a757600080fd5b813561075181611954565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156119f1576119f16119b2565b604052919050565b801515811461042257600080fd5b600060c08284031215611a1957600080fd5b60405160c0810181811067ffffffffffffffff82111715611a3c57611a3c6119b2565b6040529050808235611a4d81611954565b8152602083810135908201526040830135611a6781611954565b60408201526060830135611a7a816119f9565b60608201526080830135611a8d816119f9565b608082015260a092830135920191909152919050565b60006020808385031215611ab657600080fd5b823567ffffffffffffffff80821115611ace57600080fd5b818501915085601f830112611ae257600080fd5b813581811115611af457611af46119b2565b611b02848260051b016119c8565b818152848101925060c0918202840185019188831115611b2157600080fd5b938501935b82851015611b4757611b388986611a07565b84529384019392850192611b26565b50979650505050505050565b600060c08284031215611b6557600080fd5b6107518383611a07565b634e487b7160e01b600052603260045260246000fd5b600060208284031215611b9757600080fd5b815160ff8116811461075157600080fd5b634e487b7160e01b600052601160045260246000fd5b600181815b80851115611bf9578160001904821115611bdf57611bdf611ba8565b80851615611bec57918102915b93841c9390800290611bc3565b509250929050565b600082611c10575060016115ef565b81611c1d575060006115ef565b8160018114611c335760028114611c3d57611c59565b60019150506115ef565b60ff841115611c4e57611c4e611ba8565b50506001821b6115ef565b5060208310610133831016604e8410600b8410161715611c7c575081810a6115ef565b611c868383611bbe565b8060001904821115611c9a57611c9a611ba8565b029392505050565b600061075160ff841683611c01565b600060ff821660ff841680821015611ccb57611ccb611ba8565b90039392505050565b6000816000190483118215151615611cee57611cee611ba8565b500290565b600060208284031215611d0557600080fd5b5051919050565b80516001600160701b03811681146111d557600080fd5b600080600060608486031215611d3857600080fd5b611d4184611d0c565b9250611d4f60208501611d0c565b9150604084015163ffffffff81168114611d6857600080fd5b809150509250925092565b600060208284031215611d8557600080fd5b815161075181611954565b600082821015611da257611da2611ba8565b500390565b634e487b7160e01b600052601260045260246000fd5b600082611dcc57611dcc611da7565b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000815180845260005b81811015611e4257602081850181015186830182015201611e26565b81811115611e54576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090610dcd90830184611e1c565b600060208284031215611e9f57600080fd5b8151610751816119f9565b6001600160a01b03848116825283166020820152606060408201819052600090611ed690830184611e1c565b95945050505050565b600082611eee57611eee611da7565b500690565b60006001600160e01b0383811680611f0d57611f0d611da7565b9216919091049291505056fea2646970667358221220822f4f52e46661c73eda90cf732d8be4a901c69712c3f13bb4702f1bf5d18dd964736f6c634300080d003363616e2774206265207a65726f20616464726573730000000000000000000000", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101425760003560e01c80638da5cb5b116100b8578063cbf679191161007c578063cbf679191461036b578063cfed246b1461037e578063e24343ff14610257578063e30c39781461039e578063f2fde38b146103af578063fc57d4df146103c257600080fd5b80638da5cb5b146102e85780638dd95002146102f9578063b4a0bdf314610320578063b62e4c9214610331578063c4d66de81461035857600080fd5b80633125d3c81161010a5780633125d3c8146102575780633334ecc5146102665780635ba3792d14610286578063715018a6146102c5578063725068a5146102cd57806379ba5097146102e057600080fd5b806302459966146101475780630e32cb86146101745780631b69dc5f14610189578063234a3446146102235780632b9d9dea14610236575b600080fd5b61015a610155366004611969565b6103d5565b604080519283526020830191909152015b60405180910390f35b610187610182366004611995565b610411565b005b6101e1610197366004611995565b60c96020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919282169160ff600160a01b8204811692600160a81b909204169086565b604080516001600160a01b03978816815260208101969096529390951692840192909252151560608301521515608082015260a081019190915260c00161016b565b610187610231366004611aa3565b610425565b610249610244366004611b53565b6104ab565b60405190815260200161016b565b610249670de0b6b3a764000081565b610249610274366004611995565b60cc6020526000908152604090205481565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161016b565b6101876104da565b6102496102db366004611995565b6104ee565b610187610758565b6033546001600160a01b03166102ad565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b6097546001600160a01b03166102ad565b6102ad7f000000000000000000000000000000000000000000000000000000000000000081565b610187610366366004611995565b6107cf565b610187610379366004611b53565b6108e3565b61024961038c366004611995565b60ca6020526000908152604090205481565b6065546001600160a01b03166102ad565b6101876103bd366004611995565b610c09565b6102496103d0366004611995565b610c7a565b60cb60205281600052604060002081815481106103f157600080fd5b600091825260209091206002909102018054600190910154909250905082565b610419610dd5565b61042281610e2f565b50565b805160000361046f5760405162461bcd60e51b815260206004820152601160248201527006c656e6774682063616e2774206265203607c1b60448201526064015b60405180910390fd5b805160005b818110156104a65761049e83828151811061049157610491611b6f565b60200260200101516108e3565b600101610474565b505050565b60008060006104bd8460400151610eed565b50915091508360800151156104d3579392505050565b5092915050565b6104e2610dd5565b6104ec6000611095565b565b6000806104fa836110ae565b6001600160a01b03808216600090815260c96020526040902054919250166105565760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b6044820152606401610466565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316141580156105ba57506001600160a01b038116600090815260c96020526040902060020154600160a01b900460ff165b156106d5576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260c96020526040902054166106375760405162461bcd60e51b815260206004820152600e60248201526d15d09390881b9bdd08195e1a5cdd60921b6044820152606401610466565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260c96020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a08201526106d3906111da565b505b6001600160a01b03808216600090815260c96020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a0820152610751906111da565b9392505050565b60655433906001600160a01b031681146107c65760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610466565b61042281611095565b600054610100900460ff16158080156107ef5750600054600160ff909116105b806108095750303b158015610809575060005460ff166001145b61086c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610466565b6000805460ff19166001179055801561088f576000805461ff0019166101001790555b6108988261145b565b80156108df576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b80516001600160a01b0381166109335760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b6044820152606401610466565b60408201516001600160a01b0381166109865760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b6044820152606401610466565b6109c46040518060400160405280601b81526020017f736574546f6b656e436f6e66696728546f6b656e436f6e666967290000000000815250611493565b8260a00151600003610a185760405162461bcd60e51b815260206004820152601e60248201527f616e63686f7220706572696f64206d75737420626520706f73697469766500006044820152606401610466565b82600001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7e9190611b85565b610a8990600a611ca2565b836020015114610af55760405162461bcd60e51b815260206004820152603160248201527f6261736520756e697420646563696d616c73206d7573742062652073616d6520604482015270617320617373657420646563696d616c7360781b6064820152608401610466565b6000610b00846104ab565b84516001600160a01b03908116600090815260cb6020908152604080832081518083018352428152808401878152825460018181018555938752858720925160029182029093019283559051918301919091558a518616855260c984528285208b5181549088166001600160a01b031990911681178255948c015192810192909255828b0151908201805460608d015160808e01511515600160a81b0260ff60a81b19911515600160a01b026001600160a81b03199093169490991693841791909117169690961790955560a08a0151600390910181905590519495509390917f3cc8d9cb9370a23a8b9ffa75efa24cecb65c4693980e58260841adc474983c5f91a450505050565b610c11610dd5565b606580546001600160a01b0383166001600160a01b03199091168117909155610c426033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b600080610c86836110ae565b6001600160a01b03808216600090815260c9602052604090205491925016610ce25760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b6044820152606401610466565b6001600160a01b038116600090815260ca602052604081205490819003610d4b5760405162461bcd60e51b815260206004820152601b60248201527f54574150207072696365206d75737420626520706f73697469766500000000006044820152606401610466565b816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dad9190611b85565b610db8906012611cb1565b610dc390600a611ca2565b610dcd9082611cd4565b949350505050565b6033546001600160a01b031633146104ec5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610466565b6001600160a01b038116610e935760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610466565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa091016108d6565b6000806000610efa61152d565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5e9190611cf3565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc29190611cf3565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611007573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102b9190611d23565b9250925092508363ffffffff168163ffffffff161461108b5780840363ffffffff81166110588486611543565b516001600160e01b031602969096019563ffffffff81166110798585611543565b516001600160e01b0316029590950194505b5050509193909250565b606580546001600160a01b0319169055610422816115f5565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03160361111057507f0000000000000000000000000000000000000000000000000000000000000000919050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03160361117057507f0000000000000000000000000000000000000000000000000000000000000000919050565b816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d29190611d73565b90505b919050565b6000806000806111e985611647565b92509250925080420361121857505091516001600160a01b0316600090815260ca602052604090205492915050565b804210156112685760405162461bcd60e51b815260206004820152601a60248201527f6e6f77206d75737420636f6d65206166746572206265666f72650000000000006044820152606401610466565b60008142039050600060405180602001604052808386886112899190611d90565b6112939190611dbd565b6001600160e01b03169052905060006112ab826118ae565b9050600088606001516112c657670de0b6b3a76400006112d0565b670de0b6b3a76400005b90506000818a60200151846112e59190611cd4565b6112ef9190611dbd565b905089606001511561139c576001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600090815260ca60205260408120549081900361137b5760405162461bcd60e51b8152602060048201526014602482015273189b98881c1c9a58d9481a5cc81a5b9d985b1a5960621b6044820152606401610466565b670de0b6b3a764000061138e8284611cd4565b6113989190611dbd565b9150505b806000036113e55760405162461bcd60e51b81526020600482015260166024820152750747761702070726963652063616e6e6f7420626520360541b6044820152606401610466565b89516040805183815260208101899052428183015290516001600160a01b03909216917f7d881580fb2bb7844e8ecf8df26510247c4bbea2735d40bf0d9ac33c0d9acd819181900360600190a298516001600160a01b0316600090815260ca602052604090208990555096979650505050505050565b600054610100900460ff166114825760405162461bcd60e51b815260040161046690611dd1565b61148a6118ce565b610422816118fd565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906114c69033908690600401611e69565b602060405180830381865afa1580156114e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115079190611e8d565b9050806108df57333083604051634a3fa29360e01b815260040161046693929190611eaa565b600061153e64010000000042611edf565b905090565b6040805160208101909152600081526000826001600160701b0316116115ab5760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f0000000000000000006044820152606401610466565b6040805160208101909152806115e16001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611ef3565b6001600160e01b0316905290505b92915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080600080611656856104ab565b60a0860151909150429060009061166d9083611d90565b87516001600160a01b0316600090815260cb6020908152604080832080548251818502810185019093528083529495509293909291849084015b828210156116ed578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906116a7565b505082518b516001600160a01b0316600090815260cc6020526040902054939450929150505b81811015611801578383828151811061172e5761172e611b6f565b602002602001015160000151101580611750575061174d600183611d90565b81145b156117b85782818151811061176757611767611b6f565b602002602001015160200151975082818151811061178757611787611b6f565b602090810291909101810151518b516001600160a01b0316600090815260cc90925260409091208290559650611801565b89516001600160a01b0316600090815260cb602052604090208054829081106117e3576117e3611b6f565b60009182526020822060029091020181815560010155600101611713565b5088516001600160a01b03908116600090815260cb60209081526040808320815180830183528981528084018b81528254600180820185559387529585902091516002909602909101948555519301929092558b5182518a81529182018b90524292820192909252606081018890529116907f87208a84ec7402c933c70c261e53b733a9f1c893d73e941a152435d58177a2649060800160405180910390a2509295505050509193909250565b80516000906111d2906612725dd1d243ab906001600160e01b0316611dbd565b600054610100900460ff166118f55760405162461bcd60e51b815260040161046690611dd1565b6104ec611924565b600054610100900460ff166104195760405162461bcd60e51b815260040161046690611dd1565b600054610100900460ff1661194b5760405162461bcd60e51b815260040161046690611dd1565b6104ec33611095565b6001600160a01b038116811461042257600080fd5b6000806040838503121561197c57600080fd5b823561198781611954565b946020939093013593505050565b6000602082840312156119a757600080fd5b813561075181611954565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156119f1576119f16119b2565b604052919050565b801515811461042257600080fd5b600060c08284031215611a1957600080fd5b60405160c0810181811067ffffffffffffffff82111715611a3c57611a3c6119b2565b6040529050808235611a4d81611954565b8152602083810135908201526040830135611a6781611954565b60408201526060830135611a7a816119f9565b60608201526080830135611a8d816119f9565b608082015260a092830135920191909152919050565b60006020808385031215611ab657600080fd5b823567ffffffffffffffff80821115611ace57600080fd5b818501915085601f830112611ae257600080fd5b813581811115611af457611af46119b2565b611b02848260051b016119c8565b818152848101925060c0918202840185019188831115611b2157600080fd5b938501935b82851015611b4757611b388986611a07565b84529384019392850192611b26565b50979650505050505050565b600060c08284031215611b6557600080fd5b6107518383611a07565b634e487b7160e01b600052603260045260246000fd5b600060208284031215611b9757600080fd5b815160ff8116811461075157600080fd5b634e487b7160e01b600052601160045260246000fd5b600181815b80851115611bf9578160001904821115611bdf57611bdf611ba8565b80851615611bec57918102915b93841c9390800290611bc3565b509250929050565b600082611c10575060016115ef565b81611c1d575060006115ef565b8160018114611c335760028114611c3d57611c59565b60019150506115ef565b60ff841115611c4e57611c4e611ba8565b50506001821b6115ef565b5060208310610133831016604e8410600b8410161715611c7c575081810a6115ef565b611c868383611bbe565b8060001904821115611c9a57611c9a611ba8565b029392505050565b600061075160ff841683611c01565b600060ff821660ff841680821015611ccb57611ccb611ba8565b90039392505050565b6000816000190483118215151615611cee57611cee611ba8565b500290565b600060208284031215611d0557600080fd5b5051919050565b80516001600160701b03811681146111d557600080fd5b600080600060608486031215611d3857600080fd5b611d4184611d0c565b9250611d4f60208501611d0c565b9150604084015163ffffffff81168114611d6857600080fd5b809150509250925092565b600060208284031215611d8557600080fd5b815161075181611954565b600082821015611da257611da2611ba8565b500390565b634e487b7160e01b600052601260045260246000fd5b600082611dcc57611dcc611da7565b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000815180845260005b81811015611e4257602081850181015186830182015201611e26565b81811115611e54576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090610dcd90830184611e1c565b600060208284031215611e9f57600080fd5b8151610751816119f9565b6001600160a01b03848116825283166020820152606060408201819052600090611ed690830184611e1c565b95945050505050565b600082611eee57611eee611da7565b500690565b60006001600160e01b0383811680611f0d57611f0d611da7565b9216919091049291505056fea2646970667358221220822f4f52e46661c73eda90cf732d8be4a901c69712c3f13bb4702f1bf5d18dd964736f6c634300080d0033", - "devdoc": { - "kind": "dev", - "methods": { - "acceptOwnership()": { - "details": "The new owner accepts the ownership transfer." - }, - "constructor": { - "custom:oz-upgrades-unsafe-allow": "constructor", - "params": { - "vBnbAddress": "The address of the VBNB", - "vaiAddress": "The address of the WBNB", - "wBnbAddress": "The address of the WBNB" - } - }, - "currentCumulativePrice((address,uint256,address,bool,bool,uint256))": { - "returns": { - "_0": "cumulative price of target token regardless of pair order" - } - }, - "getUnderlyingPrice(address)": { - "custom:error": "Missing error is thrown if the token config does not existRange error is thrown if TWAP price is not greater than zero", - "params": { - "vToken": "vToken address" - }, - "returns": { - "_0": "price Underlying price in USD" - } - }, - "initialize(address)": { - "params": { - "accessControlManager_": "Address of the access control manager contract" - } - }, - "owner()": { - "details": "Returns the address of the current owner." - }, - "pendingOwner()": { - "details": "Returns the address of the pending owner." - }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." - }, - "setAccessControlManager(address)": { - "custom:access": "Only Governance", - "custom:event": "Emits NewAccessControlManager event", - "details": "Admin function to set address of AccessControlManager", - "params": { - "accessControlManager_": "The new address of the AccessControlManager" - } - }, - "setTokenConfig((address,uint256,address,bool,bool,uint256))": { - "custom:access": "Only Governance", - "custom:error": "Range error is thrown if anchor period is not greater than zeroRange error is thrown if base unit is not greater than zeroValue error is thrown if base unit decimals is not the same as asset decimalsNotNullAddress error is thrown if address of asset is nullNotNullAddress error is thrown if PancakeSwap pool address is null", - "custom:event": "Emits TokenConfigAdded event if new token config are added with asset address, PancakePool address, anchor period address", - "params": { - "config": "token config struct" - } - }, - "setTokenConfigs((address,uint256,address,bool,bool,uint256)[])": { - "custom:error": "Zero length error thrown, if length of the config array is 0", - "params": { - "configs": "Config array" - } - }, - "transferOwnership(address)": { - "details": "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." - }, - "updateTwap(address)": { - "custom:error": "Missing error is thrown if token config does not exist", - "returns": { - "_0": "anchorPrice anchor price of the underlying asset of the vToken" - } - } - }, - "stateVariables": { - "WBNB": { - "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" - }, - "vBnb": { - "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" - }, - "vai": { - "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" - } - }, - "version": 1 - }, - "userdoc": { - "errors": { - "Unauthorized(address,address,string)": [ - { - "notice": "Thrown when the action is prohibited by AccessControlManager" - } - ] - }, - "events": { - "AnchorPriceUpdated(address,uint256,uint256,uint256)": { - "notice": "Emit this event when TWAP price is updated" - }, - "NewAccessControlManager(address,address)": { - "notice": "Emitted when access control manager contract address is changed" - }, - "TokenConfigAdded(address,address,uint256)": { - "notice": "Emit this event when new token configs are added" - }, - "TwapWindowUpdated(address,uint256,uint256,uint256,uint256)": { - "notice": "Emit this event when TWAP window is updated" - } - }, - "kind": "user", - "methods": { - "BNB_BASE_UNIT()": { - "notice": "the base unit of WBNB and BUSD, which are the paired tokens for all assets" - }, - "WBNB()": { - "notice": "WBNB address" - }, - "accessControlManager()": { - "notice": "Returns the address of the access control manager contract" - }, - "constructor": { - "notice": "Constructor for the implementation contract. Sets immutable variables." - }, - "currentCumulativePrice((address,uint256,address,bool,bool,uint256))": { - "notice": "Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap." - }, - "getUnderlyingPrice(address)": { - "notice": "Get the underlying TWAP price for the given vToken" - }, - "initialize(address)": { - "notice": "Initializes the owner of the contract" - }, - "observations(address,uint256)": { - "notice": "Keeps a record of token observations mapped by address, updated on every updateTwap invocation." - }, - "prices(address)": { - "notice": "Stored price by token" - }, - "setAccessControlManager(address)": { - "notice": "Sets the address of AccessControlManager" - }, - "setTokenConfig((address,uint256,address,bool,bool,uint256))": { - "notice": "Adds a single token config" - }, - "setTokenConfigs((address,uint256,address,bool,bool,uint256)[])": { - "notice": "Adds multiple token configs at the same time" - }, - "tokenConfigs(address)": { - "notice": "Configs by token" - }, - "updateTwap(address)": { - "notice": "Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision." - }, - "vBnb()": { - "notice": "vBNB address" - }, - "vai()": { - "notice": "VAI address" - }, - "windowStart(address)": { - "notice": "Observation array index which probably falls in current anchor period mapped by asset address" - } - }, - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 290, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "_initialized", - "offset": 0, - "slot": "0", - "type": "t_uint8" - }, - { - "astId": 293, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "_initializing", - "offset": 1, - "slot": "0", - "type": "t_bool" - }, - { - "astId": 904, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "__gap", - "offset": 0, - "slot": "1", - "type": "t_array(t_uint256)50_storage" - }, - { - "astId": 162, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "_owner", - "offset": 0, - "slot": "51", - "type": "t_address" - }, - { - "astId": 282, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "__gap", - "offset": 0, - "slot": "52", - "type": "t_array(t_uint256)49_storage" - }, - { - "astId": 71, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "_pendingOwner", - "offset": 0, - "slot": "101", - "type": "t_address" - }, - { - "astId": 150, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "__gap", - "offset": 0, - "slot": "102", - "type": "t_array(t_uint256)49_storage" - }, - { - "astId": 2741, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "_accessControlManager", - "offset": 0, - "slot": "151", - "type": "t_contract(IAccessControlManagerV8)2925" - }, - { - "astId": 2746, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "__gap", - "offset": 0, - "slot": "152", - "type": "t_array(t_uint256)49_storage" - }, - { - "astId": 6159, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "tokenConfigs", - "offset": 0, - "slot": "201", - "type": "t_mapping(t_address,t_struct(TokenConfig)6137_storage)" - }, - { - "astId": 6164, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "prices", - "offset": 0, - "slot": "202", - "type": "t_mapping(t_address,t_uint256)" - }, - { - "astId": 6171, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "observations", - "offset": 0, - "slot": "203", - "type": "t_mapping(t_address,t_array(t_struct(Observation)6118_storage)dyn_storage)" - }, - { - "astId": 6176, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "windowStart", - "offset": 0, - "slot": "204", - "type": "t_mapping(t_address,t_uint256)" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_struct(Observation)6118_storage)dyn_storage": { - "base": "t_struct(Observation)6118_storage", - "encoding": "dynamic_array", - "label": "struct TwapOracle.Observation[]", - "numberOfBytes": "32" - }, - "t_array(t_uint256)49_storage": { - "base": "t_uint256", - "encoding": "inplace", - "label": "uint256[49]", - "numberOfBytes": "1568" - }, - "t_array(t_uint256)50_storage": { - "base": "t_uint256", - "encoding": "inplace", - "label": "uint256[50]", - "numberOfBytes": "1600" - }, - "t_bool": { - "encoding": "inplace", - "label": "bool", - "numberOfBytes": "1" - }, - "t_contract(IAccessControlManagerV8)2925": { - "encoding": "inplace", - "label": "contract IAccessControlManagerV8", - "numberOfBytes": "20" - }, - "t_mapping(t_address,t_array(t_struct(Observation)6118_storage)dyn_storage)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => struct TwapOracle.Observation[])", - "numberOfBytes": "32", - "value": "t_array(t_struct(Observation)6118_storage)dyn_storage" - }, - "t_mapping(t_address,t_struct(TokenConfig)6137_storage)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => struct TwapOracle.TokenConfig)", - "numberOfBytes": "32", - "value": "t_struct(TokenConfig)6137_storage" - }, - "t_mapping(t_address,t_uint256)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_struct(Observation)6118_storage": { - "encoding": "inplace", - "label": "struct TwapOracle.Observation", - "members": [ - { - "astId": 6115, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "timestamp", - "offset": 0, - "slot": "0", - "type": "t_uint256" - }, - { - "astId": 6117, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "acc", - "offset": 0, - "slot": "1", - "type": "t_uint256" - } - ], - "numberOfBytes": "64" - }, - "t_struct(TokenConfig)6137_storage": { - "encoding": "inplace", - "label": "struct TwapOracle.TokenConfig", - "members": [ - { - "astId": 6121, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "asset", - "offset": 0, - "slot": "0", - "type": "t_address" - }, - { - "astId": 6124, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "baseUnit", - "offset": 0, - "slot": "1", - "type": "t_uint256" - }, - { - "astId": 6127, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "pancakePool", - "offset": 0, - "slot": "2", - "type": "t_address" - }, - { - "astId": 6130, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "isBnbBased", - "offset": 20, - "slot": "2", - "type": "t_bool" - }, - { - "astId": 6133, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "isReversedPool", - "offset": 21, - "slot": "2", - "type": "t_bool" - }, - { - "astId": 6136, - "contract": "contracts/oracles/TwapOracle.sol:TwapOracle", - "label": "anchorPeriod", - "offset": 0, - "slot": "3", - "type": "t_uint256" - } - ], - "numberOfBytes": "128" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - }, - "t_uint8": { - "encoding": "inplace", - "label": "uint8", - "numberOfBytes": "1" - } - } - } -} diff --git a/deployments/bsctestnet/solcInputs/131f58942628e21632de19506977a910.json b/deployments/bsctestnet/solcInputs/131f58942628e21632de19506977a910.json index a39691f5..08b63256 100644 --- a/deployments/bsctestnet/solcInputs/131f58942628e21632de19506977a910.json +++ b/deployments/bsctestnet/solcInputs/131f58942628e21632de19506977a910.json @@ -82,9 +82,6 @@ "contracts/oracles/PythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"../interfaces/PythInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores the\n * updated prices from external sources\n */\ncontract PythOracle is AccessControlledV8, OracleInterface {\n // To calculate 10 ** n(which is a signed type)\n using SignedMath for int256;\n\n // To cast int64/int8 types from Pyth to unsigned types\n using SafeCast for int256;\n\n struct TokenConfig {\n bytes32 pythId;\n address asset;\n uint64 maxStalePeriod;\n }\n\n /// @notice Exponent scale (decimal precision) of prices\n uint256 public constant EXP_SCALE = 1e18;\n\n /// @notice vBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vBnb;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice The actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n /// @notice Token configs by asset address\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when setting a new pyth oracle address\n event PythOracleSet(address indexed oldPythOracle, address indexed newPythOracle);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed vToken, bytes32 indexed pythId, uint64 indexed maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param vBnbAddress The address of the vBNB\n /// @param vaiAddress The address of the VAI\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address vBnbAddress, address vaiAddress) notNullAddress(vBnbAddress) notNullAddress(vaiAddress) {\n vBnb = vBnbAddress;\n vai = vaiAddress;\n _disableInitializers();\n }\n\n /**\n * @notice Batch set token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the underlying Pyth oracle contract address\n * @param underlyingPythOracle_ Pyth oracle contract address\n * @custom:access Only Governance\n * @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero\n * @custom:event Emits PythOracleSet event with address of Pyth oracle.\n */\n function setUnderlyingPythOracle(\n IPyth underlyingPythOracle_\n ) external notNullAddress(address(underlyingPythOracle_)) {\n _checkAccessAllowed(\"setUnderlyingPythOracle(address)\");\n IPyth oldUnderlyingPythOracle = underlyingPythOracle;\n underlyingPythOracle = underlyingPythOracle_;\n emit PythOracleSet(address(oldUnderlyingPythOracle), address(underlyingPythOracle_));\n }\n\n /**\n * @notice Initializes the owner of the contract and sets required contracts\n * @param underlyingPythOracle_ Address of the Pyth oracle\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(\n address underlyingPythOracle_,\n address accessControlManager_\n ) external initializer notNullAddress(underlyingPythOracle_) {\n __AccessControlled_init(accessControlManager_);\n\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n emit PythOracleSet(address(0), underlyingPythOracle_);\n }\n\n /**\n * @notice Get price of underlying asset of the input vToken, under the hood this function\n * get price from Pyth contract, the prices of which are updated externally\n * @param vToken vToken address\n * @return price Underlying price with a precision of 18 decimals\n * @custom:error Zero address error thrown if underlyingPythOracle address is null\n * @custom:error Zero address error thrown if asset address is null\n * @custom:error Range error thrown if price of Pyth oracle is not greater than zero\n */\n function getUnderlyingPrice(\n address vToken\n ) external view override notNullAddress(address(underlyingPythOracle)) returns (uint256) {\n address asset;\n uint256 decimals;\n\n // VBNB token doesn't have `underlying` method\n if (vToken == vBnb) {\n asset = BNB_ADDR;\n decimals = 18;\n } else if (vToken == vai) {\n asset = vai;\n decimals = 18;\n } else {\n asset = VBep20Interface(vToken).underlying();\n decimals = VBep20Interface(asset).decimals();\n }\n\n TokenConfig storage tokenConfig = tokenConfigs[asset];\n if (tokenConfig.asset == address(0)) revert(\"asset doesn't exist\");\n\n // if the price is expired after it's compared against `maxStalePeriod`, the following call will revert\n PythStructs.Price memory priceInfo = underlyingPythOracle.getPriceNoOlderThan(\n tokenConfig.pythId,\n tokenConfig.maxStalePeriod\n );\n\n uint256 price = int256(priceInfo.price).toUint256();\n\n if (price == 0) revert(\"invalid pyth oracle price\");\n\n // the price returned from Pyth is price ** 10^expo, which is the real dollar price of the assets\n // we need to multiply it by 1e18 to make the price 18 decimals\n if (priceInfo.expo > 0) {\n return price * EXP_SCALE * (10 ** int256(priceInfo.expo).toUint256()) * (10 ** (18 - decimals));\n } else {\n return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));\n }\n }\n\n /**\n * @notice Set single token config. `maxStalePeriod` cannot be 0 and `vToken` can be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if max stale period is zero\n * @custom:error NotNullAddress error is thrown if asset address is null\n */\n function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n if (tokenConfig.maxStalePeriod == 0) revert(\"max stale period cannot be 0\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);\n }\n}\n" }, - "contracts/oracles/TwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../libraries/PancakeLibrary.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\ncontract TwapOracle is AccessControlledV8, TwapInterface {\n using FixedPoint for *;\n\n struct Observation {\n uint256 timestamp;\n uint256 acc;\n }\n\n struct TokenConfig {\n /// @notice Asset address, which can't be zero address and can be used for existance check\n address asset;\n /// @notice Decimals of underlying asset respresented as 1e{decimals}\n uint256 baseUnit;\n /// @notice The address of Pancake pair\n address pancakePool;\n /// @notice Whether the token is paired with WBNB\n bool isBnbBased;\n /// @notice A flag identifies whether the Pancake pair is reversed\n /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not.\n bool isReversedPool;\n /// @notice The minimum window in seconds required between TWAP updates\n uint256 anchorPeriod;\n }\n\n /// @notice WBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WBNB;\n\n /// @notice vBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vBnb;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\n uint256 public constant BNB_BASE_UNIT = 1e18;\n uint256 public constant BUSD_BASE_UNIT = 1e18;\n\n /// @notice Configs by token\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Stored price by token\n mapping(address => uint256) public prices;\n\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\n mapping(address => Observation[]) public observations;\n\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\n mapping(address => uint256) public windowStart;\n\n /// @notice Emit this event when TWAP window is updated\n event TwapWindowUpdated(\n address indexed asset,\n uint256 oldTimestamp,\n uint256 oldAcc,\n uint256 newTimestamp,\n uint256 newAcc\n );\n\n /// @notice Emit this event when TWAP price is updated\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\n\n /// @notice Emit this event when new token configs are added\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param vBnbAddress The address of the VBNB\n /// @param wBnbAddress The address of the WBNB\n /// @param vaiAddress The address of the WBNB\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address vBnbAddress,\n address wBnbAddress,\n address vaiAddress\n ) notNullAddress(vBnbAddress) notNullAddress(wBnbAddress) notNullAddress(vaiAddress) {\n vBnb = vBnbAddress;\n WBNB = wBnbAddress;\n vai = vaiAddress;\n _disableInitializers();\n }\n\n /**\n * @notice Adds multiple token configs at the same time\n * @param configs Config array\n * @custom:error Zero length error thrown, if length of the config array is 0\n */\n function setTokenConfigs(TokenConfig[] memory configs) external {\n if (configs.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = configs.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(configs[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return anchorPrice anchor price of the underlying asset of the vToken\n * @custom:error Missing error is thrown if token config does not exist\n */\n function updateTwap(address vToken) external returns (uint256) {\n address asset = _getUnderlyingAsset(vToken);\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\n if (tokenConfigs[WBNB].asset == address(0)) revert(\"WBNB not exist\");\n _updateTwapInternal(tokenConfigs[WBNB]);\n }\n return _updateTwapInternal(tokenConfigs[asset]);\n }\n\n /**\n * @notice Get the underlying TWAP price for the given vToken\n * @param vToken vToken address\n * @return price Underlying price in USD\n * @custom:error Missing error is thrown if the token config does not exist\n * @custom:error Range error is thrown if TWAP price is not greater than zero\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n address asset = _getUnderlyingAsset(vToken);\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n uint256 price = prices[asset];\n\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\n if (price == 0) revert(\"TWAP price must be positive\");\n return (price * (10 ** (18 - IERC20Metadata(asset).decimals())));\n }\n\n /**\n * @notice Adds a single token config\n * @param config token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if anchor period is not greater than zero\n * @custom:error Range error is thrown if base unit is not greater than zero\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\n * @custom:error NotNullAddress error is thrown if address of asset is null\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\n * @custom:event Emits TokenConfigAdded event if new token config are added with\n * asset address, PancakePool address, anchor period address\n */\n function setTokenConfig(\n TokenConfig memory config\n ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n if (config.anchorPeriod == 0) revert(\"anchor period must be positive\");\n if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals())\n revert(\"base unit decimals must be same as asset decimals\");\n\n uint256 cumulativePrice = currentCumulativePrice(config);\n\n // Initialize observation data\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\n tokenConfigs[config.asset] = config;\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\n }\n\n /**\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\n * @return cumulative price of target token regardless of pair order\n */\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\n if (config.isReversedPool) {\n return price1;\n } else {\n return price0;\n }\n }\n\n /**\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return price Underlying price in USD, with 18 decimals\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\n * AnchorPrice, old observation timestamp and current timestamp\n */\n function _updateTwapInternal(TokenConfig memory config) private returns (uint256) {\n // pokeWindowValues already handled reversed pool cases,\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\n\n if (block.timestamp == oldTimestamp) return prices[config.asset];\n\n // This should be impossible, but better safe than sorry\n if (block.timestamp < oldTimestamp) revert(\"now must come after before\");\n\n uint256 timeElapsed;\n unchecked {\n timeElapsed = block.timestamp - oldTimestamp;\n }\n\n // Calculate Pancake *twap**\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\n );\n // *twap** price with 1e18 decimal mantissa\n uint256 priceAverageMantissa = priceAverage.decode112with18();\n\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\n // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18)\n uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT;\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\n\n // if this token is paired with BNB, convert its price to USD\n if (config.isBnbBased) {\n uint256 bnbPrice = prices[WBNB];\n if (bnbPrice == 0) revert(\"bnb price is invalid\");\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT;\n }\n\n if (anchorPriceMantissa == 0) revert(\"twap price cannot be 0\");\n\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\n\n // save anchor price, which is 1e18 decimals\n prices[config.asset] = anchorPriceMantissa;\n\n return anchorPriceMantissa;\n }\n\n /**\n * @notice Appends current observation and pick an observation with a timestamp equal\n * or just greater than the window start timestamp. If one is not available,\n * then pick the last availableobservation. The window start index is updated in both the cases.\n * Only the current observation is saved, prior observations are deleted during this operation.\n * @return Tuple of cumulative price, old observation and timestamp\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\n * new observation timestamp, current timestamp, new observation price and cumulative price\n */\n function pokeWindowValues(\n TokenConfig memory config\n ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\n uint256 cumulativePrice = currentCumulativePrice(config);\n uint256 currentTimestamp = block.timestamp;\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\n Observation[] memory storedObservations = observations[config.asset];\n\n uint256 storedObservationsLength = storedObservations.length;\n for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) {\n if (\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\n (windowStartIndex == storedObservationsLength - 1)\n ) {\n startCumulativePrice = storedObservations[windowStartIndex].acc;\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\n windowStart[config.asset] = windowStartIndex;\n break;\n } else {\n delete observations[config.asset][windowStartIndex];\n }\n\n unchecked {\n ++windowStartIndex;\n }\n }\n\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\n emit TwapWindowUpdated(\n config.asset,\n startCumulativeTimestamp,\n startCumulativePrice,\n block.timestamp,\n cumulativePrice\n );\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view returns (address asset) {\n if (vToken == vBnb) {\n asset = WBNB;\n } else if (vToken == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" - }, "contracts/ResilientOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n /**\n * @dev Oracle roles:\n * **main**: The most trustworthy price source\n * **pivot**: Price oracle used as a loose sanity checker\n * **fallback**: The backup source when main oracle price is invalidated\n */\n enum OracleRole {\n MAIN,\n PIVOT,\n FALLBACK\n }\n\n struct TokenConfig {\n /// @notice asset address\n address asset;\n /// @notice `oracles` stores the oracles based on their role in the following order:\n /// [main, pivot, fallback],\n /// It can be indexed with the corresponding enum OracleRole value\n address[3] oracles;\n /// @notice `enableFlagsForOracles` stores the enabled state\n /// for each oracle in the same order as `oracles`\n bool[3] enableFlagsForOracles;\n }\n\n uint256 public constant INVALID_PRICE = 0;\n\n /// @notice vBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vBnb;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n BoundValidatorInterface public immutable boundValidator;\n\n mapping(address => TokenConfig) private tokenConfigs;\n\n event TokenConfigAdded(\n address indexed asset,\n address indexed mainOracle,\n address indexed pivotOracle,\n address fallbackOracle\n );\n\n /// Event emitted when an oracle is set\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n /// Event emitted when an oracle is enabled or disabled\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /**\n * @notice Checks whether token config exists by checking whether vToken is null address\n * @dev vToken can't be null, so it's suitable to be used to check the validity of the config\n * @param asset asset address\n */\n modifier checkTokenConfigExistence(address asset) {\n if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param vBnbAddress The address of the vBNB\n /// @param vaiAddress The address of the VAI\n /// @param _boundValidator Address of the bound validator contract\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address vBnbAddress, address vaiAddress, BoundValidatorInterface _boundValidator\n ) notNullAddress(vBnbAddress) notNullAddress(vaiAddress) notNullAddress(address(_boundValidator)) {\n vBnb = vBnbAddress;\n vai = vaiAddress;\n boundValidator = _boundValidator;\n\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract admin and sets the BoundValidator contract address\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n }\n\n /**\n * @notice Pauses oracle\n * @custom:access Only Governance\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n _pause();\n }\n\n /**\n * @notice Unpauses oracle\n * @custom:access Only Governance\n */\n function unpause() external {\n _checkAccessAllowed(\"unpause()\");\n _unpause();\n }\n\n /**\n * @notice Batch sets token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Throws a length error if the length of the token configs array is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Sets oracle for a given vToken and role.\n * @dev Supplied vToken **must** exist and main oracle may not be null\n * @param asset Asset address\n * @param oracle Oracle address\n * @param role Oracle role\n * @custom:access Only Governance\n * @custom:error Null address error if main-role oracle address is null\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n */\n function setOracle(\n address asset,\n address oracle,\n OracleRole role\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\n emit OracleSet(asset, oracle, uint256(role));\n }\n\n /**\n * @notice Enables/ disables oracle for the input vToken, input vToken **must** exist\n * @param asset Asset address\n * @param role Oracle role\n * @param enable Enabled boolean of the oracle\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n */\n function enableOracle(\n address asset,\n OracleRole role,\n bool enable\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n emit OracleEnabled(asset, uint256(role), enable);\n }\n\n /**\n * @notice Updates the TWAP pivot oracle price.\n * @dev This function should always be called before calling getUnderlyingPrice\n * @param vToken vToken address\n */\n function updatePrice(address vToken) external override {\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(vToken, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(vToken) {} catch {}\n }\n }\n\n /**\n * @dev Gets token config by vToken address\n * @param vToken vToken address\n * @return tokenConfig Config for the vToken\n */\n function getTokenConfig(address vToken) external view returns (TokenConfig memory) {\n address asset = _getUnderlyingAsset(vToken);\n return tokenConfigs[asset];\n }\n\n /**\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n * - Check if the oracle is paused globally\n * - Validate price from main oracle against pivot oracle\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\n * - Validate price from main oracle against fallback oracle if the second validation failed\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\n * main oracle price is returned.\n * @param vToken vToken address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n uint256 pivotPrice = INVALID_PRICE;\n\n // Get pivot oracle price, Invalid price if not available or error\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(vToken, OracleRole.PIVOT);\n if (pivotOracleEnabled && pivotOracle != address(0)) {\n try OracleInterface(pivotOracle).getUnderlyingPrice(vToken) returns (uint256 pricePivot) {\n pivotPrice = pricePivot;\n } catch {}\n }\n\n // Compare main price and pivot price, return main price and if validation was successful\n // note: In case pivot oracle is not available but main price is available and\n // validation is successful, the main oracle price is returned.\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n vToken,\n pivotPrice,\n pivotOracleEnabled && pivotOracle != address(0)\n );\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n // Compare fallback and pivot if main oracle comparision fails with pivot\n // Return fallback price when fallback price is validated successfully with pivot oracle\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(vToken, pivotPrice);\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n // Lastly compare main price and fallback price\n if (\n mainPrice != INVALID_PRICE &&\n fallbackPrice != INVALID_PRICE &&\n boundValidator.validatePriceWithAnchorPrice(vToken, mainPrice, fallbackPrice)\n ) {\n return mainPrice;\n }\n\n revert(\"invalid resilient oracle price\");\n }\n\n /**\n * @notice Sets/resets single token configs.\n * @dev main oracle **must not** be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress is thrown if asset address is null\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n * @custom:event Emits TokenConfigAdded event when vToken config is set successfully by governnace\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(\n tokenConfig.asset,\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n );\n }\n\n /**\n * @notice Gets oracle and enabled status by vToken address\n * @param vToken vToken address\n * @param role Oracle role\n * @return oracle Oracle address based on role\n * @return enabled Enabled flag of the oracle based on token config\n */\n function getOracle(address vToken, OracleRole role) public view returns (address oracle, bool enabled) {\n address asset = _getUnderlyingAsset(vToken);\n\n oracle = tokenConfigs[asset].oracles[uint256(role)];\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n }\n\n /**\n * @notice Gets underlying asset price for the provided vToken\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\n * able to fetch a correct price\n * @param vToken vToken address\n * @param pivotPrice Pivot oracle price\n * @param pivotEnabled If pivot oracle is not empty and enabled\n * @return price USD price in scaled decimals\n * e.g. vToken decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n * @return pivotValidated Boolean representing if the validation of main oracle price\n * and pivot oracle price were successful\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of underlying asset\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n * address is null\n */\n function _getMainOraclePrice(\n address vToken,\n uint256 pivotPrice,\n bool pivotEnabled\n ) private view returns (uint256, bool) {\n (address mainOracle, bool mainOracleEnabled) = getOracle(vToken, OracleRole.MAIN);\n if (mainOracleEnabled && mainOracle != address(0)) {\n try OracleInterface(mainOracle).getUnderlyingPrice(vToken) returns (uint256 mainOraclePrice) {\n if (!pivotEnabled) {\n return (mainOraclePrice, true);\n }\n if (pivotPrice == INVALID_PRICE) {\n return (mainOraclePrice, false);\n }\n return (\n mainOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(vToken, mainOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function won't revert when the price is 0 because getUnderlyingPrice checks if price is > 0\n * @param vToken vToken address\n * @return price USD price in 18 decimals\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\n * and pivot oracle price were successfull\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of underlying asset\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n * address is null\n */\n function _getFallbackOraclePrice(address vToken, uint256 pivotPrice) private view returns (uint256, bool) {\n (address fallbackOracle, bool fallbackEnabled) = getOracle(vToken, OracleRole.FALLBACK);\n if (fallbackEnabled && fallbackOracle != address(0)) {\n try OracleInterface(fallbackOracle).getUnderlyingPrice(vToken) returns (uint256 fallbackOraclePrice) {\n if (pivotPrice == INVALID_PRICE) {\n return (fallbackOraclePrice, false);\n }\n return (\n fallbackOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(vToken, fallbackOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view returns (address asset) {\n if (address(vToken) == vBnb) {\n asset = BNB_ADDR;\n } else if (address(vToken) == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" } diff --git a/deployments/bsctestnet/solcInputs/d647123072ba05451b756817f39951df.json b/deployments/bsctestnet/solcInputs/d647123072ba05451b756817f39951df.json index bf3ce92a..ecff34e1 100644 --- a/deployments/bsctestnet/solcInputs/d647123072ba05451b756817f39951df.json +++ b/deployments/bsctestnet/solcInputs/d647123072ba05451b756817f39951df.json @@ -109,15 +109,9 @@ "contracts/oracles/mocks/MockPythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { IPyth } from \"../PythOracle.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockPythOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice the actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n function initialize(address underlyingPythOracle_) public initializer {\n __Ownable_init();\n if (underlyingPythOracle_ == address(0)) revert(\"pyth oracle cannot be zero address\");\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" }, - "contracts/oracles/mocks/MockTwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockTwapOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice vBNB address\n address public vBNB;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n function initialize(address vBNB_) public initializer {\n __Ownable_init();\n if (vBNB_ == address(0)) revert(\"vBNB can't be zero address\");\n vBNB = vBNB_;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" - }, "contracts/oracles/PythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"../interfaces/PythInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title PythOracle\n * @author Venus\n * @notice PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores\n * the updated prices from external sources\n */\ncontract PythOracle is AccessControlledV8, OracleInterface {\n // To calculate 10 ** n(which is a signed type)\n using SignedMath for int256;\n\n // To cast int64/int8 types from Pyth to unsigned types\n using SafeCast for int256;\n\n struct TokenConfig {\n bytes32 pythId;\n address asset;\n uint64 maxStalePeriod;\n }\n\n /// @notice Exponent scale (decimal precision) of prices\n uint256 public constant EXP_SCALE = 1e18;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice The actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n /// @notice Token configs by asset address\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when setting a new pyth oracle address\n event PythOracleSet(address indexed oldPythOracle, address indexed newPythOracle);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed asset, bytes32 indexed pythId, uint64 indexed maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Batch set token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the underlying Pyth oracle contract address\n * @param underlyingPythOracle_ Pyth oracle contract address\n * @custom:access Only Governance\n * @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero\n * @custom:event Emits PythOracleSet event with address of Pyth oracle.\n */\n function setUnderlyingPythOracle(\n IPyth underlyingPythOracle_\n ) external notNullAddress(address(underlyingPythOracle_)) {\n _checkAccessAllowed(\"setUnderlyingPythOracle(address)\");\n IPyth oldUnderlyingPythOracle = underlyingPythOracle;\n underlyingPythOracle = underlyingPythOracle_;\n emit PythOracleSet(address(oldUnderlyingPythOracle), address(underlyingPythOracle_));\n }\n\n /**\n * @notice Initializes the owner of the contract and sets required contracts\n * @param underlyingPythOracle_ Address of the Pyth oracle\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(\n address underlyingPythOracle_,\n address accessControlManager_\n ) external initializer notNullAddress(underlyingPythOracle_) {\n __AccessControlled_init(accessControlManager_);\n\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n emit PythOracleSet(address(0), underlyingPythOracle_);\n }\n\n /**\n * @notice Set single token config. `maxStalePeriod` cannot be 0 and `asset` cannot be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if max stale period is zero\n * @custom:error NotNullAddress error is thrown if asset address is null\n */\n function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n if (tokenConfig.maxStalePeriod == 0) revert(\"max stale period cannot be 0\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);\n }\n\n /**\n * @notice Gets the price of a asset from the pyth oracle\n * @param asset Address of the asset\n * @return Price in USD\n */\n function getPrice(address asset) public view returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n return _getPriceInternal(asset, decimals);\n }\n\n function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256) {\n TokenConfig storage tokenConfig = tokenConfigs[asset];\n if (tokenConfig.asset == address(0)) revert(\"asset doesn't exist\");\n\n // if the price is expired after it's compared against `maxStalePeriod`, the following call will revert\n PythStructs.Price memory priceInfo = underlyingPythOracle.getPriceNoOlderThan(\n tokenConfig.pythId,\n tokenConfig.maxStalePeriod\n );\n\n uint256 price = int256(priceInfo.price).toUint256();\n\n if (price == 0) revert(\"invalid pyth oracle price\");\n\n // the price returned from Pyth is price ** 10^expo, which is the real dollar price of the assets\n // we need to multiply it by 1e18 to make the price 18 decimals\n if (priceInfo.expo > 0) {\n return price * EXP_SCALE * (10 ** int256(priceInfo.expo).toUint256()) * (10 ** (18 - decimals));\n } else {\n return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));\n }\n }\n}\n" }, - "contracts/oracles/TwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../libraries/PancakeLibrary.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title TwapOracle\n * @author Venus\n * @notice This oracle fetches price of assets from PancakeSwap.\n */\ncontract TwapOracle is AccessControlledV8, TwapInterface {\n using FixedPoint for *;\n\n struct Observation {\n uint256 timestamp;\n uint256 acc;\n }\n\n struct TokenConfig {\n /// @notice Asset address, which can't be zero address and can be used for existance check\n address asset;\n /// @notice Decimals of asset represented as 1e{decimals}\n uint256 baseUnit;\n /// @notice The address of Pancake pair\n address pancakePool;\n /// @notice Whether the token is paired with WBNB\n bool isBnbBased;\n /// @notice A flag identifies whether the Pancake pair is reversed\n /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not.\n bool isReversedPool;\n /// @notice The minimum window in seconds required between TWAP updates\n uint256 anchorPeriod;\n }\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice WBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WBNB;\n\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\n uint256 public constant BNB_BASE_UNIT = 1e18;\n uint256 public constant BUSD_BASE_UNIT = 1e18;\n\n /// @notice Configs by token\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Stored price by token\n mapping(address => uint256) public prices;\n\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\n mapping(address => Observation[]) public observations;\n\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\n mapping(address => uint256) public windowStart;\n\n /// @notice Emit this event when TWAP window is updated\n event TwapWindowUpdated(\n address indexed asset,\n uint256 oldTimestamp,\n uint256 oldAcc,\n uint256 newTimestamp,\n uint256 newAcc\n );\n\n /// @notice Emit this event when TWAP price is updated\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\n\n /// @notice Emit this event when new token configs are added\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param wBnbAddress The address of the WBNB\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address wBnbAddress) notNullAddress(wBnbAddress) {\n WBNB = wBnbAddress;\n _disableInitializers();\n }\n\n /**\n * @notice Adds multiple token configs at the same time\n * @param configs Config array\n * @custom:error Zero length error thrown, if length of the config array is 0\n */\n function setTokenConfigs(TokenConfig[] memory configs) external {\n if (configs.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = configs.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(configs[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Get the TWAP price for the given asset\n * @param asset asset address\n * @return price asset price in USD\n * @custom:error Missing error is thrown if the token config does not exist\n * @custom:error Range error is thrown if TWAP price is not greater than zero\n */\n function getPrice(address asset) external view override returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n asset = WBNB;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n uint256 price = prices[asset];\n\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\n if (price == 0) revert(\"TWAP price must be positive\");\n return (price * (10 ** (18 - decimals)));\n }\n\n /**\n * @notice Adds a single token config\n * @param config token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if anchor period is not greater than zero\n * @custom:error Range error is thrown if base unit is not greater than zero\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\n * @custom:error NotNullAddress error is thrown if address of asset is null\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\n * @custom:event Emits TokenConfigAdded event if new token config are added with\n * asset address, PancakePool address, anchor period address\n */\n function setTokenConfig(\n TokenConfig memory config\n ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n if (config.anchorPeriod == 0) revert(\"anchor period must be positive\");\n if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals())\n revert(\"base unit decimals must be same as asset decimals\");\n\n uint256 cumulativePrice = currentCumulativePrice(config);\n\n // Initialize observation data\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\n tokenConfigs[config.asset] = config;\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\n }\n\n /**\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return anchorPrice anchor price of the asset\n * @custom:error Missing error is thrown if token config does not exist\n */\n function updateTwap(address asset) public returns (uint256) {\n if (asset == BNB_ADDR) {\n asset = WBNB;\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\n if (tokenConfigs[WBNB].asset == address(0)) revert(\"WBNB not exist\");\n _updateTwapInternal(tokenConfigs[WBNB]);\n }\n return _updateTwapInternal(tokenConfigs[asset]);\n }\n\n /**\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\n * @return cumulative price of target token regardless of pair order\n */\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\n if (config.isReversedPool) {\n return price1;\n } else {\n return price0;\n }\n }\n\n /**\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return price Asset price in USD, with 18 decimals\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\n * AnchorPrice, old observation timestamp and current timestamp\n */\n function _updateTwapInternal(TokenConfig memory config) private returns (uint256) {\n // pokeWindowValues already handled reversed pool cases,\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\n\n if (block.timestamp == oldTimestamp) return prices[config.asset];\n\n // This should be impossible, but better safe than sorry\n if (block.timestamp < oldTimestamp) revert(\"now must come after before\");\n\n uint256 timeElapsed;\n unchecked {\n timeElapsed = block.timestamp - oldTimestamp;\n }\n\n // Calculate Pancake *twap**\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\n );\n // *twap** price with 1e18 decimal mantissa\n uint256 priceAverageMantissa = priceAverage.decode112with18();\n\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\n // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18)\n uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT;\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\n\n // if this token is paired with BNB, convert its price to USD\n if (config.isBnbBased) {\n uint256 bnbPrice = prices[WBNB];\n if (bnbPrice == 0) revert(\"bnb price is invalid\");\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT;\n }\n\n if (anchorPriceMantissa == 0) revert(\"twap price cannot be 0\");\n\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\n\n // save anchor price, which is 1e18 decimals\n prices[config.asset] = anchorPriceMantissa;\n\n return anchorPriceMantissa;\n }\n\n /**\n * @notice Appends current observation and pick an observation with a timestamp equal\n * or just greater than the window start timestamp. If one is not available,\n * then pick the last availableobservation. The window start index is updated in both the cases.\n * Only the current observation is saved, prior observations are deleted during this operation.\n * @return Tuple of cumulative price, old observation and timestamp\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\n * new observation timestamp, current timestamp, new observation price and cumulative price\n */\n function pokeWindowValues(\n TokenConfig memory config\n ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\n uint256 cumulativePrice = currentCumulativePrice(config);\n uint256 currentTimestamp = block.timestamp;\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\n Observation[] memory storedObservations = observations[config.asset];\n\n uint256 storedObservationsLength = storedObservations.length;\n for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) {\n if (\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\n (windowStartIndex == storedObservationsLength - 1)\n ) {\n startCumulativePrice = storedObservations[windowStartIndex].acc;\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\n windowStart[config.asset] = windowStartIndex;\n break;\n } else {\n delete observations[config.asset][windowStartIndex];\n }\n\n unchecked {\n ++windowStartIndex;\n }\n }\n\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\n emit TwapWindowUpdated(\n config.asset,\n startCumulativeTimestamp,\n startCumulativePrice,\n block.timestamp,\n cumulativePrice\n );\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\n }\n}\n" - }, "contracts/ResilientOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ResilientOracle\n * @author Venus\n * @notice The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets.\n * \n * DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly\n * reported prices. If only one oracle is used, this creates a single point of failure and opens a vector\n * for attacking the protocol.\n * \n * The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect\n * the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle\n * and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.\n * \n * For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per \n * vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot \n * oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. \n * \n * To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every\n * market. The upper bound ratio represents the deviation between reported price (the price that’s being\n * validated) and the anchor price (the price we are validating against) above which the reported price will\n * be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below\n * which the reported price will be invalidated. So for oracle price to be considered valid the below statement\n * should be true:\n\n```\nanchorRatio = anchorPrice/reporterPrice\nisValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio\n```\n\n * In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending\n * on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may\n * use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. \n * \n * For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the\n * oracle to be stagnant and treat it like it's disabled.\n */\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n /**\n * @dev Oracle roles:\n * **main**: The most trustworthy price source\n * **pivot**: Price oracle used as a loose sanity checker\n * **fallback**: The backup source when main oracle price is invalidated\n */\n enum OracleRole {\n MAIN,\n PIVOT,\n FALLBACK\n }\n\n struct TokenConfig {\n /// @notice asset address\n address asset;\n /// @notice `oracles` stores the oracles based on their role in the following order:\n /// [main, pivot, fallback],\n /// It can be indexed with the corresponding enum OracleRole value\n address[3] oracles;\n /// @notice `enableFlagsForOracles` stores the enabled state\n /// for each oracle in the same order as `oracles`\n bool[3] enableFlagsForOracles;\n }\n\n uint256 public constant INVALID_PRICE = 0;\n\n /// @notice vBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vBnb;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Bound validator contract address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n BoundValidatorInterface public immutable boundValidator;\n\n mapping(address => TokenConfig) private tokenConfigs;\n\n event TokenConfigAdded(\n address indexed asset,\n address indexed mainOracle,\n address indexed pivotOracle,\n address fallbackOracle\n );\n\n /// Event emitted when an oracle is set\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n /// Event emitted when an oracle is enabled or disabled\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /**\n * @notice Checks whether token config exists by checking whether asset is null address\n * @dev address can't be null, so it's suitable to be used to check the validity of the config\n * @param asset asset address\n */\n modifier checkTokenConfigExistence(address asset) {\n if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param vBnbAddress The address of the vBNB\n /// @param vaiAddress The address of the VAI\n /// @param _boundValidator Address of the bound validator contract\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address vBnbAddress,\n address vaiAddress,\n BoundValidatorInterface _boundValidator\n ) notNullAddress(vBnbAddress) notNullAddress(vaiAddress) notNullAddress(address(_boundValidator)) {\n vBnb = vBnbAddress;\n vai = vaiAddress;\n boundValidator = _boundValidator;\n\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract admin and sets the BoundValidator contract address\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n }\n\n /**\n * @notice Pauses oracle\n * @custom:access Only Governance\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n _pause();\n }\n\n /**\n * @notice Unpauses oracle\n * @custom:access Only Governance\n */\n function unpause() external {\n _checkAccessAllowed(\"unpause()\");\n _unpause();\n }\n\n /**\n * @notice Batch sets token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Throws a length error if the length of the token configs array is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Sets oracle for a given asset and role.\n * @dev Supplied asset **must** exist and main oracle may not be null\n * @param asset Asset address\n * @param oracle Oracle address\n * @param role Oracle role\n * @custom:access Only Governance\n * @custom:error Null address error if main-role oracle address is null\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n */\n function setOracle(\n address asset,\n address oracle,\n OracleRole role\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\n emit OracleSet(asset, oracle, uint256(role));\n }\n\n /**\n * @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\n * @dev Configuration for the asset **must** already exist and the asset cannot be 0 address\n * @param asset Asset address\n * @param role Oracle role\n * @param enable Enabled boolean of the oracle\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n */\n function enableOracle(\n address asset,\n OracleRole role,\n bool enable\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n emit OracleEnabled(asset, uint256(role), enable);\n }\n\n /**\n * @notice Updates the TWAP pivot oracle price.\n * @dev This function should always be called before calling getUnderlyingPrice\n * @param vToken vToken address\n */\n function updatePrice(address vToken) external override {\n address asset = _getUnderlyingAsset(vToken);\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @notice Updates the pivot oracle price. Currently using TWAP\n * @dev This function should always be called before calling getPrice\n * @param asset asset address\n */\n function updateAssetPrice(address asset) external {\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @dev Gets token config by asset address\n * @param asset asset address\n * @return tokenConfig Config for the asset\n */\n function getTokenConfig(address asset) external view returns (TokenConfig memory) {\n return tokenConfigs[asset];\n }\n\n /**\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n * - Check if the oracle is paused globally\n * - Validate price from main oracle against pivot oracle\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\n * - Validate price from main oracle against fallback oracle if the second validation failed\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\n * main oracle price is returned.\n * @param vToken vToken address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n\n address asset = _getUnderlyingAsset(vToken);\n return _getPrice(asset);\n }\n\n /**\n * @notice Gets price of the asset\n * @param asset asset address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getPrice(address asset) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n return _getPrice(asset);\n }\n\n /**\n * @notice Sets/resets single token configs.\n * @dev main oracle **must not** be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress is thrown if asset address is null\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n * @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(\n tokenConfig.asset,\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n );\n }\n\n /**\n * @notice Gets oracle and enabled status by asset address\n * @param asset asset address\n * @param role Oracle role\n * @return oracle Oracle address based on role\n * @return enabled Enabled flag of the oracle based on token config\n */\n function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {\n oracle = tokenConfigs[asset].oracles[uint256(role)];\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n }\n\n function _getPrice(address asset) internal view returns (uint256) {\n uint256 pivotPrice = INVALID_PRICE;\n\n // Get pivot oracle price, Invalid price if not available or error\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracleEnabled && pivotOracle != address(0)) {\n try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {\n pivotPrice = pricePivot;\n } catch {}\n }\n\n // Compare main price and pivot price, return main price and if validation was successful\n // note: In case pivot oracle is not available but main price is available and\n // validation is successful, the main oracle price is returned.\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n asset,\n pivotPrice,\n pivotOracleEnabled && pivotOracle != address(0)\n );\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n // Compare fallback and pivot if main oracle comparision fails with pivot\n // Return fallback price when fallback price is validated successfully with pivot oracle\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n // Lastly compare main price and fallback price\n if (\n mainPrice != INVALID_PRICE &&\n fallbackPrice != INVALID_PRICE &&\n boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)\n ) {\n return mainPrice;\n }\n\n revert(\"invalid resilient oracle price\");\n }\n\n /**\n * @notice Gets a price for the provided asset\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\n * able to fetch a correct price\n * @param asset asset address\n * @param pivotPrice Pivot oracle price\n * @param pivotEnabled If pivot oracle is not empty and enabled\n * @return price USD price in scaled decimals\n * e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n * @return pivotValidated Boolean representing if the validation of main oracle price\n * and pivot oracle price were successful\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n * address is null\n */\n function _getMainOraclePrice(\n address asset,\n uint256 pivotPrice,\n bool pivotEnabled\n ) internal view returns (uint256, bool) {\n (address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);\n if (mainOracleEnabled && mainOracle != address(0)) {\n try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {\n if (!pivotEnabled) {\n return (mainOraclePrice, true);\n }\n if (pivotPrice == INVALID_PRICE) {\n return (mainOraclePrice, false);\n }\n return (\n mainOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function won't revert when the price is 0 because getPrice checks if price is > 0\n * @param asset asset address\n * @return price USD price in 18 decimals\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\n * and pivot oracle price were successfull\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n * address is null\n */\n function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {\n (address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);\n if (fallbackEnabled && fallbackOracle != address(0)) {\n try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {\n if (pivotPrice == INVALID_PRICE) {\n return (fallbackOraclePrice, false);\n }\n return (\n fallbackOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view returns (address asset) {\n if (address(vToken) == vBnb) {\n asset = BNB_ADDR;\n } else if (address(vToken) == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" }, diff --git a/deployments/bsctestnet_addresses.json b/deployments/bsctestnet_addresses.json index 03276c3a..a71b9373 100644 --- a/deployments/bsctestnet_addresses.json +++ b/deployments/bsctestnet_addresses.json @@ -20,9 +20,6 @@ "RedStoneOracle_Proxy": "0x0Af51d1504ac5B711A9EAFe2fAC11A51d32029Ad", "ResilientOracle": "0x3cD69251D04A28d887Ac14cbe2E14c52F3D57823", "ResilientOracle_Implementation": "0x35cC3b99985F9d970aEcc9BD83d5Ac78a074a896", - "ResilientOracle_Proxy": "0x3cD69251D04A28d887Ac14cbe2E14c52F3D57823", - "TwapOracle": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", - "TwapOracle_Implementation": "0x572ec272B4Ae3a50B99905AFd78671F84474ffd1", - "TwapOracle_Proxy": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432" + "ResilientOracle_Proxy": "0x3cD69251D04A28d887Ac14cbe2E14c52F3D57823" } } diff --git a/deployments/ethereum.json b/deployments/ethereum.json index 3a073ee1..735753fe 100644 --- a/deployments/ethereum.json +++ b/deployments/ethereum.json @@ -4760,6 +4760,978 @@ "type": "receive" } ] + }, + "WstETHOracle_Equivalence": { + "address": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [], + "name": "ZeroAddressNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "ASSUME_STETH_ETH_EQUIVALENCE", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESILIENT_ORACLE", + "outputs": [ + { + "internalType": "contract OracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STETH", + "outputs": [ + { + "internalType": "contract IStETH", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WSTETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ] + }, + "WstETHOracle_Equivalence_Implementation": { + "address": "0x4e70615332550CE81e12891772eB950411Bb05A2", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "wstETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "wETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "stETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "resilientOracleAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "assumeEquivalence", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "ZeroAddressNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "ASSUME_STETH_ETH_EQUIVALENCE", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESILIENT_ORACLE", + "outputs": [ + { + "internalType": "contract OracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STETH", + "outputs": [ + { + "internalType": "contract IStETH", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WSTETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "WstETHOracle_Equivalence_Proxy": { + "address": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ] + }, + "WstETHOracle_NonEquivalence": { + "address": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [], + "name": "ZeroAddressNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "ASSUME_STETH_ETH_EQUIVALENCE", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESILIENT_ORACLE", + "outputs": [ + { + "internalType": "contract OracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STETH", + "outputs": [ + { + "internalType": "contract IStETH", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WSTETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ] + }, + "WstETHOracle_NonEquivalence_Implementation": { + "address": "0x24D3D52332834ddE93692D9ede4679FE920d2afC", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "wstETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "wETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "stETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "resilientOracleAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "assumeEquivalence", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "ZeroAddressNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "ASSUME_STETH_ETH_EQUIVALENCE", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESILIENT_ORACLE", + "outputs": [ + { + "internalType": "contract OracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STETH", + "outputs": [ + { + "internalType": "contract IStETH", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WSTETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "WstETHOracle_NonEquivalence_Proxy": { + "address": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ] } } } diff --git a/deployments/ethereum/WstETHOracle_Equivalence.json b/deployments/ethereum/WstETHOracle_Equivalence.json new file mode 100644 index 00000000..3e59dd32 --- /dev/null +++ b/deployments/ethereum/WstETHOracle_Equivalence.json @@ -0,0 +1,303 @@ +{ + "address": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [], + "name": "ZeroAddressNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "ASSUME_STETH_ETH_EQUIVALENCE", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESILIENT_ORACLE", + "outputs": [ + { + "internalType": "contract OracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STETH", + "outputs": [ + { + "internalType": "contract IStETH", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WSTETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0xc1ec093e4f459de11f515b1fd9cb35d397f9a674da9d7b6a6780ef87af7c6d4d", + "receipt": { + "to": null, + "from": "0x1bb5A9f786a6BA418E8059a877689486A14497a2", + "contractAddress": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "transactionIndex": 101, + "gasUsed": "622245", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000404000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000008000000000020000000000400000000000000000000000000000000000000000000000000000000000000000000000100000000000000", + "blockHash": "0x1439f9894570bd92ae5f3c33e6f3cefcc8ab8879a538312e08cff08b95b9023e", + "transactionHash": "0xc1ec093e4f459de11f515b1fd9cb35d397f9a674da9d7b6a6780ef87af7c6d4d", + "logs": [ + { + "transactionIndex": 101, + "blockNumber": 19276128, + "transactionHash": "0xc1ec093e4f459de11f515b1fd9cb35d397f9a674da9d7b6a6780ef87af7c6d4d", + "address": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x0000000000000000000000004e70615332550ce81e12891772eb950411bb05a2" + ], + "data": "0x", + "logIndex": 89, + "blockHash": "0x1439f9894570bd92ae5f3c33e6f3cefcc8ab8879a538312e08cff08b95b9023e" + }, + { + "transactionIndex": 101, + "blockNumber": 19276128, + "transactionHash": "0xc1ec093e4f459de11f515b1fd9cb35d397f9a674da9d7b6a6780ef87af7c6d4d", + "address": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000567e4cc5e085d09f66f836fa8279f38b4e5866b9", + "logIndex": 90, + "blockHash": "0x1439f9894570bd92ae5f3c33e6f3cefcc8ab8879a538312e08cff08b95b9023e" + } + ], + "blockNumber": 19276128, + "cumulativeGasUsed": "5389879", + "status": 1, + "byzantium": true + }, + "args": ["0x4e70615332550CE81e12891772eB950411Bb05A2", "0x567e4cc5e085d09f66f836fa8279f38b4e5866b9", "0x"], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"},\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n\\n function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405260405162000f5f38038062000f5f83398101604081905262000026916200044a565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6200052a565b60008051602062000f188339815191521462000075576200007562000550565b62000083828260006200013c565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046200052a565b60008051602062000ef883398151915214620000d357620000d362000550565b6001600160a01b038216608081905260008051602062000ef88339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050620005b9565b620001478362000179565b600082511180620001555750805b156200017457620001728383620001bb60201b620002a91760201c565b505b505050565b6200018481620001ea565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e3838360405180606001604052806027815260200162000f3860279139620002b2565b9392505050565b62000200816200039860201b620002d51760201c565b620002685760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806200029160008051602062000f1883398151915260001b620003a760201b620002411760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606001600160a01b0384163b6200031c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200025f565b600080856001600160a01b03168560405162000339919062000566565b600060405180830381855af49150503d806000811462000376576040519150601f19603f3d011682016040523d82523d6000602084013e6200037b565b606091505b5090925090506200038e828286620003aa565b9695505050505050565b6001600160a01b03163b151590565b90565b60608315620003bb575081620001e3565b825115620003cc5782518084602001fd5b8160405162461bcd60e51b81526004016200025f919062000584565b80516001600160a01b03811681146200040057600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004385781810151838201526020016200041e565b83811115620001725750506000910152565b6000806000606084860312156200046057600080fd5b6200046b84620003e8565b92506200047b60208501620003e8565b60408501519092506001600160401b03808211156200049957600080fd5b818601915086601f830112620004ae57600080fd5b815181811115620004c357620004c362000405565b604051601f8201601f19908116603f01168101908382118183101715620004ee57620004ee62000405565b816040528281528960208487010111156200050857600080fd5b6200051b8360208301602088016200041b565b80955050505050509250925092565b6000828210156200054b57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b600082516200057a8184602087016200041b565b9190910192915050565b6020815260008251806020840152620005a58160408501602087016200041b565b601f01601f19169190910160400192915050565b608051610900620005f86000396000818161011201528181610176015281816102060152818161025e01528181610287015261030901526109006000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033", + "implementation": "0x4e70615332550CE81e12891772eB950411Bb05A2", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/ethereum/WstETHOracle_Equivalence_Implementation.json b/deployments/ethereum/WstETHOracle_Equivalence_Implementation.json new file mode 100644 index 00000000..34c3721e --- /dev/null +++ b/deployments/ethereum/WstETHOracle_Equivalence_Implementation.json @@ -0,0 +1,229 @@ +{ + "address": "0x4e70615332550CE81e12891772eB950411Bb05A2", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "wstETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "wETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "stETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "resilientOracleAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "assumeEquivalence", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "ZeroAddressNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "ASSUME_STETH_ETH_EQUIVALENCE", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESILIENT_ORACLE", + "outputs": [ + { + "internalType": "contract OracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STETH", + "outputs": [ + { + "internalType": "contract IStETH", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WSTETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xb15c040b577518bbff1380ea5ed7b0bc786e20b757091f6470d308cbc724a170", + "receipt": { + "to": null, + "from": "0x1bb5A9f786a6BA418E8059a877689486A14497a2", + "contractAddress": "0x4e70615332550CE81e12891772eB950411Bb05A2", + "transactionIndex": 47, + "gasUsed": "307696", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x09280897229413b55727fff47079a6e135c9f6afef538c6c58763d36485d08dd", + "transactionHash": "0xb15c040b577518bbff1380ea5ed7b0bc786e20b757091f6470d308cbc724a170", + "logs": [], + "blockNumber": 19276104, + "cumulativeGasUsed": "6941812", + "status": 1, + "byzantium": true + }, + "args": [ + "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", + "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "0xae7ab96520de3a18e5e111b5eaab095312d7fe84", + "0xd2ce3fb018805ef92b8C5976cb31F84b4E295F94", + true + ], + "numDeployments": 1, + "solcInputHash": "643c04e89f008dea200654c141acbf47", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"wstETHAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"wETHAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stETHAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"resilientOracleAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"assumeEquivalence\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ZeroAddressNotAllowed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ASSUME_STETH_ETH_EQUIVALENCE\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RESILIENT_ORACLE\",\"outputs\":[{\"internalType\":\"contract OracleInterface\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"STETH\",\"outputs\":[{\"internalType\":\"contract IStETH\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WETH_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WSTETH_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"kind\":\"dev\",\"methods\":{\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"getPrice(address)\":{\"details\":\"Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH or the price of stETH/USD (secondary market price) is obtained from the oracle\",\"params\":{\"asset\":\"Address of wstETH\"},\"returns\":{\"_0\":\"wstETH Price in USD scaled by 1e18\"}}},\"stateVariables\":{\"ASSUME_STETH_ETH_EQUIVALENCE\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"RESILIENT_ORACLE\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"STETH\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"WETH_ADDRESS\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"WSTETH_ADDRESS\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"WstETHOracle\",\"version\":1},\"userdoc\":{\"errors\":{\"ZeroAddressNotAllowed()\":[{\"notice\":\"Thrown if the supplied address is a zero address where it is not allowed\"}]},\"kind\":\"user\",\"methods\":{\"ASSUME_STETH_ETH_EQUIVALENCE()\":{\"notice\":\"A flag assuming 1:1 price equivalence between stETH/ETH\"},\"RESILIENT_ORACLE()\":{\"notice\":\"Address of Resilient Oracle\"},\"STETH()\":{\"notice\":\"Address of stETH\"},\"WETH_ADDRESS()\":{\"notice\":\"Address of WETH\"},\"WSTETH_ADDRESS()\":{\"notice\":\"Address of wstETH\"},\"constructor\":{\"notice\":\"Constructor for the implementation contract.\"},\"getPrice(address)\":{\"notice\":\"Gets the USD price of wstETH asset\"}},\"notice\":\"Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH or the price of stETH/USD (secondary market price) is obtained from the oracle.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/oracles/WstETHOracle.sol\":\"WstETHOracle\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@venusprotocol/solidity-utilities/contracts/constants.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\n/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)\\nuint256 constant EXP_SCALE = 1e18;\\n\\n/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\\nuint256 constant MANTISSA_ONE = EXP_SCALE;\\n\\n/// @dev The approximate number of seconds per year\\nuint256 constant SECONDS_PER_YEAR = 31_536_000;\\n\",\"keccak256\":\"0x0464dd1b882ea2925e06e967c025a232c824e9e4c7aee7b97cc255d040594a59\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/validators.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\n/// @notice Thrown if the supplied address is a zero address where it is not allowed\\nerror ZeroAddressNotAllowed();\\n\\n/// @notice Thrown if the supplied value is 0 where it is not allowed\\nerror ZeroValueNotAllowed();\\n\\n/// @notice Checks if the provided address is nonzero, reverts otherwise\\n/// @param address_ Address to check\\n/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\\nfunction ensureNonzeroAddress(address address_) pure {\\n if (address_ == address(0)) {\\n revert ZeroAddressNotAllowed();\\n }\\n}\\n\\n/// @notice Checks if the provided value is nonzero, reverts otherwise\\n/// @param value_ Value to check\\n/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0\\nfunction ensureNonzeroValue(uint256 value_) pure {\\n if (value_ == 0) {\\n revert ZeroValueNotAllowed();\\n }\\n}\\n\",\"keccak256\":\"0xd55726634a83a862a9cef9d34c41694d3d0fea86cdbc57d6674af066792194b1\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/IStETH.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface IStETH {\\n function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xc298a8004674ce23b9c3b8217285c3c3f926ee3148e58d0dd3863dc7ba9e13e6\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface OracleInterface {\\n function getPrice(address asset) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n\\n function updateAssetPrice(address asset) external;\\n\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address asset) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address asset,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x40031b19684ca0c912e794d08c2c0b0d8be77d3c1bdc937830a0658eff899650\",\"license\":\"BSD-3-Clause\"},\"contracts/oracles/WstETHOracle.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport { OracleInterface } from \\\"../interfaces/OracleInterface.sol\\\";\\nimport { IStETH } from \\\"../interfaces/IStETH.sol\\\";\\nimport { ensureNonzeroAddress } from \\\"@venusprotocol/solidity-utilities/contracts/validators.sol\\\";\\nimport { EXP_SCALE } from \\\"@venusprotocol/solidity-utilities/contracts/constants.sol\\\";\\n\\n/**\\n * @title WstETHOracle\\n * @author Venus\\n * @notice Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH\\n * or the price of stETH/USD (secondary market price) is obtained from the oracle.\\n */\\ncontract WstETHOracle is OracleInterface {\\n /// @notice A flag assuming 1:1 price equivalence between stETH/ETH\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n bool public immutable ASSUME_STETH_ETH_EQUIVALENCE;\\n\\n /// @notice Address of stETH\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IStETH public immutable STETH;\\n\\n /// @notice Address of wstETH\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable WSTETH_ADDRESS;\\n\\n /// @notice Address of WETH\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable WETH_ADDRESS;\\n\\n /// @notice Address of Resilient Oracle\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n OracleInterface public immutable RESILIENT_ORACLE;\\n\\n /// @notice Constructor for the implementation contract.\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n address wstETHAddress,\\n address wETHAddress,\\n address stETHAddress,\\n address resilientOracleAddress,\\n bool assumeEquivalence\\n ) {\\n ensureNonzeroAddress(wstETHAddress);\\n ensureNonzeroAddress(wETHAddress);\\n ensureNonzeroAddress(stETHAddress);\\n ensureNonzeroAddress(resilientOracleAddress);\\n WSTETH_ADDRESS = wstETHAddress;\\n WETH_ADDRESS = wETHAddress;\\n STETH = IStETH(stETHAddress);\\n RESILIENT_ORACLE = OracleInterface(resilientOracleAddress);\\n ASSUME_STETH_ETH_EQUIVALENCE = assumeEquivalence;\\n }\\n\\n /**\\n * @notice Gets the USD price of wstETH asset\\n * @dev Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH\\n * or the price of stETH/USD (secondary market price) is obtained from the oracle\\n * @param asset Address of wstETH\\n * @return wstETH Price in USD scaled by 1e18\\n */\\n function getPrice(address asset) public view returns (uint256) {\\n if (asset != WSTETH_ADDRESS) revert(\\\"wrong wstETH address\\\");\\n\\n // get stETH amount for 1 wstETH scaled by 1e18\\n uint256 stETHAmount = STETH.getPooledEthByShares(1 ether);\\n\\n // price is scaled 1e18 (oracle returns 36 - asset decimal scale)\\n uint256 stETHUSDPrice = RESILIENT_ORACLE.getPrice(ASSUME_STETH_ETH_EQUIVALENCE ? WETH_ADDRESS : address(STETH));\\n\\n // stETHAmount (for 1 wstETH) * stETHUSDPrice / 1e18\\n return (stETHAmount * stETHUSDPrice) / EXP_SCALE;\\n }\\n}\\n\",\"keccak256\":\"0x43e6363cca2563e9e8dc3ec0197001b1fb9c2a8ab8eb76414758d4b185df6aec\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", + "bytecode": "0x61012060405234801561001157600080fd5b50604051610624380380610624833981016040819052610030916100c5565b6100398561007f565b6100428461007f565b61004b8361007f565b6100548261007f565b6001600160a01b0394851660c05292841660e05290831660a052909116610100521515608052610133565b6001600160a01b0381166100a6576040516342bcdf7f60e11b815260040160405180910390fd5b50565b80516001600160a01b03811681146100c057600080fd5b919050565b600080600080600060a086880312156100dd57600080fd5b6100e6866100a9565b94506100f4602087016100a9565b9350610102604087016100a9565b9250610110606087016100a9565b91506080860151801515811461012557600080fd5b809150509295509295909350565b60805160a05160c05160e0516101005161048661019e6000396000818160f8015261028f015260008181606c015261030901526000818160b0015261017c01526000818161011f0152818161021601526102e301526000818161014601526102be01526104866000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063040141e51461006757806336e6372f146100ab57806341976e09146100d2578063a4edcd4c146100f3578063e00bfe501461011a578063ed0142b714610141575b600080fd5b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6100e56100e03660046103b8565b610178565b6040519081526020016100a2565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6101687f000000000000000000000000000000000000000000000000000000000000000081565b60405190151581526020016100a2565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316146101f65760405162461bcd60e51b815260206004820152601460248201527377726f6e6720777374455448206164647265737360601b604482015260640160405180910390fd5b604051630f451f7160e31b8152670de0b6b3a764000060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637a28fb8890602401602060405180830381865afa158015610265573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061028991906103e8565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166341976e097f0000000000000000000000000000000000000000000000000000000000000000610307577f0000000000000000000000000000000000000000000000000000000000000000610329565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561036d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039191906103e8565b9050670de0b6b3a76400006103a68284610401565b6103b0919061042e565b949350505050565b6000602082840312156103ca57600080fd5b81356001600160a01b03811681146103e157600080fd5b9392505050565b6000602082840312156103fa57600080fd5b5051919050565b600081600019048311821515161561042957634e487b7160e01b600052601160045260246000fd5b500290565b60008261044b57634e487b7160e01b600052601260045260246000fd5b50049056fea264697066735822122065ae659d958b7601c08793974dff6c2a473b0d61fc2cd816dbddf7f8b0cbfbb664736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c8063040141e51461006757806336e6372f146100ab57806341976e09146100d2578063a4edcd4c146100f3578063e00bfe501461011a578063ed0142b714610141575b600080fd5b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6100e56100e03660046103b8565b610178565b6040519081526020016100a2565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6101687f000000000000000000000000000000000000000000000000000000000000000081565b60405190151581526020016100a2565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316146101f65760405162461bcd60e51b815260206004820152601460248201527377726f6e6720777374455448206164647265737360601b604482015260640160405180910390fd5b604051630f451f7160e31b8152670de0b6b3a764000060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637a28fb8890602401602060405180830381865afa158015610265573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061028991906103e8565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166341976e097f0000000000000000000000000000000000000000000000000000000000000000610307577f0000000000000000000000000000000000000000000000000000000000000000610329565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561036d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039191906103e8565b9050670de0b6b3a76400006103a68284610401565b6103b0919061042e565b949350505050565b6000602082840312156103ca57600080fd5b81356001600160a01b03811681146103e157600080fd5b9392505050565b6000602082840312156103fa57600080fd5b5051919050565b600081600019048311821515161561042957634e487b7160e01b600052601160045260246000fd5b500290565b60008261044b57634e487b7160e01b600052601260045260246000fd5b50049056fea264697066735822122065ae659d958b7601c08793974dff6c2a473b0d61fc2cd816dbddf7f8b0cbfbb664736f6c634300080d0033", + "devdoc": { + "author": "Venus", + "kind": "dev", + "methods": { + "constructor": { + "custom:oz-upgrades-unsafe-allow": "constructor" + }, + "getPrice(address)": { + "details": "Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH or the price of stETH/USD (secondary market price) is obtained from the oracle", + "params": { + "asset": "Address of wstETH" + }, + "returns": { + "_0": "wstETH Price in USD scaled by 1e18" + } + } + }, + "stateVariables": { + "ASSUME_STETH_ETH_EQUIVALENCE": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "RESILIENT_ORACLE": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "STETH": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "WETH_ADDRESS": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "WSTETH_ADDRESS": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + } + }, + "title": "WstETHOracle", + "version": 1 + }, + "userdoc": { + "errors": { + "ZeroAddressNotAllowed()": [ + { + "notice": "Thrown if the supplied address is a zero address where it is not allowed" + } + ] + }, + "kind": "user", + "methods": { + "ASSUME_STETH_ETH_EQUIVALENCE()": { + "notice": "A flag assuming 1:1 price equivalence between stETH/ETH" + }, + "RESILIENT_ORACLE()": { + "notice": "Address of Resilient Oracle" + }, + "STETH()": { + "notice": "Address of stETH" + }, + "WETH_ADDRESS()": { + "notice": "Address of WETH" + }, + "WSTETH_ADDRESS()": { + "notice": "Address of wstETH" + }, + "constructor": { + "notice": "Constructor for the implementation contract." + }, + "getPrice(address)": { + "notice": "Gets the USD price of wstETH asset" + } + }, + "notice": "Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH or the price of stETH/USD (secondary market price) is obtained from the oracle.", + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/ethereum/WstETHOracle_Equivalence_Proxy.json b/deployments/ethereum/WstETHOracle_Equivalence_Proxy.json new file mode 100644 index 00000000..805976c5 --- /dev/null +++ b/deployments/ethereum/WstETHOracle_Equivalence_Proxy.json @@ -0,0 +1,213 @@ +{ + "address": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xc1ec093e4f459de11f515b1fd9cb35d397f9a674da9d7b6a6780ef87af7c6d4d", + "receipt": { + "to": null, + "from": "0x1bb5A9f786a6BA418E8059a877689486A14497a2", + "contractAddress": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "transactionIndex": 101, + "gasUsed": "622245", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000404000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000008000000000020000000000400000000000000000000000000000000000000000000000000000000000000000000000100000000000000", + "blockHash": "0x1439f9894570bd92ae5f3c33e6f3cefcc8ab8879a538312e08cff08b95b9023e", + "transactionHash": "0xc1ec093e4f459de11f515b1fd9cb35d397f9a674da9d7b6a6780ef87af7c6d4d", + "logs": [ + { + "transactionIndex": 101, + "blockNumber": 19276128, + "transactionHash": "0xc1ec093e4f459de11f515b1fd9cb35d397f9a674da9d7b6a6780ef87af7c6d4d", + "address": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x0000000000000000000000004e70615332550ce81e12891772eb950411bb05a2" + ], + "data": "0x", + "logIndex": 89, + "blockHash": "0x1439f9894570bd92ae5f3c33e6f3cefcc8ab8879a538312e08cff08b95b9023e" + }, + { + "transactionIndex": 101, + "blockNumber": 19276128, + "transactionHash": "0xc1ec093e4f459de11f515b1fd9cb35d397f9a674da9d7b6a6780ef87af7c6d4d", + "address": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000567e4cc5e085d09f66f836fa8279f38b4e5866b9", + "logIndex": 90, + "blockHash": "0x1439f9894570bd92ae5f3c33e6f3cefcc8ab8879a538312e08cff08b95b9023e" + } + ], + "blockNumber": 19276128, + "cumulativeGasUsed": "5389879", + "status": 1, + "byzantium": true + }, + "args": ["0x4e70615332550CE81e12891772eB950411Bb05A2", "0x567e4cc5e085d09f66f836fa8279f38b4e5866b9", "0x"], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"},\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n\\n function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405260405162000f5f38038062000f5f83398101604081905262000026916200044a565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6200052a565b60008051602062000f188339815191521462000075576200007562000550565b62000083828260006200013c565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046200052a565b60008051602062000ef883398151915214620000d357620000d362000550565b6001600160a01b038216608081905260008051602062000ef88339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050620005b9565b620001478362000179565b600082511180620001555750805b156200017457620001728383620001bb60201b620002a91760201c565b505b505050565b6200018481620001ea565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e3838360405180606001604052806027815260200162000f3860279139620002b2565b9392505050565b62000200816200039860201b620002d51760201c565b620002685760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806200029160008051602062000f1883398151915260001b620003a760201b620002411760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606001600160a01b0384163b6200031c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200025f565b600080856001600160a01b03168560405162000339919062000566565b600060405180830381855af49150503d806000811462000376576040519150601f19603f3d011682016040523d82523d6000602084013e6200037b565b606091505b5090925090506200038e828286620003aa565b9695505050505050565b6001600160a01b03163b151590565b90565b60608315620003bb575081620001e3565b825115620003cc5782518084602001fd5b8160405162461bcd60e51b81526004016200025f919062000584565b80516001600160a01b03811681146200040057600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004385781810151838201526020016200041e565b83811115620001725750506000910152565b6000806000606084860312156200046057600080fd5b6200046b84620003e8565b92506200047b60208501620003e8565b60408501519092506001600160401b03808211156200049957600080fd5b818601915086601f830112620004ae57600080fd5b815181811115620004c357620004c362000405565b604051601f8201601f19908116603f01168101908382118183101715620004ee57620004ee62000405565b816040528281528960208487010111156200050857600080fd5b6200051b8360208301602088016200041b565b80955050505050509250925092565b6000828210156200054b57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b600082516200057a8184602087016200041b565b9190910192915050565b6020815260008251806020840152620005a58160408501602087016200041b565b601f01601f19169190910160400192915050565b608051610900620005f86000396000818161011201528181610176015281816102060152818161025e01528181610287015261030901526109006000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/ethereum/WstETHOracle_NonEquivalence.json b/deployments/ethereum/WstETHOracle_NonEquivalence.json new file mode 100644 index 00000000..3ed7fcfb --- /dev/null +++ b/deployments/ethereum/WstETHOracle_NonEquivalence.json @@ -0,0 +1,303 @@ +{ + "address": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [], + "name": "ZeroAddressNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "ASSUME_STETH_ETH_EQUIVALENCE", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESILIENT_ORACLE", + "outputs": [ + { + "internalType": "contract OracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STETH", + "outputs": [ + { + "internalType": "contract IStETH", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WSTETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0xe5f6eb1f53fb632519eb85e168454e1357d3ebbda0536e2d3b06dcff44f8932a", + "receipt": { + "to": null, + "from": "0x1bb5A9f786a6BA418E8059a877689486A14497a2", + "contractAddress": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "transactionIndex": 99, + "gasUsed": "622245", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000800000000000000000000000000000400000000000000800000000000000000000000000040000000000000000000000000000000000080000000000020000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000800", + "blockHash": "0x1695e78f240fbd2c3cb51fcbf602bba30a2ab326aaaa1d4d0a82445b88e992db", + "transactionHash": "0xe5f6eb1f53fb632519eb85e168454e1357d3ebbda0536e2d3b06dcff44f8932a", + "logs": [ + { + "transactionIndex": 99, + "blockNumber": 19276211, + "transactionHash": "0xe5f6eb1f53fb632519eb85e168454e1357d3ebbda0536e2d3b06dcff44f8932a", + "address": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x00000000000000000000000024d3d52332834dde93692d9ede4679fe920d2afc" + ], + "data": "0x", + "logIndex": 181, + "blockHash": "0x1695e78f240fbd2c3cb51fcbf602bba30a2ab326aaaa1d4d0a82445b88e992db" + }, + { + "transactionIndex": 99, + "blockNumber": 19276211, + "transactionHash": "0xe5f6eb1f53fb632519eb85e168454e1357d3ebbda0536e2d3b06dcff44f8932a", + "address": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000567e4cc5e085d09f66f836fa8279f38b4e5866b9", + "logIndex": 182, + "blockHash": "0x1695e78f240fbd2c3cb51fcbf602bba30a2ab326aaaa1d4d0a82445b88e992db" + } + ], + "blockNumber": 19276211, + "cumulativeGasUsed": "7726843", + "status": 1, + "byzantium": true + }, + "args": ["0x24D3D52332834ddE93692D9ede4679FE920d2afC", "0x567e4cc5e085d09f66f836fa8279f38b4e5866b9", "0x"], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"},\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n\\n function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405260405162000f5f38038062000f5f83398101604081905262000026916200044a565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6200052a565b60008051602062000f188339815191521462000075576200007562000550565b62000083828260006200013c565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046200052a565b60008051602062000ef883398151915214620000d357620000d362000550565b6001600160a01b038216608081905260008051602062000ef88339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050620005b9565b620001478362000179565b600082511180620001555750805b156200017457620001728383620001bb60201b620002a91760201c565b505b505050565b6200018481620001ea565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e3838360405180606001604052806027815260200162000f3860279139620002b2565b9392505050565b62000200816200039860201b620002d51760201c565b620002685760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806200029160008051602062000f1883398151915260001b620003a760201b620002411760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606001600160a01b0384163b6200031c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200025f565b600080856001600160a01b03168560405162000339919062000566565b600060405180830381855af49150503d806000811462000376576040519150601f19603f3d011682016040523d82523d6000602084013e6200037b565b606091505b5090925090506200038e828286620003aa565b9695505050505050565b6001600160a01b03163b151590565b90565b60608315620003bb575081620001e3565b825115620003cc5782518084602001fd5b8160405162461bcd60e51b81526004016200025f919062000584565b80516001600160a01b03811681146200040057600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004385781810151838201526020016200041e565b83811115620001725750506000910152565b6000806000606084860312156200046057600080fd5b6200046b84620003e8565b92506200047b60208501620003e8565b60408501519092506001600160401b03808211156200049957600080fd5b818601915086601f830112620004ae57600080fd5b815181811115620004c357620004c362000405565b604051601f8201601f19908116603f01168101908382118183101715620004ee57620004ee62000405565b816040528281528960208487010111156200050857600080fd5b6200051b8360208301602088016200041b565b80955050505050509250925092565b6000828210156200054b57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b600082516200057a8184602087016200041b565b9190910192915050565b6020815260008251806020840152620005a58160408501602087016200041b565b601f01601f19169190910160400192915050565b608051610900620005f86000396000818161011201528181610176015281816102060152818161025e01528181610287015261030901526109006000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033", + "implementation": "0x24D3D52332834ddE93692D9ede4679FE920d2afC", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/ethereum/WstETHOracle_NonEquivalence_Implementation.json b/deployments/ethereum/WstETHOracle_NonEquivalence_Implementation.json new file mode 100644 index 00000000..b8821cdf --- /dev/null +++ b/deployments/ethereum/WstETHOracle_NonEquivalence_Implementation.json @@ -0,0 +1,229 @@ +{ + "address": "0x24D3D52332834ddE93692D9ede4679FE920d2afC", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "wstETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "wETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "stETHAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "resilientOracleAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "assumeEquivalence", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "ZeroAddressNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "ASSUME_STETH_ETH_EQUIVALENCE", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RESILIENT_ORACLE", + "outputs": [ + { + "internalType": "contract OracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STETH", + "outputs": [ + { + "internalType": "contract IStETH", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WSTETH_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x2457bc83c867e0eccefd679fadc594954edfda01cee1af5092bed3436f89bce2", + "receipt": { + "to": null, + "from": "0x1bb5A9f786a6BA418E8059a877689486A14497a2", + "contractAddress": "0x24D3D52332834ddE93692D9ede4679FE920d2afC", + "transactionIndex": 80, + "gasUsed": "307684", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xbee13d8c7b12d3e5a723dbdf1ce4e18153ba79895bb4520d76c6450bad3791bb", + "transactionHash": "0x2457bc83c867e0eccefd679fadc594954edfda01cee1af5092bed3436f89bce2", + "logs": [], + "blockNumber": 19276130, + "cumulativeGasUsed": "7483339", + "status": 1, + "byzantium": true + }, + "args": [ + "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", + "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "0xae7ab96520de3a18e5e111b5eaab095312d7fe84", + "0xd2ce3fb018805ef92b8C5976cb31F84b4E295F94", + false + ], + "numDeployments": 1, + "solcInputHash": "643c04e89f008dea200654c141acbf47", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"wstETHAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"wETHAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stETHAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"resilientOracleAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"assumeEquivalence\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ZeroAddressNotAllowed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ASSUME_STETH_ETH_EQUIVALENCE\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RESILIENT_ORACLE\",\"outputs\":[{\"internalType\":\"contract OracleInterface\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"STETH\",\"outputs\":[{\"internalType\":\"contract IStETH\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WETH_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WSTETH_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"kind\":\"dev\",\"methods\":{\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"getPrice(address)\":{\"details\":\"Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH or the price of stETH/USD (secondary market price) is obtained from the oracle\",\"params\":{\"asset\":\"Address of wstETH\"},\"returns\":{\"_0\":\"wstETH Price in USD scaled by 1e18\"}}},\"stateVariables\":{\"ASSUME_STETH_ETH_EQUIVALENCE\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"RESILIENT_ORACLE\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"STETH\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"WETH_ADDRESS\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"WSTETH_ADDRESS\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"WstETHOracle\",\"version\":1},\"userdoc\":{\"errors\":{\"ZeroAddressNotAllowed()\":[{\"notice\":\"Thrown if the supplied address is a zero address where it is not allowed\"}]},\"kind\":\"user\",\"methods\":{\"ASSUME_STETH_ETH_EQUIVALENCE()\":{\"notice\":\"A flag assuming 1:1 price equivalence between stETH/ETH\"},\"RESILIENT_ORACLE()\":{\"notice\":\"Address of Resilient Oracle\"},\"STETH()\":{\"notice\":\"Address of stETH\"},\"WETH_ADDRESS()\":{\"notice\":\"Address of WETH\"},\"WSTETH_ADDRESS()\":{\"notice\":\"Address of wstETH\"},\"constructor\":{\"notice\":\"Constructor for the implementation contract.\"},\"getPrice(address)\":{\"notice\":\"Gets the USD price of wstETH asset\"}},\"notice\":\"Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH or the price of stETH/USD (secondary market price) is obtained from the oracle.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/oracles/WstETHOracle.sol\":\"WstETHOracle\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@venusprotocol/solidity-utilities/contracts/constants.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\n/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)\\nuint256 constant EXP_SCALE = 1e18;\\n\\n/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\\nuint256 constant MANTISSA_ONE = EXP_SCALE;\\n\\n/// @dev The approximate number of seconds per year\\nuint256 constant SECONDS_PER_YEAR = 31_536_000;\\n\",\"keccak256\":\"0x0464dd1b882ea2925e06e967c025a232c824e9e4c7aee7b97cc255d040594a59\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/validators.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\n/// @notice Thrown if the supplied address is a zero address where it is not allowed\\nerror ZeroAddressNotAllowed();\\n\\n/// @notice Thrown if the supplied value is 0 where it is not allowed\\nerror ZeroValueNotAllowed();\\n\\n/// @notice Checks if the provided address is nonzero, reverts otherwise\\n/// @param address_ Address to check\\n/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\\nfunction ensureNonzeroAddress(address address_) pure {\\n if (address_ == address(0)) {\\n revert ZeroAddressNotAllowed();\\n }\\n}\\n\\n/// @notice Checks if the provided value is nonzero, reverts otherwise\\n/// @param value_ Value to check\\n/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0\\nfunction ensureNonzeroValue(uint256 value_) pure {\\n if (value_ == 0) {\\n revert ZeroValueNotAllowed();\\n }\\n}\\n\",\"keccak256\":\"0xd55726634a83a862a9cef9d34c41694d3d0fea86cdbc57d6674af066792194b1\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/IStETH.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface IStETH {\\n function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xc298a8004674ce23b9c3b8217285c3c3f926ee3148e58d0dd3863dc7ba9e13e6\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface OracleInterface {\\n function getPrice(address asset) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n\\n function updateAssetPrice(address asset) external;\\n\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address asset) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address asset,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x40031b19684ca0c912e794d08c2c0b0d8be77d3c1bdc937830a0658eff899650\",\"license\":\"BSD-3-Clause\"},\"contracts/oracles/WstETHOracle.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport { OracleInterface } from \\\"../interfaces/OracleInterface.sol\\\";\\nimport { IStETH } from \\\"../interfaces/IStETH.sol\\\";\\nimport { ensureNonzeroAddress } from \\\"@venusprotocol/solidity-utilities/contracts/validators.sol\\\";\\nimport { EXP_SCALE } from \\\"@venusprotocol/solidity-utilities/contracts/constants.sol\\\";\\n\\n/**\\n * @title WstETHOracle\\n * @author Venus\\n * @notice Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH\\n * or the price of stETH/USD (secondary market price) is obtained from the oracle.\\n */\\ncontract WstETHOracle is OracleInterface {\\n /// @notice A flag assuming 1:1 price equivalence between stETH/ETH\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n bool public immutable ASSUME_STETH_ETH_EQUIVALENCE;\\n\\n /// @notice Address of stETH\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IStETH public immutable STETH;\\n\\n /// @notice Address of wstETH\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable WSTETH_ADDRESS;\\n\\n /// @notice Address of WETH\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable WETH_ADDRESS;\\n\\n /// @notice Address of Resilient Oracle\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n OracleInterface public immutable RESILIENT_ORACLE;\\n\\n /// @notice Constructor for the implementation contract.\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n address wstETHAddress,\\n address wETHAddress,\\n address stETHAddress,\\n address resilientOracleAddress,\\n bool assumeEquivalence\\n ) {\\n ensureNonzeroAddress(wstETHAddress);\\n ensureNonzeroAddress(wETHAddress);\\n ensureNonzeroAddress(stETHAddress);\\n ensureNonzeroAddress(resilientOracleAddress);\\n WSTETH_ADDRESS = wstETHAddress;\\n WETH_ADDRESS = wETHAddress;\\n STETH = IStETH(stETHAddress);\\n RESILIENT_ORACLE = OracleInterface(resilientOracleAddress);\\n ASSUME_STETH_ETH_EQUIVALENCE = assumeEquivalence;\\n }\\n\\n /**\\n * @notice Gets the USD price of wstETH asset\\n * @dev Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH\\n * or the price of stETH/USD (secondary market price) is obtained from the oracle\\n * @param asset Address of wstETH\\n * @return wstETH Price in USD scaled by 1e18\\n */\\n function getPrice(address asset) public view returns (uint256) {\\n if (asset != WSTETH_ADDRESS) revert(\\\"wrong wstETH address\\\");\\n\\n // get stETH amount for 1 wstETH scaled by 1e18\\n uint256 stETHAmount = STETH.getPooledEthByShares(1 ether);\\n\\n // price is scaled 1e18 (oracle returns 36 - asset decimal scale)\\n uint256 stETHUSDPrice = RESILIENT_ORACLE.getPrice(ASSUME_STETH_ETH_EQUIVALENCE ? WETH_ADDRESS : address(STETH));\\n\\n // stETHAmount (for 1 wstETH) * stETHUSDPrice / 1e18\\n return (stETHAmount * stETHUSDPrice) / EXP_SCALE;\\n }\\n}\\n\",\"keccak256\":\"0x43e6363cca2563e9e8dc3ec0197001b1fb9c2a8ab8eb76414758d4b185df6aec\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", + "bytecode": "0x61012060405234801561001157600080fd5b50604051610624380380610624833981016040819052610030916100c5565b6100398561007f565b6100428461007f565b61004b8361007f565b6100548261007f565b6001600160a01b0394851660c05292841660e05290831660a052909116610100521515608052610133565b6001600160a01b0381166100a6576040516342bcdf7f60e11b815260040160405180910390fd5b50565b80516001600160a01b03811681146100c057600080fd5b919050565b600080600080600060a086880312156100dd57600080fd5b6100e6866100a9565b94506100f4602087016100a9565b9350610102604087016100a9565b9250610110606087016100a9565b91506080860151801515811461012557600080fd5b809150509295509295909350565b60805160a05160c05160e0516101005161048661019e6000396000818160f8015261028f015260008181606c015261030901526000818160b0015261017c01526000818161011f0152818161021601526102e301526000818161014601526102be01526104866000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063040141e51461006757806336e6372f146100ab57806341976e09146100d2578063a4edcd4c146100f3578063e00bfe501461011a578063ed0142b714610141575b600080fd5b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6100e56100e03660046103b8565b610178565b6040519081526020016100a2565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6101687f000000000000000000000000000000000000000000000000000000000000000081565b60405190151581526020016100a2565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316146101f65760405162461bcd60e51b815260206004820152601460248201527377726f6e6720777374455448206164647265737360601b604482015260640160405180910390fd5b604051630f451f7160e31b8152670de0b6b3a764000060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637a28fb8890602401602060405180830381865afa158015610265573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061028991906103e8565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166341976e097f0000000000000000000000000000000000000000000000000000000000000000610307577f0000000000000000000000000000000000000000000000000000000000000000610329565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561036d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039191906103e8565b9050670de0b6b3a76400006103a68284610401565b6103b0919061042e565b949350505050565b6000602082840312156103ca57600080fd5b81356001600160a01b03811681146103e157600080fd5b9392505050565b6000602082840312156103fa57600080fd5b5051919050565b600081600019048311821515161561042957634e487b7160e01b600052601160045260246000fd5b500290565b60008261044b57634e487b7160e01b600052601260045260246000fd5b50049056fea264697066735822122065ae659d958b7601c08793974dff6c2a473b0d61fc2cd816dbddf7f8b0cbfbb664736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c8063040141e51461006757806336e6372f146100ab57806341976e09146100d2578063a4edcd4c146100f3578063e00bfe501461011a578063ed0142b714610141575b600080fd5b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6100e56100e03660046103b8565b610178565b6040519081526020016100a2565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b6101687f000000000000000000000000000000000000000000000000000000000000000081565b60405190151581526020016100a2565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316146101f65760405162461bcd60e51b815260206004820152601460248201527377726f6e6720777374455448206164647265737360601b604482015260640160405180910390fd5b604051630f451f7160e31b8152670de0b6b3a764000060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637a28fb8890602401602060405180830381865afa158015610265573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061028991906103e8565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166341976e097f0000000000000000000000000000000000000000000000000000000000000000610307577f0000000000000000000000000000000000000000000000000000000000000000610329565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561036d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039191906103e8565b9050670de0b6b3a76400006103a68284610401565b6103b0919061042e565b949350505050565b6000602082840312156103ca57600080fd5b81356001600160a01b03811681146103e157600080fd5b9392505050565b6000602082840312156103fa57600080fd5b5051919050565b600081600019048311821515161561042957634e487b7160e01b600052601160045260246000fd5b500290565b60008261044b57634e487b7160e01b600052601260045260246000fd5b50049056fea264697066735822122065ae659d958b7601c08793974dff6c2a473b0d61fc2cd816dbddf7f8b0cbfbb664736f6c634300080d0033", + "devdoc": { + "author": "Venus", + "kind": "dev", + "methods": { + "constructor": { + "custom:oz-upgrades-unsafe-allow": "constructor" + }, + "getPrice(address)": { + "details": "Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH or the price of stETH/USD (secondary market price) is obtained from the oracle", + "params": { + "asset": "Address of wstETH" + }, + "returns": { + "_0": "wstETH Price in USD scaled by 1e18" + } + } + }, + "stateVariables": { + "ASSUME_STETH_ETH_EQUIVALENCE": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "RESILIENT_ORACLE": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "STETH": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "WETH_ADDRESS": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "WSTETH_ADDRESS": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + } + }, + "title": "WstETHOracle", + "version": 1 + }, + "userdoc": { + "errors": { + "ZeroAddressNotAllowed()": [ + { + "notice": "Thrown if the supplied address is a zero address where it is not allowed" + } + ] + }, + "kind": "user", + "methods": { + "ASSUME_STETH_ETH_EQUIVALENCE()": { + "notice": "A flag assuming 1:1 price equivalence between stETH/ETH" + }, + "RESILIENT_ORACLE()": { + "notice": "Address of Resilient Oracle" + }, + "STETH()": { + "notice": "Address of stETH" + }, + "WETH_ADDRESS()": { + "notice": "Address of WETH" + }, + "WSTETH_ADDRESS()": { + "notice": "Address of wstETH" + }, + "constructor": { + "notice": "Constructor for the implementation contract." + }, + "getPrice(address)": { + "notice": "Gets the USD price of wstETH asset" + } + }, + "notice": "Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH or the price of stETH/USD (secondary market price) is obtained from the oracle.", + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/ethereum/WstETHOracle_NonEquivalence_Proxy.json b/deployments/ethereum/WstETHOracle_NonEquivalence_Proxy.json new file mode 100644 index 00000000..ef78ac19 --- /dev/null +++ b/deployments/ethereum/WstETHOracle_NonEquivalence_Proxy.json @@ -0,0 +1,213 @@ +{ + "address": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xe5f6eb1f53fb632519eb85e168454e1357d3ebbda0536e2d3b06dcff44f8932a", + "receipt": { + "to": null, + "from": "0x1bb5A9f786a6BA418E8059a877689486A14497a2", + "contractAddress": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "transactionIndex": 99, + "gasUsed": "622245", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000800000000000000000000000000000400000000000000800000000000000000000000000040000000000000000000000000000000000080000000000020000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000800", + "blockHash": "0x1695e78f240fbd2c3cb51fcbf602bba30a2ab326aaaa1d4d0a82445b88e992db", + "transactionHash": "0xe5f6eb1f53fb632519eb85e168454e1357d3ebbda0536e2d3b06dcff44f8932a", + "logs": [ + { + "transactionIndex": 99, + "blockNumber": 19276211, + "transactionHash": "0xe5f6eb1f53fb632519eb85e168454e1357d3ebbda0536e2d3b06dcff44f8932a", + "address": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x00000000000000000000000024d3d52332834dde93692d9ede4679fe920d2afc" + ], + "data": "0x", + "logIndex": 181, + "blockHash": "0x1695e78f240fbd2c3cb51fcbf602bba30a2ab326aaaa1d4d0a82445b88e992db" + }, + { + "transactionIndex": 99, + "blockNumber": 19276211, + "transactionHash": "0xe5f6eb1f53fb632519eb85e168454e1357d3ebbda0536e2d3b06dcff44f8932a", + "address": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000567e4cc5e085d09f66f836fa8279f38b4e5866b9", + "logIndex": 182, + "blockHash": "0x1695e78f240fbd2c3cb51fcbf602bba30a2ab326aaaa1d4d0a82445b88e992db" + } + ], + "blockNumber": 19276211, + "cumulativeGasUsed": "7726843", + "status": 1, + "byzantium": true + }, + "args": ["0x24D3D52332834ddE93692D9ede4679FE920d2afC", "0x567e4cc5e085d09f66f836fa8279f38b4e5866b9", "0x"], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"},\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n\\n function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405260405162000f5f38038062000f5f83398101604081905262000026916200044a565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6200052a565b60008051602062000f188339815191521462000075576200007562000550565b62000083828260006200013c565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046200052a565b60008051602062000ef883398151915214620000d357620000d362000550565b6001600160a01b038216608081905260008051602062000ef88339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050620005b9565b620001478362000179565b600082511180620001555750805b156200017457620001728383620001bb60201b620002a91760201c565b505b505050565b6200018481620001ea565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e3838360405180606001604052806027815260200162000f3860279139620002b2565b9392505050565b62000200816200039860201b620002d51760201c565b620002685760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806200029160008051602062000f1883398151915260001b620003a760201b620002411760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606001600160a01b0384163b6200031c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200025f565b600080856001600160a01b03168560405162000339919062000566565b600060405180830381855af49150503d806000811462000376576040519150601f19603f3d011682016040523d82523d6000602084013e6200037b565b606091505b5090925090506200038e828286620003aa565b9695505050505050565b6001600160a01b03163b151590565b90565b60608315620003bb575081620001e3565b825115620003cc5782518084602001fd5b8160405162461bcd60e51b81526004016200025f919062000584565b80516001600160a01b03811681146200040057600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004385781810151838201526020016200041e565b83811115620001725750506000910152565b6000806000606084860312156200046057600080fd5b6200046b84620003e8565b92506200047b60208501620003e8565b60408501519092506001600160401b03808211156200049957600080fd5b818601915086601f830112620004ae57600080fd5b815181811115620004c357620004c362000405565b604051601f8201601f19908116603f01168101908382118183101715620004ee57620004ee62000405565b816040528281528960208487010111156200050857600080fd5b6200051b8360208301602088016200041b565b80955050505050509250925092565b6000828210156200054b57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b600082516200057a8184602087016200041b565b9190910192915050565b6020815260008251806020840152620005a58160408501602087016200041b565b601f01601f19169190910160400192915050565b608051610900620005f86000396000818161011201528181610176015281816102060152818161025e01528181610287015261030901526109006000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/ethereum/solcInputs/2675f6933965af498101c80cb5610aca.json b/deployments/ethereum/solcInputs/2675f6933965af498101c80cb5610aca.json new file mode 100644 index 00000000..34f28028 --- /dev/null +++ b/deployments/ethereum/solcInputs/2675f6933965af498101c80cb5610aca.json @@ -0,0 +1,186 @@ +{ + "language": "Solidity", + "sources": { + "@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorInterface {\n function latestAnswer() external view returns (int256);\n\n function latestTimestamp() external view returns (uint256);\n\n function latestRound() external view returns (uint256);\n\n function getAnswer(uint256 roundId) external view returns (int256);\n\n function getTimestamp(uint256 roundId) external view returns (uint256);\n\n event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);\n\n event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./AggregatorInterface.sol\";\nimport \"./AggregatorV3Interface.sol\";\n\ninterface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface {}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./OwnableUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\n function __Ownable2Step_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable2Step_init_unchained() internal onlyInitializing {\n }\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() public virtual {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(account),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(address from, address to, uint256 amount) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(address owner, address spender, uint256 amount) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/utils/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1, \"Math: mulDiv overflow\");\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/SignedMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toString(int256 value) internal pure returns (string memory) {\n return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value))));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\n\nimport \"./IAccessControlManagerV8.sol\";\n\n/**\n * @title AccessControlledV8\n * @author Venus\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\n */\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\n /// @notice Access control manager contract\n IAccessControlManagerV8 private _accessControlManager;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n\n /// @notice Emitted when access control manager contract address is changed\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\n\n /// @notice Thrown when the action is prohibited by AccessControlManager\n error Unauthorized(address sender, address calledContract, string methodSignature);\n\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\n __Ownable2Step_init();\n __AccessControlled_init_unchained(accessControlManager_);\n }\n\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\n _setAccessControlManager(accessControlManager_);\n }\n\n /**\n * @notice Sets the address of AccessControlManager\n * @dev Admin function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n * @custom:event Emits NewAccessControlManager event\n * @custom:access Only Governance\n */\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\n _setAccessControlManager(accessControlManager_);\n }\n\n /**\n * @notice Returns the address of the access control manager contract\n */\n function accessControlManager() external view returns (IAccessControlManagerV8) {\n return _accessControlManager;\n }\n\n /**\n * @dev Internal function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n */\n function _setAccessControlManager(address accessControlManager_) internal {\n require(address(accessControlManager_) != address(0), \"invalid acess control manager address\");\n address oldAccessControlManager = address(_accessControlManager);\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\n }\n\n /**\n * @notice Reverts if the call is not allowed by AccessControlManager\n * @param signature Method signature\n */\n function _checkAccessAllowed(string memory signature) internal view {\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\n\n if (!isAllowedToCall) {\n revert Unauthorized(msg.sender, address(this), signature);\n }\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"./IAccessControlManagerV8.sol\";\n\n/**\n * @title AccessControlManager\n * @author Venus\n * @dev This contract is a wrapper of OpenZeppelin AccessControl extending it in a way to standartize access control within Venus Smart Contract Ecosystem.\n * @notice Access control plays a crucial role in the Venus governance model. It is used to restrict functions so that they can only be called from one\n * account or list of accounts (EOA or Contract Accounts).\n *\n * The implementation of `AccessControlManager`(https://github.com/VenusProtocol/governance-contracts/blob/main/contracts/Governance/AccessControlManager.sol)\n * inherits the [Open Zeppelin AccessControl](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol)\n * contract as a base for role management logic. There are two role types: admin and granular permissions.\n * \n * ## Granular Roles\n * \n * Granular roles are built by hashing the contract address and its function signature. For example, given contract `Foo` with function `Foo.bar()` which\n * is guarded by ACM, calling `giveRolePermission` for account B do the following:\n * \n * 1. Compute `keccak256(contractFooAddress,functionSignatureBar)`\n * 1. Add the computed role to the roles of account B\n * 1. Account B now can call `ContractFoo.bar()`\n * \n * ## Admin Roles\n * \n * Admin roles allow for an address to call a function signature on any contract guarded by the `AccessControlManager`. This is particularly useful for\n * contracts created by factories.\n * \n * For Admin roles a null address is hashed in place of the contract address (`keccak256(0x0000000000000000000000000000000000000000,functionSignatureBar)`.\n * \n * In the previous example, giving account B the admin role, account B will have permissions to call the `bar()` function on any contract that is guarded by\n * ACM, not only contract A.\n * \n * ## Protocol Integration\n * \n * All restricted functions in Venus Protocol use a hook to ACM in order to check if the caller has the right permission to call the guarded function.\n * `AccessControlledV5` and `AccessControlledV8` abstract contract makes this integration easier. They call ACM's external method\n * `isAllowedToCall(address caller, string functionSig)`. Here is an example of how `setCollateralFactor` function in `Comptroller` is integrated with ACM:\n\n```\n contract Comptroller is [...] AccessControlledV8 {\n [...]\n function setCollateralFactor(VToken vToken, uint256 newCollateralFactorMantissa, uint256 newLiquidationThresholdMantissa) external {\n _checkAccessAllowed(\"setCollateralFactor(address,uint256,uint256)\");\n [...]\n }\n }\n```\n */\ncontract AccessControlManager is AccessControl, IAccessControlManagerV8 {\n /// @notice Emitted when an account is given a permission to a certain contract function\n /// @dev If contract address is 0x000..0 this means that the account is a default admin of this function and\n /// can call any contract function with this signature\n event PermissionGranted(address account, address contractAddress, string functionSig);\n\n /// @notice Emitted when an account is revoked a permission to a certain contract function\n event PermissionRevoked(address account, address contractAddress, string functionSig);\n\n constructor() {\n // Grant the contract deployer the default admin role: it will be able\n // to grant and revoke any roles\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n }\n\n /**\n * @notice Gives a function call permission to one single account\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\n * @param contractAddress address of contract for which call permissions will be granted\n * @dev if contractAddress is zero address, the account can access the specified function\n * on **any** contract managed by this ACL\n * @param functionSig signature e.g. \"functionName(uint256,bool)\"\n * @param accountToPermit account that will be given access to the contract function\n * @custom:event Emits a {RoleGranted} and {PermissionGranted} events.\n */\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) public {\n bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));\n grantRole(role, accountToPermit);\n emit PermissionGranted(accountToPermit, contractAddress, functionSig);\n }\n\n /**\n * @notice Revokes an account's permission to a particular function call\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\n * \t\tMay emit a {RoleRevoked} event.\n * @param contractAddress address of contract for which call permissions will be revoked\n * @param functionSig signature e.g. \"functionName(uint256,bool)\"\n * @custom:event Emits {RoleRevoked} and {PermissionRevoked} events.\n */\n function revokeCallPermission(\n address contractAddress,\n string calldata functionSig,\n address accountToRevoke\n ) public {\n bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));\n revokeRole(role, accountToRevoke);\n emit PermissionRevoked(accountToRevoke, contractAddress, functionSig);\n }\n\n /**\n * @notice Verifies if the given account can call a contract's guarded function\n * @dev Since restricted contracts using this function as a permission hook, we can get contracts address with msg.sender\n * @param account for which call permissions will be checked\n * @param functionSig restricted function signature e.g. \"functionName(uint256,bool)\"\n * @return false if the user account cannot call the particular contract function\n *\n */\n function isAllowedToCall(address account, string calldata functionSig) public view returns (bool) {\n bytes32 role = keccak256(abi.encodePacked(msg.sender, functionSig));\n\n if (hasRole(role, account)) {\n return true;\n } else {\n role = keccak256(abi.encodePacked(address(0), functionSig));\n return hasRole(role, account);\n }\n }\n\n /**\n * @notice Verifies if the given account can call a contract's guarded function\n * @dev This function is used as a view function to check permissions rather than contract hook for access restriction check.\n * @param account for which call permissions will be checked against\n * @param contractAddress address of the restricted contract\n * @param functionSig signature of the restricted function e.g. \"functionName(uint256,bool)\"\n * @return false if the user account cannot call the particular contract function\n */\n function hasPermission(\n address account,\n address contractAddress,\n string calldata functionSig\n ) public view returns (bool) {\n bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));\n return hasRole(role, account);\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/access/IAccessControl.sol\";\n\n/**\n * @title IAccessControlManagerV8\n * @author Venus\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\n */\ninterface IAccessControlManagerV8 is IAccessControl {\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\n\n function revokeCallPermission(\n address contractAddress,\n string calldata functionSig,\n address accountToRevoke\n ) external;\n\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\n\n function hasPermission(\n address account,\n address contractAddress,\n string calldata functionSig\n ) external view returns (bool);\n}\n" + }, + "@venusprotocol/solidity-utilities/contracts/constants.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\n/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)\nuint256 constant EXP_SCALE = 1e18;\n\n/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\nuint256 constant MANTISSA_ONE = EXP_SCALE;\n\n/// @dev The approximate number of seconds per year\nuint256 constant SECONDS_PER_YEAR = 31_536_000;\n" + }, + "@venusprotocol/solidity-utilities/contracts/validators.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\n/// @notice Thrown if the supplied address is a zero address where it is not allowed\nerror ZeroAddressNotAllowed();\n\n/// @notice Thrown if the supplied value is 0 where it is not allowed\nerror ZeroValueNotAllowed();\n\n/// @notice Checks if the provided address is nonzero, reverts otherwise\n/// @param address_ Address to check\n/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\nfunction ensureNonzeroAddress(address address_) pure {\n if (address_ == address(0)) {\n revert ZeroAddressNotAllowed();\n }\n}\n\n/// @notice Checks if the provided value is nonzero, reverts otherwise\n/// @param value_ Value to check\n/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0\nfunction ensureNonzeroValue(uint256 value_) pure {\n if (value_ == 0) {\n revert ZeroValueNotAllowed();\n }\n}\n" + }, + "contracts/interfaces/FeedRegistryInterface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\ninterface FeedRegistryInterface {\n function latestRoundDataByName(\n string memory base,\n string memory quote\n )\n external\n view\n returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);\n\n function decimalsByName(string memory base, string memory quote) external view returns (uint8);\n}\n" + }, + "contracts/interfaces/IStETH.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\ninterface IStETH {\n function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);\n}\n" + }, + "contracts/interfaces/OracleInterface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\ninterface OracleInterface {\n function getPrice(address asset) external view returns (uint256);\n}\n\ninterface ResilientOracleInterface is OracleInterface {\n function updatePrice(address vToken) external;\n\n function updateAssetPrice(address asset) external;\n\n function getUnderlyingPrice(address vToken) external view returns (uint256);\n}\n\ninterface TwapInterface is OracleInterface {\n function updateTwap(address asset) external returns (uint256);\n}\n\ninterface BoundValidatorInterface {\n function validatePriceWithAnchorPrice(\n address asset,\n uint256 reporterPrice,\n uint256 anchorPrice\n ) external view returns (bool);\n}\n" + }, + "contracts/interfaces/PublicResolverInterface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\ninterface PublicResolverInterface {\n function addr(bytes32 node) external view returns (address payable);\n}\n" + }, + "contracts/interfaces/PythInterface.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\n// SPDX-FileCopyrightText: 2021 Pyth Data Foundation\npragma solidity 0.8.13;\n\ncontract PythStructs {\n // A price with a degree of uncertainty, represented as a price +- a confidence interval.\n //\n // The confidence interval roughly corresponds to the standard error of a normal distribution.\n // Both the price and confidence are stored in a fixed-point numeric representation,\n // `x * (10^expo)`, where `expo` is the exponent.\n //\n // Please refer to the documentation at https://docs.pyth.network/consumers/best-practices for how\n // to how this price safely.\n struct Price {\n // Price\n int64 price;\n // Confidence interval around the price\n uint64 conf;\n // Price exponent\n int32 expo;\n // Unix timestamp describing when the price was published\n uint256 publishTime;\n }\n\n // PriceFeed represents a current aggregate price from pyth publisher feeds.\n struct PriceFeed {\n // The price ID.\n bytes32 id;\n // Latest available price\n Price price;\n // Latest available exponentially-weighted moving average price\n Price emaPrice;\n }\n}\n\n/// @title Consume prices from the Pyth Network (https://pyth.network/).\n/// @dev Please refer to the guidance at https://docs.pyth.network/consumers/best-practices\n/// for how to consume prices safely.\n/// @author Pyth Data Association\ninterface IPyth {\n /// @dev Emitted when an update for price feed with `id` is processed successfully.\n /// @param id The Pyth Price Feed ID.\n /// @param fresh True if the price update is more recent and stored.\n /// @param chainId ID of the source chain that the batch price update containing this price.\n /// This value comes from Wormhole, and you can find the corresponding chains\n /// at https://docs.wormholenetwork.com/wormhole/contracts.\n /// @param sequenceNumber Sequence number of the batch price update containing this price.\n /// @param lastPublishTime Publish time of the previously stored price.\n /// @param publishTime Publish time of the given price update.\n /// @param price Price of the given price update.\n /// @param conf Confidence interval of the given price update.\n event PriceFeedUpdate(\n bytes32 indexed id,\n bool indexed fresh,\n uint16 chainId,\n uint64 sequenceNumber,\n uint256 lastPublishTime,\n uint256 publishTime,\n int64 price,\n uint64 conf\n );\n\n /// @dev Emitted when a batch price update is processed successfully.\n /// @param chainId ID of the source chain that the batch price update comes from.\n /// @param sequenceNumber Sequence number of the batch price update.\n /// @param batchSize Number of prices within the batch price update.\n /// @param freshPricesInBatch Number of prices that were more recent and were stored.\n event BatchPriceFeedUpdate(uint16 chainId, uint64 sequenceNumber, uint256 batchSize, uint256 freshPricesInBatch);\n\n /// @dev Emitted when a call to `updatePriceFeeds` is processed successfully.\n /// @param sender Sender of the call (`msg.sender`).\n /// @param batchCount Number of batches that this function processed.\n /// @param fee Amount of paid fee for updating the prices.\n event UpdatePriceFeeds(address indexed sender, uint256 batchCount, uint256 fee);\n\n /// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time\n function getValidTimePeriod() external view returns (uint256 validTimePeriod);\n\n /// @notice Returns the price and confidence interval.\n /// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds.\n /// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getPrice(bytes32 id) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the exponentially-weighted moving average price and confidence interval.\n /// @dev Reverts if the EMA price is not available.\n /// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getEmaPrice(bytes32 id) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the price of a price feed without any sanity checks.\n /// @dev This function returns the most recent price update in this contract without any recency checks.\n /// This function is unsafe as the returned price update may be arbitrarily far in the past.\n ///\n /// Users of this function should check the `publishTime` in the price to ensure that the returned price is\n /// sufficiently recent for their application. If you are considering using this function, it may be\n /// safer / easier to use either `getPrice` or `getPriceNoOlderThan`.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getPriceUnsafe(bytes32 id) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the price that is no older than `age` seconds of the current time.\n /// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in\n /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently\n /// recently.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getPriceNoOlderThan(bytes32 id, uint256 age) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks.\n /// @dev This function returns the same price as `getEmaPrice` in the case where the price is available.\n /// However, if the price is not recent this function returns the latest available price.\n ///\n /// The returned price can be from arbitrarily far in the past; this function makes no guarantees that\n /// the returned price is recent or useful for any particular application.\n ///\n /// Users of this function should check the `publishTime` in the price to ensure that the returned price is\n /// sufficiently recent for their application. If you are considering using this function, it may be\n /// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getEmaPriceUnsafe(bytes32 id) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds\n /// of the current time.\n /// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in\n /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently\n /// recently.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getEmaPriceNoOlderThan(bytes32 id, uint256 age) external view returns (PythStructs.Price memory price);\n\n /// @notice Update price feeds with given update messages.\n /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling\n /// `getUpdateFee` with the length of the `updateData` array.\n /// Prices will be updated if they are more recent than the current stored prices.\n /// The call will succeed even if the update is not the most recent.\n /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.\n /// @param updateData Array of price update data.\n function updatePriceFeeds(bytes[] calldata updateData) external payable;\n\n /// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is\n /// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the\n /// given `publishTimes` for the price feeds and does not read the actual price\n /// update publish time within `updateData`.\n ///\n /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling\n /// `getUpdateFee` with the length of the `updateData` array.\n ///\n /// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime\n /// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have\n /// a newer or equal publish time than the given publish time, it will reject the transaction to save gas.\n /// Otherwise, it calls updatePriceFeeds method to update the prices.\n ///\n /// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid.\n /// @param updateData Array of price update data.\n /// @param priceIds Array of price ids.\n /// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]`\n function updatePriceFeedsIfNecessary(\n bytes[] calldata updateData,\n bytes32[] calldata priceIds,\n uint64[] calldata publishTimes\n ) external payable;\n\n /// @notice Returns the required fee to update an array of price updates.\n /// @param updateDataSize Number of price updates.\n /// @return feeAmount The required fee in Wei.\n function getUpdateFee(uint256 updateDataSize) external view returns (uint256 feeAmount);\n}\n\nabstract contract AbstractPyth is IPyth {\n /// @notice Returns the price feed with given id.\n /// @dev Reverts if the price does not exist.\n /// @param id The Pyth Price Feed ID of which to fetch the PriceFeed.\n function queryPriceFeed(bytes32 id) public view virtual returns (PythStructs.PriceFeed memory priceFeed);\n\n /// @notice Returns true if a price feed with the given id exists.\n /// @param id The Pyth Price Feed ID of which to check its existence.\n function priceFeedExists(bytes32 id) public view virtual returns (bool exists);\n\n function getValidTimePeriod() public view virtual override returns (uint256 validTimePeriod);\n\n function getPrice(bytes32 id) external view override returns (PythStructs.Price memory price) {\n return getPriceNoOlderThan(id, getValidTimePeriod());\n }\n\n function getEmaPrice(bytes32 id) external view override returns (PythStructs.Price memory price) {\n return getEmaPriceNoOlderThan(id, getValidTimePeriod());\n }\n\n function getPriceUnsafe(bytes32 id) public view override returns (PythStructs.Price memory price) {\n PythStructs.PriceFeed memory priceFeed = queryPriceFeed(id);\n return priceFeed.price;\n }\n\n function getPriceNoOlderThan(\n bytes32 id,\n uint256 age\n ) public view override returns (PythStructs.Price memory price) {\n price = getPriceUnsafe(id);\n\n require(diff(block.timestamp, price.publishTime) <= age, \"no price available which is recent enough\");\n\n return price;\n }\n\n function getEmaPriceUnsafe(bytes32 id) public view override returns (PythStructs.Price memory price) {\n PythStructs.PriceFeed memory priceFeed = queryPriceFeed(id);\n return priceFeed.emaPrice;\n }\n\n function getEmaPriceNoOlderThan(\n bytes32 id,\n uint256 age\n ) public view override returns (PythStructs.Price memory price) {\n price = getEmaPriceUnsafe(id);\n\n require(diff(block.timestamp, price.publishTime) <= age, \"no ema price available which is recent enough\");\n\n return price;\n }\n\n function diff(uint256 x, uint256 y) internal pure returns (uint256) {\n if (x > y) {\n return x - y;\n } else {\n return y - x;\n }\n }\n\n // Access modifier is overridden to public to be able to call it locally.\n function updatePriceFeeds(bytes[] calldata updateData) public payable virtual override;\n\n function updatePriceFeedsIfNecessary(\n bytes[] calldata updateData,\n bytes32[] calldata priceIds,\n uint64[] calldata publishTimes\n ) external payable override {\n require(priceIds.length == publishTimes.length, \"priceIds and publishTimes arrays should have same length\");\n\n bool updateNeeded = false;\n for (uint256 i = 0; i < priceIds.length; ) {\n if (!priceFeedExists(priceIds[i]) || queryPriceFeed(priceIds[i]).price.publishTime < publishTimes[i]) {\n updateNeeded = true;\n break;\n }\n unchecked {\n i++;\n }\n }\n\n require(updateNeeded, \"no prices in the submitted batch have fresh prices, so this update will have no effect\");\n\n updatePriceFeeds(updateData);\n }\n}\n" + }, + "contracts/interfaces/SIDRegistryInterface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\ninterface SIDRegistryInterface {\n function resolver(bytes32 node) external view returns (address);\n}\n" + }, + "contracts/interfaces/VBep20Interface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\ninterface VBep20Interface is IERC20Metadata {\n /**\n * @notice Underlying asset for this VToken\n */\n function underlying() external view returns (address);\n}\n" + }, + "contracts/libraries/PancakeLibrary.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\ninterface IPancakePair {\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n\n function price0CumulativeLast() external view returns (uint256);\n\n function price1CumulativeLast() external view returns (uint256);\n}\n\nlibrary FixedPoint {\n // range: [0, 2**112 - 1]\n // resolution: 1 / 2**112\n struct uq112x112 {\n uint224 _x;\n }\n\n // returns a uq112x112 which represents the ratio of the numerator to the denominator\n // equivalent to encode(numerator).div(denominator)\n function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {\n require(denominator > 0, \"FixedPoint: DIV_BY_ZERO\");\n return uq112x112((uint224(numerator) << 112) / denominator);\n }\n\n // decode a uq112x112 into a uint with 18 decimals of precision\n function decode112with18(uq112x112 memory self) internal pure returns (uint256) {\n // we only have 256 - 224 = 32 bits to spare, so scaling up by ~60 bits is dangerous\n // instead, get close to:\n // (x * 1e18) >> 112\n // without risk of overflowing, e.g.:\n // (x) / 2 ** (112 - lg(1e18))\n return uint256(self._x) / 5192296858534827;\n }\n}\n\n// library with helper methods for oracles that are concerned with computing average prices\nlibrary PancakeOracleLibrary {\n using FixedPoint for *;\n\n // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]\n function currentBlockTimestamp() internal view returns (uint32) {\n return uint32(block.timestamp % 2 ** 32);\n }\n\n // produces the cumulative price using counterfactuals to save gas and avoid a call to sync.\n function currentCumulativePrices(\n address pair\n ) internal view returns (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) {\n blockTimestamp = currentBlockTimestamp();\n price0Cumulative = IPancakePair(pair).price0CumulativeLast();\n price1Cumulative = IPancakePair(pair).price1CumulativeLast();\n\n // if time has elapsed since the last update on the pair, mock the accumulated price values\n (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IPancakePair(pair).getReserves();\n if (blockTimestampLast != blockTimestamp) {\n unchecked {\n // subtraction overflow is desired\n uint32 timeElapsed = blockTimestamp - blockTimestampLast;\n // addition overflow is desired\n // counterfactual\n price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;\n // counterfactual\n price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;\n }\n }\n }\n}\n" + }, + "contracts/oracles/BinanceOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"../interfaces/SIDRegistryInterface.sol\";\nimport \"../interfaces/FeedRegistryInterface.sol\";\nimport \"../interfaces/PublicResolverInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport \"../interfaces/OracleInterface.sol\";\n\n/**\n * @title BinanceOracle\n * @author Venus\n * @notice This oracle fetches price of assets from Binance.\n */\ncontract BinanceOracle is AccessControlledV8, OracleInterface {\n /// @notice Used to fetch feed registry address.\n address public sidRegistryAddress;\n\n /// @notice Set this as asset address for BNB. This is the underlying address for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Max stale period configuration for assets\n mapping(string => uint256) public maxStalePeriod;\n\n /// @notice Override symbols to be compatible with Binance feed registry\n mapping(string => string) public symbols;\n\n /// @notice Used to fetch price of assets used directly when space ID is not supported by current chain.\n address public feedRegistryAddress;\n\n /// @notice Emits when asset stale period is updated.\n event MaxStalePeriodAdded(string indexed asset, uint256 maxStalePeriod);\n\n /// @notice Emits when symbol of the asset is updated.\n event SymbolOverridden(string indexed symbol, string overriddenSymbol);\n\n /// @notice Emits when address of feed registry is updated.\n event FeedRegistryUpdated(address indexed oldFeedRegistry, address indexed newFeedRegistry);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Sets the contracts required to fetch prices\n * @param _sidRegistryAddress Address of SID registry\n * @param _accessControlManager Address of the access control manager contract\n */\n function initialize(address _sidRegistryAddress, address _accessControlManager) external initializer {\n sidRegistryAddress = _sidRegistryAddress;\n __AccessControlled_init(_accessControlManager);\n }\n\n /**\n * @notice Used to set the max stale period of an asset\n * @param symbol The symbol of the asset\n * @param _maxStalePeriod The max stake period\n */\n function setMaxStalePeriod(string memory symbol, uint256 _maxStalePeriod) external {\n _checkAccessAllowed(\"setMaxStalePeriod(string,uint256)\");\n if (_maxStalePeriod == 0) revert(\"stale period can't be zero\");\n if (bytes(symbol).length == 0) revert(\"symbol cannot be empty\");\n\n maxStalePeriod[symbol] = _maxStalePeriod;\n emit MaxStalePeriodAdded(symbol, _maxStalePeriod);\n }\n\n /**\n * @notice Used to override a symbol when fetching price\n * @param symbol The symbol to override\n * @param overrideSymbol The symbol after override\n */\n function setSymbolOverride(string calldata symbol, string calldata overrideSymbol) external {\n _checkAccessAllowed(\"setSymbolOverride(string,string)\");\n if (bytes(symbol).length == 0) revert(\"symbol cannot be empty\");\n\n symbols[symbol] = overrideSymbol;\n emit SymbolOverridden(symbol, overrideSymbol);\n }\n\n /**\n * @notice Used to set feed registry address when current chain does not support space ID.\n * @param newfeedRegistryAddress Address of new feed registry.\n */\n function setFeedRegistryAddress(\n address newfeedRegistryAddress\n ) external notNullAddress(newfeedRegistryAddress) onlyOwner {\n if (sidRegistryAddress != address(0)) revert(\"sidRegistryAddress must be zero\");\n emit FeedRegistryUpdated(feedRegistryAddress, newfeedRegistryAddress);\n feedRegistryAddress = newfeedRegistryAddress;\n }\n\n /**\n * @notice Uses Space ID to fetch the feed registry address\n * @return feedRegistryAddress Address of binance oracle feed registry.\n */\n function getFeedRegistryAddress() public view returns (address) {\n bytes32 nodeHash = 0x94fe3821e0768eb35012484db4df61890f9a6ca5bfa984ef8ff717e73139faff;\n\n SIDRegistryInterface sidRegistry = SIDRegistryInterface(sidRegistryAddress);\n address publicResolverAddress = sidRegistry.resolver(nodeHash);\n PublicResolverInterface publicResolver = PublicResolverInterface(publicResolverAddress);\n\n return publicResolver.addr(nodeHash);\n }\n\n /**\n * @notice Gets the price of a asset from the binance oracle\n * @param asset Address of the asset\n * @return Price in USD\n */\n function getPrice(address asset) public view returns (uint256) {\n string memory symbol;\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n symbol = \"BNB\";\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n symbol = token.symbol();\n decimals = token.decimals();\n }\n\n string memory overrideSymbol = symbols[symbol];\n\n if (bytes(overrideSymbol).length != 0) {\n symbol = overrideSymbol;\n }\n\n return _getPrice(symbol, decimals);\n }\n\n function _getPrice(string memory symbol, uint256 decimals) internal view returns (uint256) {\n FeedRegistryInterface feedRegistry;\n\n if (sidRegistryAddress != address(0)) {\n // If sidRegistryAddress is available, fetch feedRegistryAddress from sidRegistry\n feedRegistry = FeedRegistryInterface(getFeedRegistryAddress());\n } else {\n // Use feedRegistry directly if sidRegistryAddress is not available\n feedRegistry = FeedRegistryInterface(feedRegistryAddress);\n }\n\n (, int256 answer, , uint256 updatedAt, ) = feedRegistry.latestRoundDataByName(symbol, \"USD\");\n if (answer <= 0) revert(\"invalid binance oracle price\");\n if (block.timestamp < updatedAt) revert(\"updatedAt exceeds block time\");\n\n uint256 deltaTime;\n unchecked {\n deltaTime = block.timestamp - updatedAt;\n }\n if (deltaTime > maxStalePeriod[symbol]) revert(\"binance oracle price expired\");\n\n uint256 decimalDelta = feedRegistry.decimalsByName(symbol, \"USD\");\n return (uint256(answer) * (10 ** (18 - decimalDelta))) * (10 ** (18 - decimals));\n }\n}\n" + }, + "contracts/oracles/BoundValidator.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title BoundValidator\n * @author Venus\n * @notice The BoundValidator contract is used to validate prices fetched from two different sources.\n * Each asset has an upper and lower bound ratio set in the config. In order for a price to be valid\n * it must fall within this range of the validator price.\n */\ncontract BoundValidator is AccessControlledV8, BoundValidatorInterface {\n struct ValidateConfig {\n /// @notice asset address\n address asset;\n /// @notice Upper bound of deviation between reported price and anchor price,\n /// beyond which the reported price will be invalidated\n uint256 upperBoundRatio;\n /// @notice Lower bound of deviation between reported price and anchor price,\n /// below which the reported price will be invalidated\n uint256 lowerBoundRatio;\n }\n\n /// @notice validation configs by asset\n mapping(address => ValidateConfig) public validateConfigs;\n\n /// @notice Emit this event when new validation configs are added\n event ValidateConfigAdded(address indexed asset, uint256 indexed upperBound, uint256 indexed lowerBound);\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Add multiple validation configs at the same time\n * @param configs Array of validation configs\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the config array is 0\n * @custom:event Emits ValidateConfigAdded for each validation config that is successfully set\n */\n function setValidateConfigs(ValidateConfig[] memory configs) external {\n uint256 length = configs.length;\n if (length == 0) revert(\"invalid validate config length\");\n for (uint256 i; i < length; ) {\n setValidateConfig(configs[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Add a single validation config\n * @param config Validation config struct\n * @custom:access Only Governance\n * @custom:error Null address error is thrown if asset address is null\n * @custom:error Range error thrown if bound ratio is not positive\n * @custom:error Range error thrown if lower bound is greater than or equal to upper bound\n * @custom:event Emits ValidateConfigAdded when a validation config is successfully set\n */\n function setValidateConfig(ValidateConfig memory config) public {\n _checkAccessAllowed(\"setValidateConfig(ValidateConfig)\");\n\n if (config.asset == address(0)) revert(\"asset can't be zero address\");\n if (config.upperBoundRatio == 0 || config.lowerBoundRatio == 0) revert(\"bound must be positive\");\n if (config.upperBoundRatio <= config.lowerBoundRatio) revert(\"upper bound must be higher than lowner bound\");\n validateConfigs[config.asset] = config;\n emit ValidateConfigAdded(config.asset, config.upperBoundRatio, config.lowerBoundRatio);\n }\n\n /**\n * @notice Test reported asset price against anchor price\n * @param asset asset address\n * @param reportedPrice The price to be tested\n * @custom:error Missing error thrown if asset config is not set\n * @custom:error Price error thrown if anchor price is not valid\n */\n function validatePriceWithAnchorPrice(\n address asset,\n uint256 reportedPrice,\n uint256 anchorPrice\n ) public view virtual override returns (bool) {\n if (validateConfigs[asset].upperBoundRatio == 0) revert(\"validation config not exist\");\n if (anchorPrice == 0) revert(\"anchor price is not valid\");\n return _isWithinAnchor(asset, reportedPrice, anchorPrice);\n }\n\n /**\n * @notice Test whether the reported price is within the valid bounds\n * @param asset Asset address\n * @param reportedPrice The price to be tested\n * @param anchorPrice The reported price must be within the the valid bounds of this price\n */\n function _isWithinAnchor(address asset, uint256 reportedPrice, uint256 anchorPrice) private view returns (bool) {\n if (reportedPrice != 0) {\n // we need to multiply anchorPrice by 1e18 to make the ratio 18 decimals\n uint256 anchorRatio = (anchorPrice * 1e18) / reportedPrice;\n uint256 upperBoundAnchorRatio = validateConfigs[asset].upperBoundRatio;\n uint256 lowerBoundAnchorRatio = validateConfigs[asset].lowerBoundRatio;\n return anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio;\n }\n return false;\n }\n\n // BoundValidator is to get inherited, so it's a good practice to add some storage gaps like\n // OpenZepplin proposed in their contracts: https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n // solhint-disable-next-line\n uint256[49] private __gap;\n}\n" + }, + "contracts/oracles/ChainlinkOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ChainlinkOracle\n * @author Venus\n * @notice This oracle fetches prices of assets from the Chainlink oracle.\n */\ncontract ChainlinkOracle is AccessControlledV8, OracleInterface {\n struct TokenConfig {\n /// @notice Underlying token address, which can't be a null address\n /// @notice Used to check if a token is supported\n /// @notice 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB address for native tokens\n /// (e.g BNB for BNB chain, ETH for Ethereum network)\n address asset;\n /// @notice Chainlink feed address\n address feed;\n /// @notice Price expiration period of this asset\n uint256 maxStalePeriod;\n }\n\n /// @notice Set this as asset address for native token on each chain.\n /// This is the underlying address for vBNB on BNB chain or an underlying asset for a native market on any chain.\n address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Manually set an override price, useful under extenuating conditions such as price feed failure\n mapping(address => uint256) public prices;\n\n /// @notice Token config by assets\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when a price is manually set\n event PricePosted(address indexed asset, uint256 previousPriceMantissa, uint256 newPriceMantissa);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed asset, address feed, uint256 maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Manually set the price of a given asset\n * @param asset Asset address\n * @param price Asset price in 18 decimals\n * @custom:access Only Governance\n * @custom:event Emits PricePosted event on succesfully setup of asset price\n */\n function setDirectPrice(address asset, uint256 price) external notNullAddress(asset) {\n _checkAccessAllowed(\"setDirectPrice(address,uint256)\");\n\n uint256 previousPriceMantissa = prices[asset];\n prices[asset] = price;\n emit PricePosted(asset, previousPriceMantissa, price);\n }\n\n /**\n * @notice Add multiple token configs at the same time\n * @param tokenConfigs_ config array\n * @custom:access Only Governance\n * @custom:error Zero length error thrown, if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Add single token config. asset & feed cannot be null addresses and maxStalePeriod must be positive\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error NotNullAddress error is thrown if token feed address is null\n * @custom:error Range error is thrown if maxStale period of token is not greater than zero\n * @custom:event Emits TokenConfigAdded event on succesfully setting of the token config\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.feed) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n if (tokenConfig.maxStalePeriod == 0) revert(\"stale period can't be zero\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.feed, tokenConfig.maxStalePeriod);\n }\n\n /**\n * @notice Gets the price of a asset from the chainlink oracle\n * @param asset Address of the asset\n * @return Price in USD from Chainlink or a manually set price for the asset\n */\n function getPrice(address asset) public view returns (uint256) {\n uint256 decimals;\n\n if (asset == NATIVE_TOKEN_ADDR) {\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n return _getPriceInternal(asset, decimals);\n }\n\n /**\n * @notice Gets the Chainlink price for a given asset\n * @param asset address of the asset\n * @param decimals decimals of the asset\n * @return price Asset price in USD or a manually set price of the asset\n */\n function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256 price) {\n uint256 tokenPrice = prices[asset];\n if (tokenPrice != 0) {\n price = tokenPrice;\n } else {\n price = _getChainlinkPrice(asset);\n }\n\n uint256 decimalDelta = 18 - decimals;\n return price * (10 ** decimalDelta);\n }\n\n /**\n * @notice Get the Chainlink price for an asset, revert if token config doesn't exist\n * @dev The precision of the price feed is used to ensure the returned price has 18 decimals of precision\n * @param asset Address of the asset\n * @return price Price in USD, with 18 decimals of precision\n * @custom:error NotNullAddress error is thrown if the asset address is null\n * @custom:error Price error is thrown if the Chainlink price of asset is not greater than zero\n * @custom:error Timing error is thrown if current timestamp is less than the last updatedAt timestamp\n * @custom:error Timing error is thrown if time difference between current time and last updated time\n * is greater than maxStalePeriod\n */\n function _getChainlinkPrice(\n address asset\n ) private view notNullAddress(tokenConfigs[asset].asset) returns (uint256) {\n TokenConfig memory tokenConfig = tokenConfigs[asset];\n AggregatorV3Interface feed = AggregatorV3Interface(tokenConfig.feed);\n\n // note: maxStalePeriod cannot be 0\n uint256 maxStalePeriod = tokenConfig.maxStalePeriod;\n\n // Chainlink USD-denominated feeds store answers at 8 decimals, mostly\n uint256 decimalDelta = 18 - feed.decimals();\n\n (, int256 answer, , uint256 updatedAt, ) = feed.latestRoundData();\n if (answer <= 0) revert(\"chainlink price must be positive\");\n if (block.timestamp < updatedAt) revert(\"updatedAt exceeds block time\");\n\n uint256 deltaTime;\n unchecked {\n deltaTime = block.timestamp - updatedAt;\n }\n\n if (deltaTime > maxStalePeriod) revert(\"chainlink price expired\");\n\n return uint256(answer) * (10 ** decimalDelta);\n }\n}\n" + }, + "contracts/oracles/mocks/MockBinanceFeedRegistry.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"../../interfaces/FeedRegistryInterface.sol\";\n\ncontract MockBinanceFeedRegistry is FeedRegistryInterface {\n mapping(string => uint256) public assetPrices;\n\n function setAssetPrice(string memory base, uint256 price) external {\n assetPrices[base] = price;\n }\n\n function latestRoundDataByName(\n string memory base,\n string memory quote\n )\n external\n view\n override\n returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)\n {\n quote;\n return (0, int256(assetPrices[base]), 0, block.timestamp - 10, 0);\n }\n\n function decimalsByName(string memory base, string memory quote) external view override returns (uint8) {\n return 8;\n }\n}\n" + }, + "contracts/oracles/mocks/MockBinanceOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockBinanceOracle is OwnableUpgradeable, OracleInterface {\n mapping(address => uint256) public assetPrices;\n\n constructor() {}\n\n function initialize() public initializer {}\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" + }, + "contracts/oracles/mocks/MockChainlinkOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockChainlinkOracle is OwnableUpgradeable, OracleInterface {\n mapping(address => uint256) public assetPrices;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize() public initializer {\n __Ownable_init();\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" + }, + "contracts/oracles/mocks/MockPythOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { IPyth } from \"../PythOracle.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockPythOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice the actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize(address underlyingPythOracle_) public initializer {\n __Ownable_init();\n if (underlyingPythOracle_ == address(0)) revert(\"pyth oracle cannot be zero address\");\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" + }, + "contracts/oracles/PythOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"../interfaces/PythInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title PythOracle\n * @author Venus\n * @notice PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores\n * the updated prices from external sources\n */\ncontract PythOracle is AccessControlledV8, OracleInterface {\n // To calculate 10 ** n(which is a signed type)\n using SignedMath for int256;\n\n // To cast int64/int8 types from Pyth to unsigned types\n using SafeCast for int256;\n\n struct TokenConfig {\n bytes32 pythId;\n address asset;\n uint64 maxStalePeriod;\n }\n\n /// @notice Exponent scale (decimal precision) of prices\n uint256 public constant EXP_SCALE = 1e18;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice The actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n /// @notice Token configs by asset address\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when setting a new pyth oracle address\n event PythOracleSet(address indexed oldPythOracle, address indexed newPythOracle);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed asset, bytes32 indexed pythId, uint64 indexed maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract and sets required contracts\n * @param underlyingPythOracle_ Address of the Pyth oracle\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(\n address underlyingPythOracle_,\n address accessControlManager_\n ) external initializer notNullAddress(underlyingPythOracle_) {\n __AccessControlled_init(accessControlManager_);\n\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n emit PythOracleSet(address(0), underlyingPythOracle_);\n }\n\n /**\n * @notice Batch set token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the underlying Pyth oracle contract address\n * @param underlyingPythOracle_ Pyth oracle contract address\n * @custom:access Only Governance\n * @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero\n * @custom:event Emits PythOracleSet event with address of Pyth oracle.\n */\n function setUnderlyingPythOracle(\n IPyth underlyingPythOracle_\n ) external notNullAddress(address(underlyingPythOracle_)) {\n _checkAccessAllowed(\"setUnderlyingPythOracle(address)\");\n IPyth oldUnderlyingPythOracle = underlyingPythOracle;\n underlyingPythOracle = underlyingPythOracle_;\n emit PythOracleSet(address(oldUnderlyingPythOracle), address(underlyingPythOracle_));\n }\n\n /**\n * @notice Set single token config. `maxStalePeriod` cannot be 0 and `asset` cannot be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if max stale period is zero\n * @custom:error NotNullAddress error is thrown if asset address is null\n */\n function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n if (tokenConfig.maxStalePeriod == 0) revert(\"max stale period cannot be 0\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);\n }\n\n /**\n * @notice Gets the price of a asset from the pyth oracle\n * @param asset Address of the asset\n * @return Price in USD\n */\n function getPrice(address asset) public view returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n return _getPriceInternal(asset, decimals);\n }\n\n function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256) {\n TokenConfig storage tokenConfig = tokenConfigs[asset];\n if (tokenConfig.asset == address(0)) revert(\"asset doesn't exist\");\n\n // if the price is expired after it's compared against `maxStalePeriod`, the following call will revert\n PythStructs.Price memory priceInfo = underlyingPythOracle.getPriceNoOlderThan(\n tokenConfig.pythId,\n tokenConfig.maxStalePeriod\n );\n\n uint256 price = int256(priceInfo.price).toUint256();\n\n if (price == 0) revert(\"invalid pyth oracle price\");\n\n // the price returned from Pyth is price ** 10^expo, which is the real dollar price of the assets\n // we need to multiply it by 1e18 to make the price 18 decimals\n if (priceInfo.expo > 0) {\n return price * EXP_SCALE * (10 ** int256(priceInfo.expo).toUint256()) * (10 ** (18 - decimals));\n } else {\n return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));\n }\n }\n}\n" + }, + "contracts/oracles/WstETHOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OracleInterface } from \"../interfaces/OracleInterface.sol\";\nimport { IStETH } from \"../interfaces/IStETH.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\nimport { EXP_SCALE } from \"@venusprotocol/solidity-utilities/contracts/constants.sol\";\n\n/**\n * @title WstETHOracle\n * @author Venus\n * @notice This oracle fetches the price of wstETH asset\n */\ncontract WstETHOracle is OracleInterface {\n /// @notice Address of stETH\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IStETH public immutable STETH;\n\n /// @notice Address of wstETH\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WSTETH_ADDRESS;\n\n /// @notice Address of WETH\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WETH_ADDRESS;\n\n /// @notice Address of Resilient Oracle\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n OracleInterface public immutable RESILIENT_ORACLE;\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address wstETHAddress, address wETHAddress, address stETHAddress, address resilientOracleAddress) {\n ensureNonzeroAddress(wstETHAddress);\n ensureNonzeroAddress(wETHAddress);\n ensureNonzeroAddress(stETHAddress);\n ensureNonzeroAddress(resilientOracleAddress);\n WSTETH_ADDRESS = wstETHAddress;\n WETH_ADDRESS = wETHAddress;\n STETH = IStETH(stETHAddress);\n RESILIENT_ORACLE = OracleInterface(resilientOracleAddress);\n }\n\n /**\n * @notice Gets the price of wstETH asset\n * @param asset Address of wstETH\n * @return wstETH Price in USD scaled by 1e18\n */\n function getPrice(address asset) public view returns (uint256) {\n if (asset != WSTETH_ADDRESS) revert(\"wrong wstETH address\");\n\n // get stETH amount for 1 wstETH scaled by 1e18\n uint256 stETHAmount = STETH.getPooledEthByShares(1 ether);\n\n // price is scaled 1e18 (oracle returns 36 - asset decimal scale)\n uint256 wethUSDPrice = RESILIENT_ORACLE.getPrice(WETH_ADDRESS);\n\n // stETHAmount (for 1 wstETH) * wethUSDPrice (assuming 1stETH = 1 WETH) / 1e18\n return (stETHAmount * wethUSDPrice) / EXP_SCALE;\n }\n}\n" + }, + "contracts/ResilientOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ResilientOracle\n * @author Venus\n * @notice The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets.\n * \n * DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly\n * reported prices. If only one oracle is used, this creates a single point of failure and opens a vector\n * for attacking the protocol.\n * \n * The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect\n * the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle\n * and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.\n * \n * For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per \n * vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot \n * oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. \n * \n * To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every\n * market. The upper bound ratio represents the deviation between reported price (the price that’s being\n * validated) and the anchor price (the price we are validating against) above which the reported price will\n * be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below\n * which the reported price will be invalidated. So for oracle price to be considered valid the below statement\n * should be true:\n\n```\nanchorRatio = anchorPrice/reporterPrice\nisValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio\n```\n\n * In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending\n * on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may\n * use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. \n * \n * For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the\n * oracle to be stagnant and treat it like it's disabled.\n */\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n /**\n * @dev Oracle roles:\n * **main**: The most trustworthy price source\n * **pivot**: Price oracle used as a loose sanity checker\n * **fallback**: The backup source when main oracle price is invalidated\n */\n enum OracleRole {\n MAIN,\n PIVOT,\n FALLBACK\n }\n\n struct TokenConfig {\n /// @notice asset address\n address asset;\n /// @notice `oracles` stores the oracles based on their role in the following order:\n /// [main, pivot, fallback],\n /// It can be indexed with the corresponding enum OracleRole value\n address[3] oracles;\n /// @notice `enableFlagsForOracles` stores the enabled state\n /// for each oracle in the same order as `oracles`\n bool[3] enableFlagsForOracles;\n }\n\n uint256 public constant INVALID_PRICE = 0;\n\n /// @notice Native market address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable nativeMarket;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for Native token on each chain.This is the underlying for vBNB (on bsc)\n /// and can serve as any underlying asset of a market that supports native tokens\n address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Bound validator contract address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n BoundValidatorInterface public immutable boundValidator;\n\n mapping(address => TokenConfig) private tokenConfigs;\n\n event TokenConfigAdded(\n address indexed asset,\n address indexed mainOracle,\n address indexed pivotOracle,\n address fallbackOracle\n );\n\n /// Event emitted when an oracle is set\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n /// Event emitted when an oracle is enabled or disabled\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /**\n * @notice Checks whether token config exists by checking whether asset is null address\n * @dev address can't be null, so it's suitable to be used to check the validity of the config\n * @param asset asset address\n */\n modifier checkTokenConfigExistence(address asset) {\n if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @dev nativeMarketAddress can be address(0) if on the chain we do not support native market\n /// (e.g vETH on ethereum would not be supported, only vWETH)\n /// @param nativeMarketAddress The address of a native market (for bsc it would be vBNB address)\n /// @param vaiAddress The address of the VAI token (if there is VAI on the deployed chain).\n /// Set to address(0) of VAI is not existent.\n /// @param _boundValidator Address of the bound validator contract\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address nativeMarketAddress,\n address vaiAddress,\n BoundValidatorInterface _boundValidator\n ) notNullAddress(address(_boundValidator)) {\n nativeMarket = nativeMarketAddress;\n vai = vaiAddress;\n boundValidator = _boundValidator;\n\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract admin and sets the BoundValidator contract address\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n }\n\n /**\n * @notice Pauses oracle\n * @custom:access Only Governance\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n _pause();\n }\n\n /**\n * @notice Unpauses oracle\n * @custom:access Only Governance\n */\n function unpause() external {\n _checkAccessAllowed(\"unpause()\");\n _unpause();\n }\n\n /**\n * @notice Batch sets token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Throws a length error if the length of the token configs array is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Sets oracle for a given asset and role.\n * @dev Supplied asset **must** exist and main oracle may not be null\n * @param asset Asset address\n * @param oracle Oracle address\n * @param role Oracle role\n * @custom:access Only Governance\n * @custom:error Null address error if main-role oracle address is null\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n */\n function setOracle(\n address asset,\n address oracle,\n OracleRole role\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\n emit OracleSet(asset, oracle, uint256(role));\n }\n\n /**\n * @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\n * @dev Configuration for the asset **must** already exist and the asset cannot be 0 address\n * @param asset Asset address\n * @param role Oracle role\n * @param enable Enabled boolean of the oracle\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n */\n function enableOracle(\n address asset,\n OracleRole role,\n bool enable\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n emit OracleEnabled(asset, uint256(role), enable);\n }\n\n /**\n * @notice Updates the TWAP pivot oracle price.\n * @dev This function should always be called before calling getUnderlyingPrice\n * @param vToken vToken address\n */\n function updatePrice(address vToken) external override {\n address asset = _getUnderlyingAsset(vToken);\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @notice Updates the pivot oracle price. Currently using TWAP\n * @dev This function should always be called before calling getPrice\n * @param asset asset address\n */\n function updateAssetPrice(address asset) external {\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @dev Gets token config by asset address\n * @param asset asset address\n * @return tokenConfig Config for the asset\n */\n function getTokenConfig(address asset) external view returns (TokenConfig memory) {\n return tokenConfigs[asset];\n }\n\n /**\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n * - Check if the oracle is paused globally\n * - Validate price from main oracle against pivot oracle\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\n * - Validate price from main oracle against fallback oracle if the second validation failed\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\n * main oracle price is returned.\n * @param vToken vToken address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n\n address asset = _getUnderlyingAsset(vToken);\n return _getPrice(asset);\n }\n\n /**\n * @notice Gets price of the asset\n * @param asset asset address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getPrice(address asset) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n return _getPrice(asset);\n }\n\n /**\n * @notice Sets/resets single token configs.\n * @dev main oracle **must not** be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress is thrown if asset address is null\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n * @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(\n tokenConfig.asset,\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n );\n }\n\n /**\n * @notice Gets oracle and enabled status by asset address\n * @param asset asset address\n * @param role Oracle role\n * @return oracle Oracle address based on role\n * @return enabled Enabled flag of the oracle based on token config\n */\n function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {\n oracle = tokenConfigs[asset].oracles[uint256(role)];\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n }\n\n function _getPrice(address asset) internal view returns (uint256) {\n uint256 pivotPrice = INVALID_PRICE;\n\n // Get pivot oracle price, Invalid price if not available or error\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracleEnabled && pivotOracle != address(0)) {\n try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {\n pivotPrice = pricePivot;\n } catch {}\n }\n\n // Compare main price and pivot price, return main price and if validation was successful\n // note: In case pivot oracle is not available but main price is available and\n // validation is successful, the main oracle price is returned.\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n asset,\n pivotPrice,\n pivotOracleEnabled && pivotOracle != address(0)\n );\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n // Compare fallback and pivot if main oracle comparision fails with pivot\n // Return fallback price when fallback price is validated successfully with pivot oracle\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n // Lastly compare main price and fallback price\n if (\n mainPrice != INVALID_PRICE &&\n fallbackPrice != INVALID_PRICE &&\n boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)\n ) {\n return mainPrice;\n }\n\n revert(\"invalid resilient oracle price\");\n }\n\n /**\n * @notice Gets a price for the provided asset\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\n * able to fetch a correct price\n * @param asset asset address\n * @param pivotPrice Pivot oracle price\n * @param pivotEnabled If pivot oracle is not empty and enabled\n * @return price USD price in scaled decimals\n * e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n * @return pivotValidated Boolean representing if the validation of main oracle price\n * and pivot oracle price were successful\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n * address is null\n */\n function _getMainOraclePrice(\n address asset,\n uint256 pivotPrice,\n bool pivotEnabled\n ) internal view returns (uint256, bool) {\n (address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);\n if (mainOracleEnabled && mainOracle != address(0)) {\n try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {\n if (!pivotEnabled) {\n return (mainOraclePrice, true);\n }\n if (pivotPrice == INVALID_PRICE) {\n return (mainOraclePrice, false);\n }\n return (\n mainOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function won't revert when the price is 0 because getPrice checks if price is > 0\n * @param asset asset address\n * @return price USD price in 18 decimals\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\n * and pivot oracle price were successfull\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n * address is null\n */\n function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {\n (address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);\n if (fallbackEnabled && fallbackOracle != address(0)) {\n try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {\n if (pivotPrice == INVALID_PRICE) {\n return (fallbackOraclePrice, false);\n }\n return (\n fallbackOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view notNullAddress(vToken) returns (address asset) {\n if (vToken == nativeMarket) {\n asset = NATIVE_TOKEN_ADDR;\n } else if (vToken == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" + }, + "contracts/test/AccessControlManager.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol\";\n\ncontract AccessControlManagerScenario is AccessControlManager {}\n" + }, + "contracts/test/BEP20Harness.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract BEP20Harness is ERC20 {\n uint8 public decimalsInternal = 18;\n\n constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) {\n decimalsInternal = decimals_;\n }\n\n function faucet(uint256 amount) external {\n _mint(msg.sender, amount);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return decimalsInternal;\n }\n}\n" + }, + "contracts/test/MockPyth.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"../interfaces/PythInterface.sol\";\n\ncontract MockPyth is AbstractPyth {\n mapping(bytes32 => PythStructs.PriceFeed) priceFeeds;\n uint64 sequenceNumber;\n\n uint256 singleUpdateFeeInWei;\n uint256 validTimePeriod;\n\n constructor(uint256 _validTimePeriod, uint256 _singleUpdateFeeInWei) {\n singleUpdateFeeInWei = _singleUpdateFeeInWei;\n validTimePeriod = _validTimePeriod;\n }\n\n // simply update price feeds\n function updatePriceFeedsHarness(PythStructs.PriceFeed[] calldata feeds) external {\n require(feeds.length > 0, \"feeds length must > 0\");\n for (uint256 i = 0; i < feeds.length; ) {\n priceFeeds[feeds[i].id] = feeds[i];\n unchecked {\n ++i;\n }\n }\n }\n\n // Takes an array of encoded price feeds and stores them.\n // You can create this data either by calling createPriceFeedData or\n // by using web3.js or ethers abi utilities.\n function updatePriceFeeds(bytes[] calldata updateData) public payable override {\n uint256 requiredFee = getUpdateFee(updateData.length);\n require(msg.value >= requiredFee, \"Insufficient paid fee amount\");\n\n if (msg.value > requiredFee) {\n (bool success, ) = payable(msg.sender).call{ value: msg.value - requiredFee }(\"\");\n require(success, \"failed to transfer update fee\");\n }\n\n uint256 freshPrices = 0;\n\n // Chain ID is id of the source chain that the price update comes from. Since it is just a mock contract\n // We set it to 1.\n uint16 chainId = 1;\n\n for (uint256 i = 0; i < updateData.length; ) {\n PythStructs.PriceFeed memory priceFeed = abi.decode(updateData[i], (PythStructs.PriceFeed));\n\n bool fresh = false;\n uint256 lastPublishTime = priceFeeds[priceFeed.id].price.publishTime;\n\n if (lastPublishTime < priceFeed.price.publishTime) {\n // Price information is more recent than the existing price information.\n fresh = true;\n priceFeeds[priceFeed.id] = priceFeed;\n freshPrices += 1;\n }\n\n emit PriceFeedUpdate(\n priceFeed.id,\n fresh,\n chainId,\n sequenceNumber,\n priceFeed.price.publishTime,\n lastPublishTime,\n priceFeed.price.price,\n priceFeed.price.conf\n );\n\n unchecked {\n i++;\n }\n }\n\n // In the real contract, the input of this function contains multiple batches that each contain multiple prices.\n // This event is emitted when a batch is processed. In this mock contract we consider\n // there is only one batch of prices.\n // Each batch has (chainId, sequenceNumber) as it's unique identifier. Here chainId\n // is set to 1 and an increasing sequence number is used.\n emit BatchPriceFeedUpdate(chainId, sequenceNumber, updateData.length, freshPrices);\n sequenceNumber += 1;\n\n // There is only 1 batch of prices\n emit UpdatePriceFeeds(msg.sender, 1, requiredFee);\n }\n\n function queryPriceFeed(bytes32 id) public view override returns (PythStructs.PriceFeed memory priceFeed) {\n require(priceFeeds[id].id != 0, \"no price feed found for the given price id\");\n return priceFeeds[id];\n }\n\n function priceFeedExists(bytes32 id) public view override returns (bool) {\n return (priceFeeds[id].id != 0);\n }\n\n function getValidTimePeriod() public view override returns (uint256) {\n return validTimePeriod;\n }\n\n function getUpdateFee(uint256 updateDataSize) public view override returns (uint256 feeAmount) {\n return singleUpdateFeeInWei * updateDataSize;\n }\n\n function createPriceFeedUpdateData(\n bytes32 id,\n int64 price,\n uint64 conf,\n int32 expo,\n int64 emaPrice,\n uint64 emaConf,\n uint64 publishTime\n ) public pure returns (bytes memory priceFeedData) {\n PythStructs.PriceFeed memory priceFeed;\n\n priceFeed.id = id;\n\n priceFeed.price.price = price;\n priceFeed.price.conf = conf;\n priceFeed.price.expo = expo;\n priceFeed.price.publishTime = publishTime;\n\n priceFeed.emaPrice.price = emaPrice;\n priceFeed.emaPrice.conf = emaConf;\n priceFeed.emaPrice.expo = expo;\n priceFeed.emaPrice.publishTime = publishTime;\n\n priceFeedData = abi.encode(priceFeed);\n }\n}\n" + }, + "contracts/test/MockSimpleOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"../interfaces/OracleInterface.sol\";\n\ncontract MockSimpleOracle is OracleInterface {\n mapping(address => uint256) public prices;\n\n constructor() {\n //\n }\n\n function getUnderlyingPrice(address vToken) external view returns (uint256) {\n return prices[vToken];\n }\n\n function getPrice(address asset) external view returns (uint256) {\n return prices[asset];\n }\n\n function setPrice(address vToken, uint256 price) public {\n prices[vToken] = price;\n }\n}\n\ncontract MockBoundValidator is BoundValidatorInterface {\n mapping(address => bool) public validateResults;\n bool public twapUpdated;\n\n constructor() {\n //\n }\n\n function validatePriceWithAnchorPrice(\n address vToken,\n uint256 reporterPrice,\n uint256 anchorPrice\n ) external view returns (bool) {\n return validateResults[vToken];\n }\n\n function validateAssetPriceWithAnchorPrice(\n address asset,\n uint256 reporterPrice,\n uint256 anchorPrice\n ) external view returns (bool) {\n return validateResults[asset];\n }\n\n function setValidateResult(address token, bool pass) public {\n validateResults[token] = pass;\n }\n}\n" + }, + "contracts/test/MockV3Aggregator.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol\";\n\n/**\n * @title MockV3Aggregator\n * @notice Based on the FluxAggregator contract\n * @notice Use this contract when you need to test\n * other contract's ability to read data from an\n * aggregator contract, but how the aggregator got\n * its answer is unimportant\n */\ncontract MockV3Aggregator is AggregatorV2V3Interface {\n uint256 public constant version = 0;\n\n uint8 public decimals;\n int256 public latestAnswer;\n uint256 public latestTimestamp;\n uint256 public latestRound;\n\n mapping(uint256 => int256) public getAnswer;\n mapping(uint256 => uint256) public getTimestamp;\n mapping(uint256 => uint256) private getStartedAt;\n\n constructor(uint8 _decimals, int256 _initialAnswer) {\n decimals = _decimals;\n updateAnswer(_initialAnswer);\n }\n\n function getRoundData(\n uint80 _roundId\n )\n external\n view\n returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)\n {\n return (_roundId, getAnswer[_roundId], getStartedAt[_roundId], getTimestamp[_roundId], _roundId);\n }\n\n function latestRoundData()\n external\n view\n returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)\n {\n return (\n uint80(latestRound),\n getAnswer[latestRound],\n getStartedAt[latestRound],\n getTimestamp[latestRound],\n uint80(latestRound)\n );\n }\n\n function description() external pure returns (string memory) {\n return \"v0.6/tests/MockV3Aggregator.sol\";\n }\n\n function updateAnswer(int256 _answer) public {\n latestAnswer = _answer;\n latestTimestamp = block.timestamp;\n latestRound++;\n getAnswer[latestRound] = _answer;\n getTimestamp[latestRound] = block.timestamp;\n getStartedAt[latestRound] = block.timestamp;\n }\n\n function updateRoundData(uint80 _roundId, int256 _answer, uint256 _timestamp, uint256 _startedAt) public {\n latestRound = _roundId;\n latestAnswer = _answer;\n latestTimestamp = _timestamp;\n getAnswer[latestRound] = _answer;\n getTimestamp[latestRound] = _timestamp;\n getStartedAt[latestRound] = _startedAt;\n }\n}\n" + }, + "contracts/test/PancakePairHarness.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\n// a library for performing various math operations\n\nlibrary Math {\n function min(uint256 x, uint256 y) internal pure returns (uint256 z) {\n z = x < y ? x : y;\n }\n\n // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)\n function sqrt(uint256 y) internal pure returns (uint256 z) {\n if (y > 3) {\n z = y;\n uint256 x = y / 2 + 1;\n while (x < z) {\n z = x;\n x = (y / x + x) / 2;\n }\n } else if (y != 0) {\n z = 1;\n }\n }\n}\n\n// range: [0, 2**112 - 1]\n// resolution: 1 / 2**112\n\nlibrary UQ112x112 {\n //solhint-disable-next-line state-visibility\n uint224 constant Q112 = 2 ** 112;\n\n // encode a uint112 as a UQ112x112\n function encode(uint112 y) internal pure returns (uint224 z) {\n z = uint224(y) * Q112; // never overflows\n }\n\n // divide a UQ112x112 by a uint112, returning a UQ112x112\n function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {\n z = x / uint224(y);\n }\n}\n\ncontract PancakePairHarness {\n using UQ112x112 for uint224;\n\n address public token0;\n address public token1;\n\n uint112 private reserve0; // uses single storage slot, accessible via getReserves\n uint112 private reserve1; // uses single storage slot, accessible via getReserves\n uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves\n\n uint256 public price0CumulativeLast;\n uint256 public price1CumulativeLast;\n uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event\n\n // called once by the factory at time of deployment\n function initialize(address _token0, address _token1) external {\n token0 = _token0;\n token1 = _token1;\n }\n\n // update reserves and, on the first call per block, price accumulators\n function update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) external {\n require(balance0 <= type(uint112).max && balance1 <= type(uint112).max, \"PancakeV2: OVERFLOW\");\n uint32 blockTimestamp = uint32(block.timestamp % 2 ** 32);\n unchecked {\n uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired\n if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {\n // * never overflows, and + overflow is desired\n price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;\n price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;\n }\n }\n reserve0 = uint112(balance0);\n reserve1 = uint112(balance1);\n blockTimestampLast = blockTimestamp;\n }\n\n function currentBlockTimestamp() external view returns (uint32) {\n return uint32(block.timestamp % 2 ** 32);\n }\n\n function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {\n _reserve0 = reserve0;\n _reserve1 = reserve1;\n _blockTimestampLast = blockTimestampLast;\n }\n}\n" + }, + "contracts/test/VBEP20Harness.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"./BEP20Harness.sol\";\n\ncontract VBEP20Harness is BEP20Harness {\n /**\n * @notice Underlying asset for this VToken\n */\n address public underlying;\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals,\n address underlying_\n ) BEP20Harness(name_, symbol_, decimals) {\n underlying = underlying_;\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200, + "details": { + "yul": true + } + }, + "outputSelection": { + "*": { + "*": [ + "storageLayout", + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} diff --git a/deployments/ethereum/solcInputs/61a63fbc062c2591c6768138f59373e1.json b/deployments/ethereum/solcInputs/61a63fbc062c2591c6768138f59373e1.json index a0168fae..53225c4b 100644 --- a/deployments/ethereum/solcInputs/61a63fbc062c2591c6768138f59373e1.json +++ b/deployments/ethereum/solcInputs/61a63fbc062c2591c6768138f59373e1.json @@ -115,15 +115,9 @@ "contracts/oracles/mocks/MockPythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { IPyth } from \"../PythOracle.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockPythOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice the actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize(address underlyingPythOracle_) public initializer {\n __Ownable_init();\n if (underlyingPythOracle_ == address(0)) revert(\"pyth oracle cannot be zero address\");\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" }, - "contracts/oracles/mocks/MockTwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockTwapOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice vBNB address\n address public vBNB;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize(address vBNB_) public initializer {\n __Ownable_init();\n if (vBNB_ == address(0)) revert(\"vBNB can't be zero address\");\n vBNB = vBNB_;\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" - }, "contracts/oracles/PythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"../interfaces/PythInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title PythOracle\n * @author Venus\n * @notice PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores\n * the updated prices from external sources\n */\ncontract PythOracle is AccessControlledV8, OracleInterface {\n // To calculate 10 ** n(which is a signed type)\n using SignedMath for int256;\n\n // To cast int64/int8 types from Pyth to unsigned types\n using SafeCast for int256;\n\n struct TokenConfig {\n bytes32 pythId;\n address asset;\n uint64 maxStalePeriod;\n }\n\n /// @notice Exponent scale (decimal precision) of prices\n uint256 public constant EXP_SCALE = 1e18;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice The actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n /// @notice Token configs by asset address\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when setting a new pyth oracle address\n event PythOracleSet(address indexed oldPythOracle, address indexed newPythOracle);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed asset, bytes32 indexed pythId, uint64 indexed maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract and sets required contracts\n * @param underlyingPythOracle_ Address of the Pyth oracle\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(\n address underlyingPythOracle_,\n address accessControlManager_\n ) external initializer notNullAddress(underlyingPythOracle_) {\n __AccessControlled_init(accessControlManager_);\n\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n emit PythOracleSet(address(0), underlyingPythOracle_);\n }\n\n /**\n * @notice Batch set token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the underlying Pyth oracle contract address\n * @param underlyingPythOracle_ Pyth oracle contract address\n * @custom:access Only Governance\n * @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero\n * @custom:event Emits PythOracleSet event with address of Pyth oracle.\n */\n function setUnderlyingPythOracle(\n IPyth underlyingPythOracle_\n ) external notNullAddress(address(underlyingPythOracle_)) {\n _checkAccessAllowed(\"setUnderlyingPythOracle(address)\");\n IPyth oldUnderlyingPythOracle = underlyingPythOracle;\n underlyingPythOracle = underlyingPythOracle_;\n emit PythOracleSet(address(oldUnderlyingPythOracle), address(underlyingPythOracle_));\n }\n\n /**\n * @notice Set single token config. `maxStalePeriod` cannot be 0 and `asset` cannot be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if max stale period is zero\n * @custom:error NotNullAddress error is thrown if asset address is null\n */\n function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n if (tokenConfig.maxStalePeriod == 0) revert(\"max stale period cannot be 0\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);\n }\n\n /**\n * @notice Gets the price of a asset from the pyth oracle\n * @param asset Address of the asset\n * @return Price in USD\n */\n function getPrice(address asset) public view returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n return _getPriceInternal(asset, decimals);\n }\n\n function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256) {\n TokenConfig storage tokenConfig = tokenConfigs[asset];\n if (tokenConfig.asset == address(0)) revert(\"asset doesn't exist\");\n\n // if the price is expired after it's compared against `maxStalePeriod`, the following call will revert\n PythStructs.Price memory priceInfo = underlyingPythOracle.getPriceNoOlderThan(\n tokenConfig.pythId,\n tokenConfig.maxStalePeriod\n );\n\n uint256 price = int256(priceInfo.price).toUint256();\n\n if (price == 0) revert(\"invalid pyth oracle price\");\n\n // the price returned from Pyth is price ** 10^expo, which is the real dollar price of the assets\n // we need to multiply it by 1e18 to make the price 18 decimals\n if (priceInfo.expo > 0) {\n return price * EXP_SCALE * (10 ** int256(priceInfo.expo).toUint256()) * (10 ** (18 - decimals));\n } else {\n return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));\n }\n }\n}\n" }, - "contracts/oracles/TwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../libraries/PancakeLibrary.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title TwapOracle\n * @author Venus\n * @notice This oracle fetches price of assets from PancakeSwap.\n */\ncontract TwapOracle is AccessControlledV8, TwapInterface {\n using FixedPoint for *;\n\n struct Observation {\n uint256 timestamp;\n uint256 acc;\n }\n\n struct TokenConfig {\n /// @notice Asset address, which can't be zero address and can be used for existance check\n address asset;\n /// @notice Decimals of asset represented as 1e{decimals}\n uint256 baseUnit;\n /// @notice The address of Pancake pair\n address pancakePool;\n /// @notice Whether the token is paired with WBNB\n bool isBnbBased;\n /// @notice A flag identifies whether the Pancake pair is reversed\n /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not.\n bool isReversedPool;\n /// @notice The minimum window in seconds required between TWAP updates\n uint256 anchorPeriod;\n }\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice WBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WBNB;\n\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\n uint256 public constant BNB_BASE_UNIT = 1e18;\n uint256 public constant BUSD_BASE_UNIT = 1e18;\n\n /// @notice Configs by token\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Stored price by token\n mapping(address => uint256) public prices;\n\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\n mapping(address => Observation[]) public observations;\n\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\n mapping(address => uint256) public windowStart;\n\n /// @notice Emit this event when TWAP window is updated\n event TwapWindowUpdated(\n address indexed asset,\n uint256 oldTimestamp,\n uint256 oldAcc,\n uint256 newTimestamp,\n uint256 newAcc\n );\n\n /// @notice Emit this event when TWAP price is updated\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\n\n /// @notice Emit this event when new token configs are added\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param wBnbAddress The address of the WBNB\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address wBnbAddress) notNullAddress(wBnbAddress) {\n WBNB = wBnbAddress;\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Adds multiple token configs at the same time\n * @param configs Config array\n * @custom:error Zero length error thrown, if length of the config array is 0\n */\n function setTokenConfigs(TokenConfig[] memory configs) external {\n if (configs.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = configs.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(configs[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Get the TWAP price for the given asset\n * @param asset asset address\n * @return price asset price in USD\n * @custom:error Missing error is thrown if the token config does not exist\n * @custom:error Range error is thrown if TWAP price is not greater than zero\n */\n function getPrice(address asset) external view override returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n asset = WBNB;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n uint256 price = prices[asset];\n\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\n if (price == 0) revert(\"TWAP price must be positive\");\n return (price * (10 ** (18 - decimals)));\n }\n\n /**\n * @notice Adds a single token config\n * @param config token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if anchor period is not greater than zero\n * @custom:error Range error is thrown if base unit is not greater than zero\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\n * @custom:error NotNullAddress error is thrown if address of asset is null\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\n * @custom:event Emits TokenConfigAdded event if new token config are added with\n * asset address, PancakePool address, anchor period address\n */\n function setTokenConfig(\n TokenConfig memory config\n ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n if (config.anchorPeriod == 0) revert(\"anchor period must be positive\");\n if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals())\n revert(\"base unit decimals must be same as asset decimals\");\n\n uint256 cumulativePrice = currentCumulativePrice(config);\n\n // Initialize observation data\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\n tokenConfigs[config.asset] = config;\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\n }\n\n /**\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return anchorPrice anchor price of the asset\n * @custom:error Missing error is thrown if token config does not exist\n */\n function updateTwap(address asset) public returns (uint256) {\n if (asset == BNB_ADDR) {\n asset = WBNB;\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\n if (tokenConfigs[WBNB].asset == address(0)) revert(\"WBNB not exist\");\n _updateTwapInternal(tokenConfigs[WBNB]);\n }\n return _updateTwapInternal(tokenConfigs[asset]);\n }\n\n /**\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\n * @return cumulative price of target token regardless of pair order\n */\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\n if (config.isReversedPool) {\n return price1;\n } else {\n return price0;\n }\n }\n\n /**\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return price Asset price in USD, with 18 decimals\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\n * AnchorPrice, old observation timestamp and current timestamp\n */\n function _updateTwapInternal(TokenConfig memory config) private returns (uint256) {\n // pokeWindowValues already handled reversed pool cases,\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\n\n if (block.timestamp == oldTimestamp) return prices[config.asset];\n\n // This should be impossible, but better safe than sorry\n if (block.timestamp < oldTimestamp) revert(\"now must come after before\");\n\n uint256 timeElapsed;\n unchecked {\n timeElapsed = block.timestamp - oldTimestamp;\n }\n\n // Calculate Pancake *twap**\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\n );\n // *twap** price with 1e18 decimal mantissa\n uint256 priceAverageMantissa = priceAverage.decode112with18();\n\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\n // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18)\n uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT;\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\n\n // if this token is paired with BNB, convert its price to USD\n if (config.isBnbBased) {\n uint256 bnbPrice = prices[WBNB];\n if (bnbPrice == 0) revert(\"bnb price is invalid\");\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT;\n }\n\n if (anchorPriceMantissa == 0) revert(\"twap price cannot be 0\");\n\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\n\n // save anchor price, which is 1e18 decimals\n prices[config.asset] = anchorPriceMantissa;\n\n return anchorPriceMantissa;\n }\n\n /**\n * @notice Appends current observation and pick an observation with a timestamp equal\n * or just greater than the window start timestamp. If one is not available,\n * then pick the last availableobservation. The window start index is updated in both the cases.\n * Only the current observation is saved, prior observations are deleted during this operation.\n * @return Tuple of cumulative price, old observation and timestamp\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\n * new observation timestamp, current timestamp, new observation price and cumulative price\n */\n function pokeWindowValues(\n TokenConfig memory config\n ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\n uint256 cumulativePrice = currentCumulativePrice(config);\n uint256 currentTimestamp = block.timestamp;\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\n Observation[] memory storedObservations = observations[config.asset];\n\n uint256 storedObservationsLength = storedObservations.length;\n for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) {\n if (\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\n (windowStartIndex == storedObservationsLength - 1)\n ) {\n startCumulativePrice = storedObservations[windowStartIndex].acc;\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\n windowStart[config.asset] = windowStartIndex;\n break;\n } else {\n delete observations[config.asset][windowStartIndex];\n }\n\n unchecked {\n ++windowStartIndex;\n }\n }\n\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\n emit TwapWindowUpdated(\n config.asset,\n startCumulativeTimestamp,\n startCumulativePrice,\n block.timestamp,\n cumulativePrice\n );\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\n }\n}\n" - }, "contracts/ResilientOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ResilientOracle\n * @author Venus\n * @notice The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets.\n * \n * DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly\n * reported prices. If only one oracle is used, this creates a single point of failure and opens a vector\n * for attacking the protocol.\n * \n * The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect\n * the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle\n * and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.\n * \n * For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per \n * vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot \n * oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. \n * \n * To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every\n * market. The upper bound ratio represents the deviation between reported price (the price that’s being\n * validated) and the anchor price (the price we are validating against) above which the reported price will\n * be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below\n * which the reported price will be invalidated. So for oracle price to be considered valid the below statement\n * should be true:\n\n```\nanchorRatio = anchorPrice/reporterPrice\nisValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio\n```\n\n * In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending\n * on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may\n * use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. \n * \n * For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the\n * oracle to be stagnant and treat it like it's disabled.\n */\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n /**\n * @dev Oracle roles:\n * **main**: The most trustworthy price source\n * **pivot**: Price oracle used as a loose sanity checker\n * **fallback**: The backup source when main oracle price is invalidated\n */\n enum OracleRole {\n MAIN,\n PIVOT,\n FALLBACK\n }\n\n struct TokenConfig {\n /// @notice asset address\n address asset;\n /// @notice `oracles` stores the oracles based on their role in the following order:\n /// [main, pivot, fallback],\n /// It can be indexed with the corresponding enum OracleRole value\n address[3] oracles;\n /// @notice `enableFlagsForOracles` stores the enabled state\n /// for each oracle in the same order as `oracles`\n bool[3] enableFlagsForOracles;\n }\n\n uint256 public constant INVALID_PRICE = 0;\n\n /// @notice Native market address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable nativeMarket;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for Native token on each chain.This is the underlying for vBNB (on bsc)\n /// and can serve as any underlying asset of a market that supports native tokens\n address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Bound validator contract address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n BoundValidatorInterface public immutable boundValidator;\n\n mapping(address => TokenConfig) private tokenConfigs;\n\n event TokenConfigAdded(\n address indexed asset,\n address indexed mainOracle,\n address indexed pivotOracle,\n address fallbackOracle\n );\n\n /// Event emitted when an oracle is set\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n /// Event emitted when an oracle is enabled or disabled\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /**\n * @notice Checks whether token config exists by checking whether asset is null address\n * @dev address can't be null, so it's suitable to be used to check the validity of the config\n * @param asset asset address\n */\n modifier checkTokenConfigExistence(address asset) {\n if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @dev nativeMarketAddress can be address(0) if on the chain we do not support native market\n /// (e.g vETH on ethereum would not be supported, only vWETH)\n /// @param nativeMarketAddress The address of a native market (for bsc it would be vBNB address)\n /// @param vaiAddress The address of the VAI token (if there is VAI on the deployed chain).\n /// Set to address(0) of VAI is not existent.\n /// @param _boundValidator Address of the bound validator contract\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address nativeMarketAddress,\n address vaiAddress,\n BoundValidatorInterface _boundValidator\n ) notNullAddress(address(_boundValidator)) {\n nativeMarket = nativeMarketAddress;\n vai = vaiAddress;\n boundValidator = _boundValidator;\n\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract admin and sets the BoundValidator contract address\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n }\n\n /**\n * @notice Pauses oracle\n * @custom:access Only Governance\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n _pause();\n }\n\n /**\n * @notice Unpauses oracle\n * @custom:access Only Governance\n */\n function unpause() external {\n _checkAccessAllowed(\"unpause()\");\n _unpause();\n }\n\n /**\n * @notice Batch sets token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Throws a length error if the length of the token configs array is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Sets oracle for a given asset and role.\n * @dev Supplied asset **must** exist and main oracle may not be null\n * @param asset Asset address\n * @param oracle Oracle address\n * @param role Oracle role\n * @custom:access Only Governance\n * @custom:error Null address error if main-role oracle address is null\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n */\n function setOracle(\n address asset,\n address oracle,\n OracleRole role\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\n emit OracleSet(asset, oracle, uint256(role));\n }\n\n /**\n * @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\n * @dev Configuration for the asset **must** already exist and the asset cannot be 0 address\n * @param asset Asset address\n * @param role Oracle role\n * @param enable Enabled boolean of the oracle\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n */\n function enableOracle(\n address asset,\n OracleRole role,\n bool enable\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n emit OracleEnabled(asset, uint256(role), enable);\n }\n\n /**\n * @notice Updates the TWAP pivot oracle price.\n * @dev This function should always be called before calling getUnderlyingPrice\n * @param vToken vToken address\n */\n function updatePrice(address vToken) external override {\n address asset = _getUnderlyingAsset(vToken);\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @notice Updates the pivot oracle price. Currently using TWAP\n * @dev This function should always be called before calling getPrice\n * @param asset asset address\n */\n function updateAssetPrice(address asset) external {\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @dev Gets token config by asset address\n * @param asset asset address\n * @return tokenConfig Config for the asset\n */\n function getTokenConfig(address asset) external view returns (TokenConfig memory) {\n return tokenConfigs[asset];\n }\n\n /**\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n * - Check if the oracle is paused globally\n * - Validate price from main oracle against pivot oracle\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\n * - Validate price from main oracle against fallback oracle if the second validation failed\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\n * main oracle price is returned.\n * @param vToken vToken address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n\n address asset = _getUnderlyingAsset(vToken);\n return _getPrice(asset);\n }\n\n /**\n * @notice Gets price of the asset\n * @param asset asset address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getPrice(address asset) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n return _getPrice(asset);\n }\n\n /**\n * @notice Sets/resets single token configs.\n * @dev main oracle **must not** be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress is thrown if asset address is null\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n * @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(\n tokenConfig.asset,\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n );\n }\n\n /**\n * @notice Gets oracle and enabled status by asset address\n * @param asset asset address\n * @param role Oracle role\n * @return oracle Oracle address based on role\n * @return enabled Enabled flag of the oracle based on token config\n */\n function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {\n oracle = tokenConfigs[asset].oracles[uint256(role)];\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n }\n\n function _getPrice(address asset) internal view returns (uint256) {\n uint256 pivotPrice = INVALID_PRICE;\n\n // Get pivot oracle price, Invalid price if not available or error\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracleEnabled && pivotOracle != address(0)) {\n try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {\n pivotPrice = pricePivot;\n } catch {}\n }\n\n // Compare main price and pivot price, return main price and if validation was successful\n // note: In case pivot oracle is not available but main price is available and\n // validation is successful, the main oracle price is returned.\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n asset,\n pivotPrice,\n pivotOracleEnabled && pivotOracle != address(0)\n );\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n // Compare fallback and pivot if main oracle comparision fails with pivot\n // Return fallback price when fallback price is validated successfully with pivot oracle\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n // Lastly compare main price and fallback price\n if (\n mainPrice != INVALID_PRICE &&\n fallbackPrice != INVALID_PRICE &&\n boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)\n ) {\n return mainPrice;\n }\n\n revert(\"invalid resilient oracle price\");\n }\n\n /**\n * @notice Gets a price for the provided asset\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\n * able to fetch a correct price\n * @param asset asset address\n * @param pivotPrice Pivot oracle price\n * @param pivotEnabled If pivot oracle is not empty and enabled\n * @return price USD price in scaled decimals\n * e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n * @return pivotValidated Boolean representing if the validation of main oracle price\n * and pivot oracle price were successful\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n * address is null\n */\n function _getMainOraclePrice(\n address asset,\n uint256 pivotPrice,\n bool pivotEnabled\n ) internal view returns (uint256, bool) {\n (address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);\n if (mainOracleEnabled && mainOracle != address(0)) {\n try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {\n if (!pivotEnabled) {\n return (mainOraclePrice, true);\n }\n if (pivotPrice == INVALID_PRICE) {\n return (mainOraclePrice, false);\n }\n return (\n mainOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function won't revert when the price is 0 because getPrice checks if price is > 0\n * @param asset asset address\n * @return price USD price in 18 decimals\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\n * and pivot oracle price were successfull\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n * address is null\n */\n function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {\n (address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);\n if (fallbackEnabled && fallbackOracle != address(0)) {\n try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {\n if (pivotPrice == INVALID_PRICE) {\n return (fallbackOraclePrice, false);\n }\n return (\n fallbackOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view notNullAddress(vToken) returns (address asset) {\n if (vToken == nativeMarket) {\n asset = NATIVE_TOKEN_ADDR;\n } else if (vToken == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" }, diff --git a/deployments/ethereum/solcInputs/643c04e89f008dea200654c141acbf47.json b/deployments/ethereum/solcInputs/643c04e89f008dea200654c141acbf47.json new file mode 100644 index 00000000..456e96de --- /dev/null +++ b/deployments/ethereum/solcInputs/643c04e89f008dea200654c141acbf47.json @@ -0,0 +1,48 @@ +{ + "language": "Solidity", + "sources": { + "@venusprotocol/solidity-utilities/contracts/constants.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\n/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)\nuint256 constant EXP_SCALE = 1e18;\n\n/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\nuint256 constant MANTISSA_ONE = EXP_SCALE;\n\n/// @dev The approximate number of seconds per year\nuint256 constant SECONDS_PER_YEAR = 31_536_000;\n" + }, + "@venusprotocol/solidity-utilities/contracts/validators.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\n/// @notice Thrown if the supplied address is a zero address where it is not allowed\nerror ZeroAddressNotAllowed();\n\n/// @notice Thrown if the supplied value is 0 where it is not allowed\nerror ZeroValueNotAllowed();\n\n/// @notice Checks if the provided address is nonzero, reverts otherwise\n/// @param address_ Address to check\n/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\nfunction ensureNonzeroAddress(address address_) pure {\n if (address_ == address(0)) {\n revert ZeroAddressNotAllowed();\n }\n}\n\n/// @notice Checks if the provided value is nonzero, reverts otherwise\n/// @param value_ Value to check\n/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0\nfunction ensureNonzeroValue(uint256 value_) pure {\n if (value_ == 0) {\n revert ZeroValueNotAllowed();\n }\n}\n" + }, + "contracts/interfaces/IStETH.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\ninterface IStETH {\n function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);\n}\n" + }, + "contracts/interfaces/OracleInterface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\ninterface OracleInterface {\n function getPrice(address asset) external view returns (uint256);\n}\n\ninterface ResilientOracleInterface is OracleInterface {\n function updatePrice(address vToken) external;\n\n function updateAssetPrice(address asset) external;\n\n function getUnderlyingPrice(address vToken) external view returns (uint256);\n}\n\ninterface TwapInterface is OracleInterface {\n function updateTwap(address asset) external returns (uint256);\n}\n\ninterface BoundValidatorInterface {\n function validatePriceWithAnchorPrice(\n address asset,\n uint256 reporterPrice,\n uint256 anchorPrice\n ) external view returns (bool);\n}\n" + }, + "contracts/oracles/WstETHOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OracleInterface } from \"../interfaces/OracleInterface.sol\";\nimport { IStETH } from \"../interfaces/IStETH.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\nimport { EXP_SCALE } from \"@venusprotocol/solidity-utilities/contracts/constants.sol\";\n\n/**\n * @title WstETHOracle\n * @author Venus\n * @notice Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH\n * or the price of stETH/USD (secondary market price) is obtained from the oracle.\n */\ncontract WstETHOracle is OracleInterface {\n /// @notice A flag assuming 1:1 price equivalence between stETH/ETH\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n bool public immutable ASSUME_STETH_ETH_EQUIVALENCE;\n\n /// @notice Address of stETH\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IStETH public immutable STETH;\n\n /// @notice Address of wstETH\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WSTETH_ADDRESS;\n\n /// @notice Address of WETH\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WETH_ADDRESS;\n\n /// @notice Address of Resilient Oracle\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n OracleInterface public immutable RESILIENT_ORACLE;\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address wstETHAddress,\n address wETHAddress,\n address stETHAddress,\n address resilientOracleAddress,\n bool assumeEquivalence\n ) {\n ensureNonzeroAddress(wstETHAddress);\n ensureNonzeroAddress(wETHAddress);\n ensureNonzeroAddress(stETHAddress);\n ensureNonzeroAddress(resilientOracleAddress);\n WSTETH_ADDRESS = wstETHAddress;\n WETH_ADDRESS = wETHAddress;\n STETH = IStETH(stETHAddress);\n RESILIENT_ORACLE = OracleInterface(resilientOracleAddress);\n ASSUME_STETH_ETH_EQUIVALENCE = assumeEquivalence;\n }\n\n /**\n * @notice Gets the USD price of wstETH asset\n * @dev Depending on the equivalence flag price is either based on assumption that 1 stETH = 1 ETH\n * or the price of stETH/USD (secondary market price) is obtained from the oracle\n * @param asset Address of wstETH\n * @return wstETH Price in USD scaled by 1e18\n */\n function getPrice(address asset) public view returns (uint256) {\n if (asset != WSTETH_ADDRESS) revert(\"wrong wstETH address\");\n\n // get stETH amount for 1 wstETH scaled by 1e18\n uint256 stETHAmount = STETH.getPooledEthByShares(1 ether);\n\n // price is scaled 1e18 (oracle returns 36 - asset decimal scale)\n uint256 stETHUSDPrice = RESILIENT_ORACLE.getPrice(ASSUME_STETH_ETH_EQUIVALENCE ? WETH_ADDRESS : address(STETH));\n\n // stETHAmount (for 1 wstETH) * stETHUSDPrice / 1e18\n return (stETHAmount * stETHUSDPrice) / EXP_SCALE;\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200, + "details": { + "yul": true + } + }, + "outputSelection": { + "*": { + "*": [ + "storageLayout", + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} diff --git a/deployments/ethereum_addresses.json b/deployments/ethereum_addresses.json index 98c6b0c8..84547d39 100644 --- a/deployments/ethereum_addresses.json +++ b/deployments/ethereum_addresses.json @@ -14,6 +14,12 @@ "RedStoneOracle_Proxy": "0x0FC8001B2c9Ec90352A46093130e284de5889C86", "ResilientOracle": "0xd2ce3fb018805ef92b8C5976cb31F84b4E295F94", "ResilientOracle_Implementation": "0x1616BaC3e4C2222B438B3410b5196604bC557bce", - "ResilientOracle_Proxy": "0xd2ce3fb018805ef92b8C5976cb31F84b4E295F94" + "ResilientOracle_Proxy": "0xd2ce3fb018805ef92b8C5976cb31F84b4E295F94", + "WstETHOracle_Equivalence": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "WstETHOracle_Equivalence_Implementation": "0x4e70615332550CE81e12891772eB950411Bb05A2", + "WstETHOracle_Equivalence_Proxy": "0xd8B43165a6cdA057DBd3Fcd4745E88FC475398c5", + "WstETHOracle_NonEquivalence": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf", + "WstETHOracle_NonEquivalence_Implementation": "0x24D3D52332834ddE93692D9ede4679FE920d2afC", + "WstETHOracle_NonEquivalence_Proxy": "0xd082B50b3EeB012605598bB45Fc2Be853b9AFEEf" } } diff --git a/deployments/opbnbmainnet.json b/deployments/opbnbmainnet.json index 6a503c8d..11aa81bc 100644 --- a/deployments/opbnbmainnet.json +++ b/deployments/opbnbmainnet.json @@ -1,5 +1,3725 @@ { "name": "opbnbmainnet", "chainId": "204", - "contracts": {} + "contracts": { + "BinanceOracle": { + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldFeedRegistry", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newFeedRegistry", + "type": "address" + } + ], + "name": "FeedRegistryUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "string", + "name": "asset", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "maxStalePeriod", + "type": "uint256" + } + ], + "name": "MaxStalePeriodAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "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": true, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "overriddenSymbol", + "type": "string" + } + ], + "name": "SymbolOverridden", + "type": "event" + }, + { + "inputs": [], + "name": "BNB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feedRegistryAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFeedRegistryAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sidRegistryAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_accessControlManager", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "maxStalePeriod", + "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": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newfeedRegistryAddress", + "type": "address" + } + ], + "name": "setFeedRegistryAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_maxStalePeriod", + "type": "uint256" + } + ], + "name": "setMaxStalePeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "string", + "name": "overrideSymbol", + "type": "string" + } + ], + "name": "setSymbolOverride", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sidRegistryAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "symbols", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ] + }, + "BinanceOracle_Implementation": { + "address": "0x7B9BFF3AEbAcE3715660e6340370810f10481b53", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldFeedRegistry", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newFeedRegistry", + "type": "address" + } + ], + "name": "FeedRegistryUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "string", + "name": "asset", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "maxStalePeriod", + "type": "uint256" + } + ], + "name": "MaxStalePeriodAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "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": true, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "overriddenSymbol", + "type": "string" + } + ], + "name": "SymbolOverridden", + "type": "event" + }, + { + "inputs": [], + "name": "BNB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feedRegistryAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFeedRegistryAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sidRegistryAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_accessControlManager", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "maxStalePeriod", + "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": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newfeedRegistryAddress", + "type": "address" + } + ], + "name": "setFeedRegistryAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_maxStalePeriod", + "type": "uint256" + } + ], + "name": "setMaxStalePeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "string", + "name": "overrideSymbol", + "type": "string" + } + ], + "name": "setSymbolOverride", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sidRegistryAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "symbols", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "BinanceOracle_Proxy": { + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ] + }, + "BoundValidator": { + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "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": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "upperBound", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "lowerBound", + "type": "uint256" + } + ], + "name": "ValidateConfigAdded", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "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": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "internalType": "struct BoundValidator.ValidateConfig", + "name": "config", + "type": "tuple" + } + ], + "name": "setValidateConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "internalType": "struct BoundValidator.ValidateConfig[]", + "name": "configs", + "type": "tuple[]" + } + ], + "name": "setValidateConfigs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "validateConfigs", + "outputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "reportedPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "anchorPrice", + "type": "uint256" + } + ], + "name": "validatePriceWithAnchorPrice", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ] + }, + "BoundValidator_Implementation": { + "address": "0x47C33167d13eD2374161A6f0A9b55fc4cad09897", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "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": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "upperBound", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "lowerBound", + "type": "uint256" + } + ], + "name": "ValidateConfigAdded", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "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": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "internalType": "struct BoundValidator.ValidateConfig", + "name": "config", + "type": "tuple" + } + ], + "name": "setValidateConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "internalType": "struct BoundValidator.ValidateConfig[]", + "name": "configs", + "type": "tuple[]" + } + ], + "name": "setValidateConfigs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "validateConfigs", + "outputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "reportedPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "anchorPrice", + "type": "uint256" + } + ], + "name": "validatePriceWithAnchorPrice", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "BoundValidator_Proxy": { + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ] + }, + "DefaultProxyAdmin": { + "address": "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "initialOwner", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeProxyAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + } + ], + "name": "getProxyAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + } + ], + "name": "getProxyImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "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": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } + ] + }, + "ResilientOracle": { + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "role", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bool", + "name": "enable", + "type": "bool" + } + ], + "name": "OracleEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "role", + "type": "uint256" + } + ], + "name": "OracleSet", + "type": "event" + }, + { + "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": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "mainOracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pivotOracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "fallbackOracle", + "type": "address" + } + ], + "name": "TokenConfigAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "INVALID_PRICE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_TOKEN_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "boundValidator", + "outputs": [ + { + "internalType": "contract BoundValidatorInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "enable", + "type": "bool" + } + ], + "name": "enableOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + } + ], + "name": "getOracle", + "outputs": [ + { + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getTokenConfig", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" + }, + { + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" + } + ], + "internalType": "struct ResilientOracle.TokenConfig", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "getUnderlyingPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "nativeMarket", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "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": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" + }, + { + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" + } + ], + "internalType": "struct ResilientOracle.TokenConfig", + "name": "tokenConfig", + "type": "tuple" + } + ], + "name": "setTokenConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" + }, + { + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" + } + ], + "internalType": "struct ResilientOracle.TokenConfig[]", + "name": "tokenConfigs_", + "type": "tuple[]" + } + ], + "name": "setTokenConfigs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "updateAssetPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "updatePrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vai", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ] + }, + "ResilientOracle_Implementation": { + "address": "0xbC3ee948Ba5D78880c6ECb005274257e60d017c8", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "nativeMarketAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "vaiAddress", + "type": "address" + }, + { + "internalType": "contract BoundValidatorInterface", + "name": "_boundValidator", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "role", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bool", + "name": "enable", + "type": "bool" + } + ], + "name": "OracleEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "role", + "type": "uint256" + } + ], + "name": "OracleSet", + "type": "event" + }, + { + "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": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "mainOracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pivotOracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "fallbackOracle", + "type": "address" + } + ], + "name": "TokenConfigAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "INVALID_PRICE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_TOKEN_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "boundValidator", + "outputs": [ + { + "internalType": "contract BoundValidatorInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "enable", + "type": "bool" + } + ], + "name": "enableOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + } + ], + "name": "getOracle", + "outputs": [ + { + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getTokenConfig", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" + }, + { + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" + } + ], + "internalType": "struct ResilientOracle.TokenConfig", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "getUnderlyingPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "nativeMarket", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "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": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" + }, + { + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" + } + ], + "internalType": "struct ResilientOracle.TokenConfig", + "name": "tokenConfig", + "type": "tuple" + } + ], + "name": "setTokenConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" + }, + { + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" + } + ], + "internalType": "struct ResilientOracle.TokenConfig[]", + "name": "tokenConfigs_", + "type": "tuple[]" + } + ], + "name": "setTokenConfigs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "updateAssetPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "updatePrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vai", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "ResilientOracle_Proxy": { + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ] + } + } } diff --git a/deployments/opbnbmainnet/.chainId b/deployments/opbnbmainnet/.chainId new file mode 100644 index 00000000..cbd6012b --- /dev/null +++ b/deployments/opbnbmainnet/.chainId @@ -0,0 +1 @@ +204 \ No newline at end of file diff --git a/deployments/bscmainnet/TwapOracle.json b/deployments/opbnbmainnet/BinanceOracle.json similarity index 86% rename from deployments/bscmainnet/TwapOracle.json rename to deployments/opbnbmainnet/BinanceOracle.json index 7ed26515..8bfc15de 100644 --- a/deployments/bscmainnet/TwapOracle.json +++ b/deployments/opbnbmainnet/BinanceOracle.json @@ -1,5 +1,5 @@ { - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", "abi": [ { "anonymous": false, @@ -138,29 +138,17 @@ { "indexed": true, "internalType": "address", - "name": "asset", + "name": "oldFeedRegistry", "type": "address" }, { - "indexed": false, - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newTimestamp", - "type": "uint256" + "indexed": true, + "internalType": "address", + "name": "newFeedRegistry", + "type": "address" } ], - "name": "AnchorPriceUpdated", + "name": "FeedRegistryUpdated", "type": "event" }, { @@ -180,38 +168,38 @@ "anonymous": false, "inputs": [ { - "indexed": false, - "internalType": "address", - "name": "oldAccessControlManager", - "type": "address" + "indexed": true, + "internalType": "string", + "name": "asset", + "type": "string" }, { "indexed": false, - "internalType": "address", - "name": "newAccessControlManager", - "type": "address" + "internalType": "uint256", + "name": "maxStalePeriod", + "type": "uint256" } ], - "name": "NewAccessControlManager", + "name": "MaxStalePeriodAdded", "type": "event" }, { "anonymous": false, "inputs": [ { - "indexed": true, + "indexed": false, "internalType": "address", - "name": "previousOwner", + "name": "oldAccessControlManager", "type": "address" }, { - "indexed": true, + "indexed": false, "internalType": "address", - "name": "newOwner", + "name": "newAccessControlManager", "type": "address" } ], - "name": "OwnershipTransferStarted", + "name": "NewAccessControlManager", "type": "event" }, { @@ -230,7 +218,7 @@ "type": "address" } ], - "name": "OwnershipTransferred", + "name": "OwnershipTransferStarted", "type": "event" }, { @@ -239,23 +227,17 @@ { "indexed": true, "internalType": "address", - "name": "asset", + "name": "previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", - "name": "pancakePool", + "name": "newOwner", "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" } ], - "name": "TokenConfigAdded", + "name": "OwnershipTransferred", "type": "event" }, { @@ -263,46 +245,28 @@ "inputs": [ { "indexed": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldTimestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldAcc", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newTimestamp", - "type": "uint256" + "internalType": "string", + "name": "symbol", + "type": "string" }, { "indexed": false, - "internalType": "uint256", - "name": "newAcc", - "type": "uint256" + "internalType": "string", + "name": "overriddenSymbol", + "type": "string" } ], - "name": "TwapWindowUpdated", + "name": "SymbolOverridden", "type": "event" }, { "inputs": [], - "name": "BNB_BASE_UNIT", + "name": "BNB_ADDR", "outputs": [ { - "internalType": "uint256", + "internalType": "address", "name": "", - "type": "uint256" + "type": "address" } ], "stateMutability": "view", @@ -310,23 +274,17 @@ }, { "inputs": [], - "name": "BUSD_BASE_UNIT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], - "name": "WBNB", + "name": "accessControlManager", "outputs": [ { - "internalType": "address", + "internalType": "contract IAccessControlManagerV8", "name": "", "type": "address" } @@ -336,17 +294,10 @@ }, { "inputs": [], - "name": "acceptOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "accessControlManager", + "name": "feedRegistryAddress", "outputs": [ { - "internalType": "contract IAccessControlManagerV8", + "internalType": "address", "name": "", "type": "address" } @@ -355,51 +306,13 @@ "type": "function" }, { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "currentCumulativePrice", + "inputs": [], + "name": "getFeedRegistryAddress", "outputs": [ { - "internalType": "uint256", + "internalType": "address", "name": "", - "type": "uint256" + "type": "address" } ], "stateMutability": "view", @@ -409,11 +322,11 @@ "inputs": [ { "internalType": "address", - "name": "vToken", + "name": "asset", "type": "address" } ], - "name": "getUnderlyingPrice", + "name": "getPrice", "outputs": [ { "internalType": "uint256", @@ -428,7 +341,12 @@ "inputs": [ { "internalType": "address", - "name": "accessControlManager_", + "name": "_sidRegistryAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_accessControlManager", "type": "address" } ], @@ -440,26 +358,16 @@ { "inputs": [ { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", + "internalType": "string", "name": "", - "type": "uint256" + "type": "string" } ], - "name": "observations", + "name": "maxStalePeriod", "outputs": [ { "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "acc", + "name": "", "type": "uint256" } ], @@ -492,25 +400,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "prices", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [], "name": "renounceOwnership", @@ -534,89 +423,12 @@ { "inputs": [ { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "setTokenConfig", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" - } - ], - "internalType": "struct TwapOracle.TokenConfig[]", - "name": "configs", - "type": "tuple[]" - } - ], - "name": "setTokenConfigs", + "internalType": "address", + "name": "newfeedRegistryAddress", + "type": "address" + } + ], + "name": "setFeedRegistryAddress", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -624,56 +436,17 @@ { "inputs": [ { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "tokenConfigs", - "outputs": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" + "internalType": "string", + "name": "symbol", + "type": "string" }, { "internalType": "uint256", - "name": "anchorPeriod", + "name": "_maxStalePeriod", "type": "uint256" } ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", + "name": "setMaxStalePeriod", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -681,25 +454,24 @@ { "inputs": [ { - "internalType": "address", - "name": "vToken", - "type": "address" - } - ], - "name": "updateTwap", - "outputs": [ + "internalType": "string", + "name": "symbol", + "type": "string" + }, { - "internalType": "uint256", - "name": "", - "type": "uint256" + "internalType": "string", + "name": "overrideSymbol", + "type": "string" } ], + "name": "setSymbolOverride", + "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], - "name": "vBnb", + "name": "sidRegistryAddress", "outputs": [ { "internalType": "address", @@ -711,13 +483,19 @@ "type": "function" }, { - "inputs": [], - "name": "vai", + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "symbols", "outputs": [ { - "internalType": "address", + "internalType": "string", "name": "", - "type": "address" + "type": "string" } ], "stateMutability": "view", @@ -727,19 +505,13 @@ "inputs": [ { "internalType": "address", - "name": "", + "name": "newOwner", "type": "address" } ], - "name": "windowStart", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { @@ -764,84 +536,84 @@ "type": "constructor" } ], - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", "receipt": { "to": null, - "from": "0xa05f990d647287e4E84715b813BC000aEA970467", - "contractAddress": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", - "transactionIndex": 79, - "gasUsed": "696602", - "logsBloom": "0x00000000000000000000000000000000400000000000000000800000400000000000000000000000000000000000000000000000000000000000002000008000000000000000000000008000000002000001000000000100000000000000000000000004020000000000000000000800000000800000000000000000000000400000000000000000000000000008000000000000000080400000000000800000000000400000000000000000000400000000000000808000000000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000000000000000000000000000800000000000000000000000000", - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001", - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", + "from": "0x4a32670436a8A662E75E64B91B3Ab989B8a00064", + "contractAddress": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "transactionIndex": 1, + "gasUsed": "700788", + "logsBloom": "0x00000000000000000000000000040000600000000000000000800000000000000000000000000000000000000000000100000000000000000000000100008000000000000800000000000000000002000001000000000000000000000000080000000000020000000000000000000800000000800000000000000000000000400000000000000000000000000000020000000000000080000000000000800000000080000000000000000000000400000000000000800000000000000000000000000020000000000000000000040000000001000400000000000000000020000000000000000000000000000000000000000800000000000000000000000000", + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624", + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", "logs": [ { - "transactionIndex": 79, - "blockNumber": 28525821, - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "transactionIndex": 1, + "blockNumber": 11141035, + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x00000000000000000000000017d00a8926566cb4b02b25f4ee6ecc2ceb34a784" + "0x0000000000000000000000007b9bff3aebace3715660e6340370810f10481b53" ], "data": "0x", - "logIndex": 134, - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001" + "logIndex": 0, + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624" }, { - "transactionIndex": 79, - "blockNumber": 28525821, - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "transactionIndex": 1, + "blockNumber": 11141035, + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000a05f990d647287e4e84715b813bc000aea970467" + "0x0000000000000000000000004a32670436a8a662e75e64b91b3ab989b8a00064" ], "data": "0x", - "logIndex": 135, - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001" + "logIndex": 1, + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624" }, { - "transactionIndex": 79, - "blockNumber": 28525821, - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "transactionIndex": 1, + "blockNumber": 11141035, + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000004788629abc6cfca10f9f969efdeaa1cf70c23555", - "logIndex": 136, - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001" + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6", + "logIndex": 2, + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624" }, { - "transactionIndex": 79, - "blockNumber": 28525821, - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "transactionIndex": 1, + "blockNumber": 11141035, + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", - "logIndex": 137, - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001" + "logIndex": 3, + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624" }, { - "transactionIndex": 79, - "blockNumber": 28525821, - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "transactionIndex": 1, + "blockNumber": 11141035, + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001bb765b741a5f3c2a338369dab539385534e3343", - "logIndex": 138, - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001" + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f77bd1d893f67b3eb2cd256239c98ba3f238fb52", + "logIndex": 4, + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624" } ], - "blockNumber": 28525821, - "cumulativeGasUsed": "8096175", + "blockNumber": 11141035, + "cumulativeGasUsed": "747677", "status": 1, "byzantium": true }, "args": [ - "0x17D00a8926566CB4b02B25f4EE6ecC2cEB34A784", - "0x1BB765b741A5f3C2A338369DAb539385534E3343", - "0xc4d66de80000000000000000000000004788629abc6cfca10f9f969efdeaa1cf70c23555" + "0x7B9BFF3AEbAcE3715660e6340370810f10481b53", + "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "0x485cc9550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6" ], "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", @@ -850,9 +622,9 @@ "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033", "execute": { "methodName": "initialize", - "args": ["0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555"] + "args": ["0x0000000000000000000000000000000000000000", "0xA60Deae5344F1152426cA440fb6552eA0e3005D6"] }, - "implementation": "0x17D00a8926566CB4b02B25f4EE6ecC2cEB34A784", + "implementation": "0x7B9BFF3AEbAcE3715660e6340370810f10481b53", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/deployments/opbnbmainnet/BinanceOracle_Implementation.json b/deployments/opbnbmainnet/BinanceOracle_Implementation.json new file mode 100644 index 00000000..1bb6a1a2 --- /dev/null +++ b/deployments/opbnbmainnet/BinanceOracle_Implementation.json @@ -0,0 +1,757 @@ +{ + "address": "0x7B9BFF3AEbAcE3715660e6340370810f10481b53", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldFeedRegistry", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newFeedRegistry", + "type": "address" + } + ], + "name": "FeedRegistryUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "string", + "name": "asset", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "maxStalePeriod", + "type": "uint256" + } + ], + "name": "MaxStalePeriodAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "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": true, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "overriddenSymbol", + "type": "string" + } + ], + "name": "SymbolOverridden", + "type": "event" + }, + { + "inputs": [], + "name": "BNB_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feedRegistryAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFeedRegistryAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sidRegistryAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_accessControlManager", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "maxStalePeriod", + "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": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newfeedRegistryAddress", + "type": "address" + } + ], + "name": "setFeedRegistryAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_maxStalePeriod", + "type": "uint256" + } + ], + "name": "setMaxStalePeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "string", + "name": "overrideSymbol", + "type": "string" + } + ], + "name": "setSymbolOverride", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sidRegistryAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "symbols", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x76fe96c57cec4d5bb0eab94e24f633b830df482d0024a10719253acb934628ca", + "receipt": { + "to": null, + "from": "0x4a32670436a8A662E75E64B91B3Ab989B8a00064", + "contractAddress": "0x7B9BFF3AEbAcE3715660e6340370810f10481b53", + "transactionIndex": 1, + "gasUsed": "1455822", + "logsBloom": "0x00000000000000000000000000000000010000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xae4a6d9dd8702e31a59b41e5c47d674631eca4d603c06a8055bf5b5f5cf9cedc", + "transactionHash": "0x76fe96c57cec4d5bb0eab94e24f633b830df482d0024a10719253acb934628ca", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 11141029, + "transactionHash": "0x76fe96c57cec4d5bb0eab94e24f633b830df482d0024a10719253acb934628ca", + "address": "0x7B9BFF3AEbAcE3715660e6340370810f10481b53", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", + "logIndex": 0, + "blockHash": "0xae4a6d9dd8702e31a59b41e5c47d674631eca4d603c06a8055bf5b5f5cf9cedc" + } + ], + "blockNumber": 11141029, + "cumulativeGasUsed": "1502711", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "1e37f6e5d619feb70cefe47611ec524e", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"calledContract\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"methodSignature\",\"type\":\"string\"}],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldFeedRegistry\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newFeedRegistry\",\"type\":\"address\"}],\"name\":\"FeedRegistryUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"string\",\"name\":\"asset\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"maxStalePeriod\",\"type\":\"uint256\"}],\"name\":\"MaxStalePeriodAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAccessControlManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAccessControlManager\",\"type\":\"address\"}],\"name\":\"NewAccessControlManager\",\"type\":\"event\"},{\"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\":true,\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"overriddenSymbol\",\"type\":\"string\"}],\"name\":\"SymbolOverridden\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BNB_ADDR\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accessControlManager\",\"outputs\":[{\"internalType\":\"contract IAccessControlManagerV8\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feedRegistryAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getFeedRegistryAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_sidRegistryAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_accessControlManager\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"maxStalePeriod\",\"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\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"setAccessControlManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newfeedRegistryAddress\",\"type\":\"address\"}],\"name\":\"setFeedRegistryAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_maxStalePeriod\",\"type\":\"uint256\"}],\"name\":\"setMaxStalePeriod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"overrideSymbol\",\"type\":\"string\"}],\"name\":\"setSymbolOverride\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sidRegistryAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"symbols\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"getFeedRegistryAddress()\":{\"returns\":{\"_0\":\"feedRegistryAddress Address of binance oracle feed registry.\"}},\"getPrice(address)\":{\"params\":{\"asset\":\"Address of the asset\"},\"returns\":{\"_0\":\"Price in USD\"}},\"initialize(address,address)\":{\"params\":{\"_accessControlManager\":\"Address of the access control manager contract\",\"_sidRegistryAddress\":\"Address of SID registry\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"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.\"},\"setAccessControlManager(address)\":{\"custom:access\":\"Only Governance\",\"custom:event\":\"Emits NewAccessControlManager event\",\"details\":\"Admin function to set address of AccessControlManager\",\"params\":{\"accessControlManager_\":\"The new address of the AccessControlManager\"}},\"setFeedRegistryAddress(address)\":{\"params\":{\"newfeedRegistryAddress\":\"Address of new feed registry.\"}},\"setMaxStalePeriod(string,uint256)\":{\"params\":{\"_maxStalePeriod\":\"The max stake period\",\"symbol\":\"The symbol of the asset\"}},\"setSymbolOverride(string,string)\":{\"params\":{\"overrideSymbol\":\"The symbol after override\",\"symbol\":\"The symbol to override\"}},\"transferOwnership(address)\":{\"details\":\"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.\"}},\"title\":\"BinanceOracle\",\"version\":1},\"userdoc\":{\"errors\":{\"Unauthorized(address,address,string)\":[{\"notice\":\"Thrown when the action is prohibited by AccessControlManager\"}]},\"events\":{\"FeedRegistryUpdated(address,address)\":{\"notice\":\"Emits when address of feed registry is updated.\"},\"MaxStalePeriodAdded(string,uint256)\":{\"notice\":\"Emits when asset stale period is updated.\"},\"NewAccessControlManager(address,address)\":{\"notice\":\"Emitted when access control manager contract address is changed\"},\"SymbolOverridden(string,string)\":{\"notice\":\"Emits when symbol of the asset is updated.\"}},\"kind\":\"user\",\"methods\":{\"BNB_ADDR()\":{\"notice\":\"Set this as asset address for BNB. This is the underlying address for vBNB\"},\"accessControlManager()\":{\"notice\":\"Returns the address of the access control manager contract\"},\"constructor\":{\"notice\":\"Constructor for the implementation contract.\"},\"feedRegistryAddress()\":{\"notice\":\"Used to fetch price of assets used directly when space ID is not supported by current chain.\"},\"getFeedRegistryAddress()\":{\"notice\":\"Uses Space ID to fetch the feed registry address\"},\"getPrice(address)\":{\"notice\":\"Gets the price of a asset from the binance oracle\"},\"initialize(address,address)\":{\"notice\":\"Sets the contracts required to fetch prices\"},\"maxStalePeriod(string)\":{\"notice\":\"Max stale period configuration for assets\"},\"setAccessControlManager(address)\":{\"notice\":\"Sets the address of AccessControlManager\"},\"setFeedRegistryAddress(address)\":{\"notice\":\"Used to set feed registry address when current chain does not support space ID.\"},\"setMaxStalePeriod(string,uint256)\":{\"notice\":\"Used to set the max stale period of an asset\"},\"setSymbolOverride(string,string)\":{\"notice\":\"Used to override a symbol when fetching price\"},\"sidRegistryAddress()\":{\"notice\":\"Used to fetch feed registry address.\"},\"symbols(string)\":{\"notice\":\"Override symbols to be compatible with Binance feed registry\"}},\"notice\":\"This oracle fetches price of assets from Binance.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/oracles/BinanceOracle.sol\":\"BinanceOracle\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./OwnableUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\\n function __Ownable2Step_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable2Step_init_unchained() internal onlyInitializing {\\n }\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() public virtual {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x84efb8889801b0ac817324aff6acc691d07bbee816b671817132911d287a8c63\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x4075622496acc77fd6d4de4cc30a8577a744d5c75afad33fdeacf1704d6eda98\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```solidity\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n *\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized != type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x89be10e757d242e9b18d5a32c9fbe2019f6d63052bbe46397a430a1d60d7f794\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n *\\n * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9c80f545915582e63fe206c6ce27cbe85a86fc10b9cd2a0e8c9488fb7c2ee422\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x287b55befed2961a7eabd7d7b1b2839cbca8a5b80ef8dcbb25ed3d4c2002c305\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\\\";\\n\\nimport \\\"./IAccessControlManagerV8.sol\\\";\\n\\n/**\\n * @title AccessControlledV8\\n * @author Venus\\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\\n */\\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\\n /// @notice Access control manager contract\\n IAccessControlManagerV8 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /// @notice Thrown when the action is prohibited by AccessControlManager\\n error Unauthorized(address sender, address calledContract, string methodSignature);\\n\\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\\n __Ownable2Step_init();\\n __AccessControlled_init_unchained(accessControlManager_);\\n }\\n\\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Sets the address of AccessControlManager\\n * @dev Admin function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n * @custom:event Emits NewAccessControlManager event\\n * @custom:access Only Governance\\n */\\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV8) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert Unauthorized(msg.sender, address(this), signature);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1b805a5d09990e2c4f7839afe7726a02f8452261eb3d0d488e24129ec0a7736d\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/access/IAccessControl.sol\\\";\\n\\n/**\\n * @title IAccessControlManagerV8\\n * @author Venus\\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\\n */\\ninterface IAccessControlManagerV8 is IAccessControl {\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x8adbe291d659987faf4de606736227ad9d8e1a0e284a33a6ca12b30ab2a504b2\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/FeedRegistryInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface FeedRegistryInterface {\\n function latestRoundDataByName(\\n string memory base,\\n string memory quote\\n )\\n external\\n view\\n returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);\\n\\n function decimalsByName(string memory base, string memory quote) external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x326a2ae7b1ecfc3671ff569363a39c35f7430b13c545d388a0d9d8e29dd5bdb3\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface OracleInterface {\\n function getPrice(address asset) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n\\n function updateAssetPrice(address asset) external;\\n\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address asset) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address asset,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x40031b19684ca0c912e794d08c2c0b0d8be77d3c1bdc937830a0658eff899650\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/PublicResolverInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\n// SPDX-FileCopyrightText: 2022 Venus\\npragma solidity 0.8.13;\\n\\ninterface PublicResolverInterface {\\n function addr(bytes32 node) external view returns (address payable);\\n}\\n\",\"keccak256\":\"0xdacc261d23a3170a731f5a22377b452f227ebd0e54c7356278b271b55f82455d\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/SIDRegistryInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\n// SPDX-FileCopyrightText: 2022 Venus\\npragma solidity 0.8.13;\\n\\ninterface SIDRegistryInterface {\\n function resolver(bytes32 node) external view returns (address);\\n}\\n\",\"keccak256\":\"0x62bc5b95d657a1a8c64a1231510c3e8da7b6a71cb4bde7cd624854cd46f08a49\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/VBep20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\ninterface VBep20Interface is IERC20Metadata {\\n /**\\n * @notice Underlying asset for this VToken\\n */\\n function underlying() external view returns (address);\\n}\\n\",\"keccak256\":\"0x3f845cd51b2d82f7932ac6c0ab714df97f733b01ce50f6fb0adb4c28447d4618\",\"license\":\"BSD-3-Clause\"},\"contracts/oracles/BinanceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"../interfaces/VBep20Interface.sol\\\";\\nimport \\\"../interfaces/SIDRegistryInterface.sol\\\";\\nimport \\\"../interfaces/FeedRegistryInterface.sol\\\";\\nimport \\\"../interfaces/PublicResolverInterface.sol\\\";\\nimport \\\"../interfaces/OracleInterface.sol\\\";\\nimport \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\\\";\\nimport \\\"../interfaces/OracleInterface.sol\\\";\\n\\n/**\\n * @title BinanceOracle\\n * @author Venus\\n * @notice This oracle fetches price of assets from Binance.\\n */\\ncontract BinanceOracle is AccessControlledV8, OracleInterface {\\n /// @notice Used to fetch feed registry address.\\n address public sidRegistryAddress;\\n\\n /// @notice Set this as asset address for BNB. This is the underlying address for vBNB\\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\\n\\n /// @notice Max stale period configuration for assets\\n mapping(string => uint256) public maxStalePeriod;\\n\\n /// @notice Override symbols to be compatible with Binance feed registry\\n mapping(string => string) public symbols;\\n\\n /// @notice Used to fetch price of assets used directly when space ID is not supported by current chain.\\n address public feedRegistryAddress;\\n\\n /// @notice Emits when asset stale period is updated.\\n event MaxStalePeriodAdded(string indexed asset, uint256 maxStalePeriod);\\n\\n /// @notice Emits when symbol of the asset is updated.\\n event SymbolOverridden(string indexed symbol, string overriddenSymbol);\\n\\n /// @notice Emits when address of feed registry is updated.\\n event FeedRegistryUpdated(address indexed oldFeedRegistry, address indexed newFeedRegistry);\\n\\n /**\\n * @notice Checks whether an address is null or not\\n */\\n modifier notNullAddress(address someone) {\\n if (someone == address(0)) revert(\\\"can't be zero address\\\");\\n _;\\n }\\n\\n /// @notice Constructor for the implementation contract.\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /**\\n * @notice Sets the contracts required to fetch prices\\n * @param _sidRegistryAddress Address of SID registry\\n * @param _accessControlManager Address of the access control manager contract\\n */\\n function initialize(address _sidRegistryAddress, address _accessControlManager) external initializer {\\n sidRegistryAddress = _sidRegistryAddress;\\n __AccessControlled_init(_accessControlManager);\\n }\\n\\n /**\\n * @notice Used to set the max stale period of an asset\\n * @param symbol The symbol of the asset\\n * @param _maxStalePeriod The max stake period\\n */\\n function setMaxStalePeriod(string memory symbol, uint256 _maxStalePeriod) external {\\n _checkAccessAllowed(\\\"setMaxStalePeriod(string,uint256)\\\");\\n if (_maxStalePeriod == 0) revert(\\\"stale period can't be zero\\\");\\n if (bytes(symbol).length == 0) revert(\\\"symbol cannot be empty\\\");\\n\\n maxStalePeriod[symbol] = _maxStalePeriod;\\n emit MaxStalePeriodAdded(symbol, _maxStalePeriod);\\n }\\n\\n /**\\n * @notice Used to override a symbol when fetching price\\n * @param symbol The symbol to override\\n * @param overrideSymbol The symbol after override\\n */\\n function setSymbolOverride(string calldata symbol, string calldata overrideSymbol) external {\\n _checkAccessAllowed(\\\"setSymbolOverride(string,string)\\\");\\n if (bytes(symbol).length == 0) revert(\\\"symbol cannot be empty\\\");\\n\\n symbols[symbol] = overrideSymbol;\\n emit SymbolOverridden(symbol, overrideSymbol);\\n }\\n\\n /**\\n * @notice Used to set feed registry address when current chain does not support space ID.\\n * @param newfeedRegistryAddress Address of new feed registry.\\n */\\n function setFeedRegistryAddress(\\n address newfeedRegistryAddress\\n ) external notNullAddress(newfeedRegistryAddress) onlyOwner {\\n if (sidRegistryAddress != address(0)) revert(\\\"sidRegistryAddress must be zero\\\");\\n emit FeedRegistryUpdated(feedRegistryAddress, newfeedRegistryAddress);\\n feedRegistryAddress = newfeedRegistryAddress;\\n }\\n\\n /**\\n * @notice Uses Space ID to fetch the feed registry address\\n * @return feedRegistryAddress Address of binance oracle feed registry.\\n */\\n function getFeedRegistryAddress() public view returns (address) {\\n bytes32 nodeHash = 0x94fe3821e0768eb35012484db4df61890f9a6ca5bfa984ef8ff717e73139faff;\\n\\n SIDRegistryInterface sidRegistry = SIDRegistryInterface(sidRegistryAddress);\\n address publicResolverAddress = sidRegistry.resolver(nodeHash);\\n PublicResolverInterface publicResolver = PublicResolverInterface(publicResolverAddress);\\n\\n return publicResolver.addr(nodeHash);\\n }\\n\\n /**\\n * @notice Gets the price of a asset from the binance oracle\\n * @param asset Address of the asset\\n * @return Price in USD\\n */\\n function getPrice(address asset) public view returns (uint256) {\\n string memory symbol;\\n uint256 decimals;\\n\\n if (asset == BNB_ADDR) {\\n symbol = \\\"BNB\\\";\\n decimals = 18;\\n } else {\\n IERC20Metadata token = IERC20Metadata(asset);\\n symbol = token.symbol();\\n decimals = token.decimals();\\n }\\n\\n string memory overrideSymbol = symbols[symbol];\\n\\n if (bytes(overrideSymbol).length != 0) {\\n symbol = overrideSymbol;\\n }\\n\\n return _getPrice(symbol, decimals);\\n }\\n\\n function _getPrice(string memory symbol, uint256 decimals) internal view returns (uint256) {\\n FeedRegistryInterface feedRegistry;\\n\\n if (sidRegistryAddress != address(0)) {\\n // If sidRegistryAddress is available, fetch feedRegistryAddress from sidRegistry\\n feedRegistry = FeedRegistryInterface(getFeedRegistryAddress());\\n } else {\\n // Use feedRegistry directly if sidRegistryAddress is not available\\n feedRegistry = FeedRegistryInterface(feedRegistryAddress);\\n }\\n\\n (, int256 answer, , uint256 updatedAt, ) = feedRegistry.latestRoundDataByName(symbol, \\\"USD\\\");\\n if (answer <= 0) revert(\\\"invalid binance oracle price\\\");\\n if (block.timestamp < updatedAt) revert(\\\"updatedAt exceeds block time\\\");\\n\\n uint256 deltaTime;\\n unchecked {\\n deltaTime = block.timestamp - updatedAt;\\n }\\n if (deltaTime > maxStalePeriod[symbol]) revert(\\\"binance oracle price expired\\\");\\n\\n uint256 decimalDelta = feedRegistry.decimalsByName(symbol, \\\"USD\\\");\\n return (uint256(answer) * (10 ** (18 - decimalDelta))) * (10 ** (18 - decimals));\\n }\\n}\\n\",\"keccak256\":\"0x3e3c8805f82c1c1ecefcbec4e8496cd5831505890c0a1a8dd5beec42f0abb97e\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061001961001e565b6100dd565b600054610100900460ff161561008a5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146100db576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6118e4806100ec6000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063715018a6116100a25780639eab1ad6116100715780639eab1ad614610231578063b4a0bdf314610244578063e30c397814610255578063f2fde38b14610266578063fdfbc2771461027957600080fd5b8063715018a61461020857806379ba5097146102105780638da5cb5b1461021857806399fe040e1461022957600080fd5b80633e83b6b8116100e95780633e83b6b81461019357806341976e09146101ae578063475e7de5146101cf578063485cc955146101e2578063636b999a146101f557600080fd5b8063011d39621461011b578063047a74b21461014b5780630e32cb861461016b578063255ce37a14610180575b600080fd5b60cc5461012e906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b61015e610159366004611292565b6102a4565b604051610142919061132b565b61017e61017936600461135a565b610349565b005b61017e61018e36600461135a565b61035d565b61012e73bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb81565b6101c16101bc36600461135a565b61046f565b604051908152602001610142565b60c95461012e906001600160a01b031681565b61017e6101f0366004611377565b61065d565b61017e6102033660046113b0565b61078c565b61017e6108b4565b61017e6108c8565b6033546001600160a01b031661012e565b61012e61093f565b61017e61023f36600461143e565b610a4d565b6097546001600160a01b031661012e565b6065546001600160a01b031661012e565b61017e61027436600461135a565b610b5b565b6101c1610287366004611292565b805160208183018101805160ca8252928201919093012091525481565b805160208183018101805160cb82529282019190930120915280546102c8906114aa565b80601f01602080910402602001604051908101604052809291908181526020018280546102f4906114aa565b80156103415780601f1061031657610100808354040283529160200191610341565b820191906000526020600020905b81548152906001019060200180831161032457829003601f168201915b505050505081565b610351610bcc565b61035a81610c26565b50565b806001600160a01b0381166103b15760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b60448201526064015b60405180910390fd5b6103b9610bcc565b60c9546001600160a01b0316156104125760405162461bcd60e51b815260206004820152601f60248201527f736964526567697374727941646472657373206d757374206265207a65726f0060448201526064016103a8565b60cc546040516001600160a01b038085169216907f6d1006252b3dd171af76c28c184327bfddc39f439a50e0ac7f418c660b8894b590600090a35060cc80546001600160a01b0319166001600160a01b0392909216919091179055565b600060608173bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba196001600160a01b038516016104bc57505060408051808201909152600381526221272160e91b60208201526012610592565b6000849050806001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156104ff573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261052791908101906114e4565b9250806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610567573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061058b9190611552565b60ff169150505b600060cb836040516105a49190611575565b908152602001604051809103902080546105bd906114aa565b80601f01602080910402602001604051908101604052809291908181526020018280546105e9906114aa565b80156106365780601f1061060b57610100808354040283529160200191610636565b820191906000526020600020905b81548152906001019060200180831161061957829003601f168201915b50505050509050805160001461064a578092505b6106548383610ceb565b95945050505050565b600054610100900460ff161580801561067d5750600054600160ff909116105b806106975750303b158015610697575060005460ff166001145b6106fa5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103a8565b6000805460ff19166001179055801561071d576000805461ff0019166101001790555b60c980546001600160a01b0319166001600160a01b03851617905561074182610f6d565b8015610787576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b6107ad60405180606001604052806021815260200161188e60219139610fa5565b806000036107fd5760405162461bcd60e51b815260206004820152601a60248201527f7374616c6520706572696f642063616e2774206265207a65726f00000000000060448201526064016103a8565b81516000036108475760405162461bcd60e51b815260206004820152601660248201527573796d626f6c2063616e6e6f7420626520656d70747960501b60448201526064016103a8565b8060ca836040516108589190611575565b90815260405190819003602001812091909155610876908390611575565b604051908190038120828252907f37839d4a80c5e3f2578f59515c911ee8cce42383d7ebaa1c92afcde9871c4b589060200160405180910390a25050565b6108bc610bcc565b6108c66000611043565b565b60655433906001600160a01b031681146109365760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016103a8565b61035a81611043565b60c954604051630178b8bf60e01b81527f94fe3821e0768eb35012484db4df61890f9a6ca5bfa984ef8ff717e73139faff6004820181905260009290916001600160a01b039091169083908290630178b8bf90602401602060405180830381865afa1580156109b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d69190611591565b604051631d9dabef60e11b81526004810185905290915081906001600160a01b03821690633b3b57de90602401602060405180830381865afa158015610a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a449190611591565b94505050505090565b610a8b6040518060400160405280602081526020017f73657453796d626f6c4f7665727269646528737472696e672c737472696e6729815250610fa5565b6000839003610ad55760405162461bcd60e51b815260206004820152601660248201527573796d626f6c2063616e6e6f7420626520656d70747960501b60448201526064016103a8565b818160cb8686604051610ae99291906115ae565b908152604051908190036020019020610b03929091611134565b508383604051610b149291906115ae565b60405180910390207fceb1f47aa91b96f02ea70e1deed25fe154ad1885aea509bd7222f9eec0a0bda58383604051610b4d9291906115be565b60405180910390a250505050565b610b63610bcc565b606580546001600160a01b0383166001600160a01b03199091168117909155610b946033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6033546001600160a01b031633146108c65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103a8565b6001600160a01b038116610c8a5760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b60648201526084016103a8565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0910160405180910390a15050565b60c95460009081906001600160a01b031615610d1057610d0961093f565b9050610d1e565b5060cc546001600160a01b03165b600080826001600160a01b031663bfda5e71876040518263ffffffff1660e01b8152600401610d4d91906115ed565b60a060405180830381865afa158015610d6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8e9190611644565b5093505092505060008213610de55760405162461bcd60e51b815260206004820152601c60248201527f696e76616c69642062696e616e6365206f7261636c652070726963650000000060448201526064016103a8565b80421015610e355760405162461bcd60e51b815260206004820152601c60248201527f757064617465644174206578636565647320626c6f636b2074696d650000000060448201526064016103a8565b6000814203905060ca87604051610e4c9190611575565b908152602001604051809103902054811115610eaa5760405162461bcd60e51b815260206004820152601c60248201527f62696e616e6365206f7261636c6520707269636520657870697265640000000060448201526064016103a8565b604051633748ccad60e11b81526000906001600160a01b03861690636e91995a90610ed9908b906004016115ed565b602060405180830381865afa158015610ef6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1a9190611552565b60ff169050610f2a8760126116aa565b610f3590600a6117a5565b610f408260126116aa565b610f4b90600a6117a5565b610f5590866117b1565b610f5f91906117b1565b955050505050505b92915050565b600054610100900460ff16610f945760405162461bcd60e51b81526004016103a8906117d0565b610f9c61105c565b61035a8161108b565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab90610fd8903390869060040161181b565b602060405180830381865afa158015610ff5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611019919061183f565b90508061103f57333083604051634a3fa29360e01b81526004016103a893929190611861565b5050565b606580546001600160a01b031916905561035a816110b2565b600054610100900460ff166110835760405162461bcd60e51b81526004016103a8906117d0565b6108c6611104565b600054610100900460ff166103515760405162461bcd60e51b81526004016103a8906117d0565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661112b5760405162461bcd60e51b81526004016103a8906117d0565b6108c633611043565b828054611140906114aa565b90600052602060002090601f01602090048101928261116257600085556111a8565b82601f1061117b5782800160ff198235161785556111a8565b828001600101855582156111a8579182015b828111156111a857823582559160200191906001019061118d565b506111b49291506111b8565b5090565b5b808211156111b457600081556001016111b9565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561120c5761120c6111cd565b604052919050565b600067ffffffffffffffff82111561122e5761122e6111cd565b50601f01601f191660200190565b600082601f83011261124d57600080fd5b813561126061125b82611214565b6111e3565b81815284602083860101111561127557600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156112a457600080fd5b813567ffffffffffffffff8111156112bb57600080fd5b6112c78482850161123c565b949350505050565b60005b838110156112ea5781810151838201526020016112d2565b838111156112f9576000848401525b50505050565b600081518084526113178160208601602086016112cf565b601f01601f19169290920160200192915050565b60208152600061133e60208301846112ff565b9392505050565b6001600160a01b038116811461035a57600080fd5b60006020828403121561136c57600080fd5b813561133e81611345565b6000806040838503121561138a57600080fd5b823561139581611345565b915060208301356113a581611345565b809150509250929050565b600080604083850312156113c357600080fd5b823567ffffffffffffffff8111156113da57600080fd5b6113e68582860161123c565b95602094909401359450505050565b60008083601f84011261140757600080fd5b50813567ffffffffffffffff81111561141f57600080fd5b60208301915083602082850101111561143757600080fd5b9250929050565b6000806000806040858703121561145457600080fd5b843567ffffffffffffffff8082111561146c57600080fd5b611478888389016113f5565b9096509450602087013591508082111561149157600080fd5b5061149e878288016113f5565b95989497509550505050565b600181811c908216806114be57607f821691505b6020821081036114de57634e487b7160e01b600052602260045260246000fd5b50919050565b6000602082840312156114f657600080fd5b815167ffffffffffffffff81111561150d57600080fd5b8201601f8101841361151e57600080fd5b805161152c61125b82611214565b81815285602083850101111561154157600080fd5b6106548260208301602086016112cf565b60006020828403121561156457600080fd5b815160ff8116811461133e57600080fd5b600082516115878184602087016112cf565b9190910192915050565b6000602082840312156115a357600080fd5b815161133e81611345565b8183823760009101908152919050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b60408152600061160060408301846112ff565b828103602084015260038152621554d160ea1b60208201526040810191505092915050565b805169ffffffffffffffffffff8116811461163f57600080fd5b919050565b600080600080600060a0868803121561165c57600080fd5b61166586611625565b945060208601519350604086015192506060860151915061168860808701611625565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b6000828210156116bc576116bc611694565b500390565b600181815b808511156116fc5781600019048211156116e2576116e2611694565b808516156116ef57918102915b93841c93908002906116c6565b509250929050565b60008261171357506001610f67565b8161172057506000610f67565b816001811461173657600281146117405761175c565b6001915050610f67565b60ff84111561175157611751611694565b50506001821b610f67565b5060208310610133831016604e8410600b841016171561177f575081810a610f67565b61178983836116c1565b806000190482111561179d5761179d611694565b029392505050565b600061133e8383611704565b60008160001904831182151516156117cb576117cb611694565b500290565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6001600160a01b03831681526040602082018190526000906112c7908301846112ff565b60006020828403121561185157600080fd5b8151801515811461133e57600080fd5b6001600160a01b03848116825283166020820152606060408201819052600090610654908301846112ff56fe7365744d61785374616c65506572696f6428737472696e672c75696e7432353629a2646970667358221220723e85edca51e34e030621f5efdfc0d303c604bfe8ffe7b19ec5a6abfebb512a64736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063715018a6116100a25780639eab1ad6116100715780639eab1ad614610231578063b4a0bdf314610244578063e30c397814610255578063f2fde38b14610266578063fdfbc2771461027957600080fd5b8063715018a61461020857806379ba5097146102105780638da5cb5b1461021857806399fe040e1461022957600080fd5b80633e83b6b8116100e95780633e83b6b81461019357806341976e09146101ae578063475e7de5146101cf578063485cc955146101e2578063636b999a146101f557600080fd5b8063011d39621461011b578063047a74b21461014b5780630e32cb861461016b578063255ce37a14610180575b600080fd5b60cc5461012e906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b61015e610159366004611292565b6102a4565b604051610142919061132b565b61017e61017936600461135a565b610349565b005b61017e61018e36600461135a565b61035d565b61012e73bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb81565b6101c16101bc36600461135a565b61046f565b604051908152602001610142565b60c95461012e906001600160a01b031681565b61017e6101f0366004611377565b61065d565b61017e6102033660046113b0565b61078c565b61017e6108b4565b61017e6108c8565b6033546001600160a01b031661012e565b61012e61093f565b61017e61023f36600461143e565b610a4d565b6097546001600160a01b031661012e565b6065546001600160a01b031661012e565b61017e61027436600461135a565b610b5b565b6101c1610287366004611292565b805160208183018101805160ca8252928201919093012091525481565b805160208183018101805160cb82529282019190930120915280546102c8906114aa565b80601f01602080910402602001604051908101604052809291908181526020018280546102f4906114aa565b80156103415780601f1061031657610100808354040283529160200191610341565b820191906000526020600020905b81548152906001019060200180831161032457829003601f168201915b505050505081565b610351610bcc565b61035a81610c26565b50565b806001600160a01b0381166103b15760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b60448201526064015b60405180910390fd5b6103b9610bcc565b60c9546001600160a01b0316156104125760405162461bcd60e51b815260206004820152601f60248201527f736964526567697374727941646472657373206d757374206265207a65726f0060448201526064016103a8565b60cc546040516001600160a01b038085169216907f6d1006252b3dd171af76c28c184327bfddc39f439a50e0ac7f418c660b8894b590600090a35060cc80546001600160a01b0319166001600160a01b0392909216919091179055565b600060608173bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba196001600160a01b038516016104bc57505060408051808201909152600381526221272160e91b60208201526012610592565b6000849050806001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156104ff573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261052791908101906114e4565b9250806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610567573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061058b9190611552565b60ff169150505b600060cb836040516105a49190611575565b908152602001604051809103902080546105bd906114aa565b80601f01602080910402602001604051908101604052809291908181526020018280546105e9906114aa565b80156106365780601f1061060b57610100808354040283529160200191610636565b820191906000526020600020905b81548152906001019060200180831161061957829003601f168201915b50505050509050805160001461064a578092505b6106548383610ceb565b95945050505050565b600054610100900460ff161580801561067d5750600054600160ff909116105b806106975750303b158015610697575060005460ff166001145b6106fa5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103a8565b6000805460ff19166001179055801561071d576000805461ff0019166101001790555b60c980546001600160a01b0319166001600160a01b03851617905561074182610f6d565b8015610787576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b6107ad60405180606001604052806021815260200161188e60219139610fa5565b806000036107fd5760405162461bcd60e51b815260206004820152601a60248201527f7374616c6520706572696f642063616e2774206265207a65726f00000000000060448201526064016103a8565b81516000036108475760405162461bcd60e51b815260206004820152601660248201527573796d626f6c2063616e6e6f7420626520656d70747960501b60448201526064016103a8565b8060ca836040516108589190611575565b90815260405190819003602001812091909155610876908390611575565b604051908190038120828252907f37839d4a80c5e3f2578f59515c911ee8cce42383d7ebaa1c92afcde9871c4b589060200160405180910390a25050565b6108bc610bcc565b6108c66000611043565b565b60655433906001600160a01b031681146109365760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016103a8565b61035a81611043565b60c954604051630178b8bf60e01b81527f94fe3821e0768eb35012484db4df61890f9a6ca5bfa984ef8ff717e73139faff6004820181905260009290916001600160a01b039091169083908290630178b8bf90602401602060405180830381865afa1580156109b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d69190611591565b604051631d9dabef60e11b81526004810185905290915081906001600160a01b03821690633b3b57de90602401602060405180830381865afa158015610a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a449190611591565b94505050505090565b610a8b6040518060400160405280602081526020017f73657453796d626f6c4f7665727269646528737472696e672c737472696e6729815250610fa5565b6000839003610ad55760405162461bcd60e51b815260206004820152601660248201527573796d626f6c2063616e6e6f7420626520656d70747960501b60448201526064016103a8565b818160cb8686604051610ae99291906115ae565b908152604051908190036020019020610b03929091611134565b508383604051610b149291906115ae565b60405180910390207fceb1f47aa91b96f02ea70e1deed25fe154ad1885aea509bd7222f9eec0a0bda58383604051610b4d9291906115be565b60405180910390a250505050565b610b63610bcc565b606580546001600160a01b0383166001600160a01b03199091168117909155610b946033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6033546001600160a01b031633146108c65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103a8565b6001600160a01b038116610c8a5760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b60648201526084016103a8565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0910160405180910390a15050565b60c95460009081906001600160a01b031615610d1057610d0961093f565b9050610d1e565b5060cc546001600160a01b03165b600080826001600160a01b031663bfda5e71876040518263ffffffff1660e01b8152600401610d4d91906115ed565b60a060405180830381865afa158015610d6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8e9190611644565b5093505092505060008213610de55760405162461bcd60e51b815260206004820152601c60248201527f696e76616c69642062696e616e6365206f7261636c652070726963650000000060448201526064016103a8565b80421015610e355760405162461bcd60e51b815260206004820152601c60248201527f757064617465644174206578636565647320626c6f636b2074696d650000000060448201526064016103a8565b6000814203905060ca87604051610e4c9190611575565b908152602001604051809103902054811115610eaa5760405162461bcd60e51b815260206004820152601c60248201527f62696e616e6365206f7261636c6520707269636520657870697265640000000060448201526064016103a8565b604051633748ccad60e11b81526000906001600160a01b03861690636e91995a90610ed9908b906004016115ed565b602060405180830381865afa158015610ef6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1a9190611552565b60ff169050610f2a8760126116aa565b610f3590600a6117a5565b610f408260126116aa565b610f4b90600a6117a5565b610f5590866117b1565b610f5f91906117b1565b955050505050505b92915050565b600054610100900460ff16610f945760405162461bcd60e51b81526004016103a8906117d0565b610f9c61105c565b61035a8161108b565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab90610fd8903390869060040161181b565b602060405180830381865afa158015610ff5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611019919061183f565b90508061103f57333083604051634a3fa29360e01b81526004016103a893929190611861565b5050565b606580546001600160a01b031916905561035a816110b2565b600054610100900460ff166110835760405162461bcd60e51b81526004016103a8906117d0565b6108c6611104565b600054610100900460ff166103515760405162461bcd60e51b81526004016103a8906117d0565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661112b5760405162461bcd60e51b81526004016103a8906117d0565b6108c633611043565b828054611140906114aa565b90600052602060002090601f01602090048101928261116257600085556111a8565b82601f1061117b5782800160ff198235161785556111a8565b828001600101855582156111a8579182015b828111156111a857823582559160200191906001019061118d565b506111b49291506111b8565b5090565b5b808211156111b457600081556001016111b9565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561120c5761120c6111cd565b604052919050565b600067ffffffffffffffff82111561122e5761122e6111cd565b50601f01601f191660200190565b600082601f83011261124d57600080fd5b813561126061125b82611214565b6111e3565b81815284602083860101111561127557600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156112a457600080fd5b813567ffffffffffffffff8111156112bb57600080fd5b6112c78482850161123c565b949350505050565b60005b838110156112ea5781810151838201526020016112d2565b838111156112f9576000848401525b50505050565b600081518084526113178160208601602086016112cf565b601f01601f19169290920160200192915050565b60208152600061133e60208301846112ff565b9392505050565b6001600160a01b038116811461035a57600080fd5b60006020828403121561136c57600080fd5b813561133e81611345565b6000806040838503121561138a57600080fd5b823561139581611345565b915060208301356113a581611345565b809150509250929050565b600080604083850312156113c357600080fd5b823567ffffffffffffffff8111156113da57600080fd5b6113e68582860161123c565b95602094909401359450505050565b60008083601f84011261140757600080fd5b50813567ffffffffffffffff81111561141f57600080fd5b60208301915083602082850101111561143757600080fd5b9250929050565b6000806000806040858703121561145457600080fd5b843567ffffffffffffffff8082111561146c57600080fd5b611478888389016113f5565b9096509450602087013591508082111561149157600080fd5b5061149e878288016113f5565b95989497509550505050565b600181811c908216806114be57607f821691505b6020821081036114de57634e487b7160e01b600052602260045260246000fd5b50919050565b6000602082840312156114f657600080fd5b815167ffffffffffffffff81111561150d57600080fd5b8201601f8101841361151e57600080fd5b805161152c61125b82611214565b81815285602083850101111561154157600080fd5b6106548260208301602086016112cf565b60006020828403121561156457600080fd5b815160ff8116811461133e57600080fd5b600082516115878184602087016112cf565b9190910192915050565b6000602082840312156115a357600080fd5b815161133e81611345565b8183823760009101908152919050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b60408152600061160060408301846112ff565b828103602084015260038152621554d160ea1b60208201526040810191505092915050565b805169ffffffffffffffffffff8116811461163f57600080fd5b919050565b600080600080600060a0868803121561165c57600080fd5b61166586611625565b945060208601519350604086015192506060860151915061168860808701611625565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b6000828210156116bc576116bc611694565b500390565b600181815b808511156116fc5781600019048211156116e2576116e2611694565b808516156116ef57918102915b93841c93908002906116c6565b509250929050565b60008261171357506001610f67565b8161172057506000610f67565b816001811461173657600281146117405761175c565b6001915050610f67565b60ff84111561175157611751611694565b50506001821b610f67565b5060208310610133831016604e8410600b841016171561177f575081810a610f67565b61178983836116c1565b806000190482111561179d5761179d611694565b029392505050565b600061133e8383611704565b60008160001904831182151516156117cb576117cb611694565b500290565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6001600160a01b03831681526040602082018190526000906112c7908301846112ff565b60006020828403121561185157600080fd5b8151801515811461133e57600080fd5b6001600160a01b03848116825283166020820152606060408201819052600090610654908301846112ff56fe7365744d61785374616c65506572696f6428737472696e672c75696e7432353629a2646970667358221220723e85edca51e34e030621f5efdfc0d303c604bfe8ffe7b19ec5a6abfebb512a64736f6c634300080d0033", + "devdoc": { + "author": "Venus", + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "constructor": { + "custom:oz-upgrades-unsafe-allow": "constructor" + }, + "getFeedRegistryAddress()": { + "returns": { + "_0": "feedRegistryAddress Address of binance oracle feed registry." + } + }, + "getPrice(address)": { + "params": { + "asset": "Address of the asset" + }, + "returns": { + "_0": "Price in USD" + } + }, + "initialize(address,address)": { + "params": { + "_accessControlManager": "Address of the access control manager contract", + "_sidRegistryAddress": "Address of SID registry" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "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." + }, + "setAccessControlManager(address)": { + "custom:access": "Only Governance", + "custom:event": "Emits NewAccessControlManager event", + "details": "Admin function to set address of AccessControlManager", + "params": { + "accessControlManager_": "The new address of the AccessControlManager" + } + }, + "setFeedRegistryAddress(address)": { + "params": { + "newfeedRegistryAddress": "Address of new feed registry." + } + }, + "setMaxStalePeriod(string,uint256)": { + "params": { + "_maxStalePeriod": "The max stake period", + "symbol": "The symbol of the asset" + } + }, + "setSymbolOverride(string,string)": { + "params": { + "overrideSymbol": "The symbol after override", + "symbol": "The symbol to override" + } + }, + "transferOwnership(address)": { + "details": "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." + } + }, + "title": "BinanceOracle", + "version": 1 + }, + "userdoc": { + "errors": { + "Unauthorized(address,address,string)": [ + { + "notice": "Thrown when the action is prohibited by AccessControlManager" + } + ] + }, + "events": { + "FeedRegistryUpdated(address,address)": { + "notice": "Emits when address of feed registry is updated." + }, + "MaxStalePeriodAdded(string,uint256)": { + "notice": "Emits when asset stale period is updated." + }, + "NewAccessControlManager(address,address)": { + "notice": "Emitted when access control manager contract address is changed" + }, + "SymbolOverridden(string,string)": { + "notice": "Emits when symbol of the asset is updated." + } + }, + "kind": "user", + "methods": { + "BNB_ADDR()": { + "notice": "Set this as asset address for BNB. This is the underlying address for vBNB" + }, + "accessControlManager()": { + "notice": "Returns the address of the access control manager contract" + }, + "constructor": { + "notice": "Constructor for the implementation contract." + }, + "feedRegistryAddress()": { + "notice": "Used to fetch price of assets used directly when space ID is not supported by current chain." + }, + "getFeedRegistryAddress()": { + "notice": "Uses Space ID to fetch the feed registry address" + }, + "getPrice(address)": { + "notice": "Gets the price of a asset from the binance oracle" + }, + "initialize(address,address)": { + "notice": "Sets the contracts required to fetch prices" + }, + "maxStalePeriod(string)": { + "notice": "Max stale period configuration for assets" + }, + "setAccessControlManager(address)": { + "notice": "Sets the address of AccessControlManager" + }, + "setFeedRegistryAddress(address)": { + "notice": "Used to set feed registry address when current chain does not support space ID." + }, + "setMaxStalePeriod(string,uint256)": { + "notice": "Used to set the max stale period of an asset" + }, + "setSymbolOverride(string,string)": { + "notice": "Used to override a symbol when fetching price" + }, + "sidRegistryAddress()": { + "notice": "Used to fetch feed registry address." + }, + "symbols(string)": { + "notice": "Override symbols to be compatible with Binance feed registry" + } + }, + "notice": "This oracle fetches price of assets from Binance.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 347, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 350, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1007, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 219, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 339, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 128, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "_pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 207, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 5079, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "_accessControlManager", + "offset": 0, + "slot": "151", + "type": "t_contract(IAccessControlManagerV8)5264" + }, + { + "astId": 5084, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 6889, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "sidRegistryAddress", + "offset": 0, + "slot": "201", + "type": "t_address" + }, + { + "astId": 6898, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "maxStalePeriod", + "offset": 0, + "slot": "202", + "type": "t_mapping(t_string_memory_ptr,t_uint256)" + }, + { + "astId": 6903, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "symbols", + "offset": 0, + "slot": "203", + "type": "t_mapping(t_string_memory_ptr,t_string_storage)" + }, + { + "astId": 6906, + "contract": "contracts/oracles/BinanceOracle.sol:BinanceOracle", + "label": "feedRegistryAddress", + "offset": 0, + "slot": "204", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IAccessControlManagerV8)5264": { + "encoding": "inplace", + "label": "contract IAccessControlManagerV8", + "numberOfBytes": "20" + }, + "t_mapping(t_string_memory_ptr,t_string_storage)": { + "encoding": "mapping", + "key": "t_string_memory_ptr", + "label": "mapping(string => string)", + "numberOfBytes": "32", + "value": "t_string_storage" + }, + "t_mapping(t_string_memory_ptr,t_uint256)": { + "encoding": "mapping", + "key": "t_string_memory_ptr", + "label": "mapping(string => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_string_memory_ptr": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/opbnbmainnet/BinanceOracle_Proxy.json b/deployments/opbnbmainnet/BinanceOracle_Proxy.json new file mode 100644 index 00000000..36fcb79f --- /dev/null +++ b/deployments/opbnbmainnet/BinanceOracle_Proxy.json @@ -0,0 +1,251 @@ +{ + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "receipt": { + "to": null, + "from": "0x4a32670436a8A662E75E64B91B3Ab989B8a00064", + "contractAddress": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "transactionIndex": 1, + "gasUsed": "700788", + "logsBloom": "0x00000000000000000000000000040000600000000000000000800000000000000000000000000000000000000000000100000000000000000000000100008000000000000800000000000000000002000001000000000000000000000000080000000000020000000000000000000800000000800000000000000000000000400000000000000000000000000000020000000000000080000000000000800000000080000000000000000000000400000000000000800000000000000000000000000020000000000000000000040000000001000400000000000000000020000000000000000000000000000000000000000800000000000000000000000000", + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624", + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 11141035, + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x0000000000000000000000007b9bff3aebace3715660e6340370810f10481b53" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624" + }, + { + "transactionIndex": 1, + "blockNumber": 11141035, + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000004a32670436a8a662e75e64b91b3ab989b8a00064" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624" + }, + { + "transactionIndex": 1, + "blockNumber": 11141035, + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6", + "logIndex": 2, + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624" + }, + { + "transactionIndex": 1, + "blockNumber": 11141035, + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624" + }, + { + "transactionIndex": 1, + "blockNumber": 11141035, + "transactionHash": "0x6fed8e193faa4a9dcfe2143eb48c7093f401065ffeb726894ef820f9426f4709", + "address": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f77bd1d893f67b3eb2cd256239c98ba3f238fb52", + "logIndex": 4, + "blockHash": "0x7eabd173d01abc1e67ee7b652a08972416150cfd2ac6cf814cba56efc6463624" + } + ], + "blockNumber": 11141035, + "cumulativeGasUsed": "747677", + "status": 1, + "byzantium": true + }, + "args": [ + "0x7B9BFF3AEbAcE3715660e6340370810f10481b53", + "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "0x485cc9550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"},\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n\\n function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405260405162000f5f38038062000f5f83398101604081905262000026916200044a565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6200052a565b60008051602062000f188339815191521462000075576200007562000550565b62000083828260006200013c565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046200052a565b60008051602062000ef883398151915214620000d357620000d362000550565b6001600160a01b038216608081905260008051602062000ef88339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050620005b9565b620001478362000179565b600082511180620001555750805b156200017457620001728383620001bb60201b620002a91760201c565b505b505050565b6200018481620001ea565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e3838360405180606001604052806027815260200162000f3860279139620002b2565b9392505050565b62000200816200039860201b620002d51760201c565b620002685760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806200029160008051602062000f1883398151915260001b620003a760201b620002411760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606001600160a01b0384163b6200031c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200025f565b600080856001600160a01b03168560405162000339919062000566565b600060405180830381855af49150503d806000811462000376576040519150601f19603f3d011682016040523d82523d6000602084013e6200037b565b606091505b5090925090506200038e828286620003aa565b9695505050505050565b6001600160a01b03163b151590565b90565b60608315620003bb575081620001e3565b825115620003cc5782518084602001fd5b8160405162461bcd60e51b81526004016200025f919062000584565b80516001600160a01b03811681146200040057600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004385781810151838201526020016200041e565b83811115620001725750506000910152565b6000806000606084860312156200046057600080fd5b6200046b84620003e8565b92506200047b60208501620003e8565b60408501519092506001600160401b03808211156200049957600080fd5b818601915086601f830112620004ae57600080fd5b815181811115620004c357620004c362000405565b604051601f8201601f19908116603f01168101908382118183101715620004ee57620004ee62000405565b816040528281528960208487010111156200050857600080fd5b6200051b8360208301602088016200041b565b80955050505050509250925092565b6000828210156200054b57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b600082516200057a8184602087016200041b565b9190910192915050565b6020815260008251806020840152620005a58160408501602087016200041b565b601f01601f19169190910160400192915050565b608051610900620005f86000396000818161011201528181610176015281816102060152818161025e01528181610287015261030901526109006000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/opbnbmainnet/BoundValidator.json b/deployments/opbnbmainnet/BoundValidator.json new file mode 100644 index 00000000..1a62a4cf --- /dev/null +++ b/deployments/opbnbmainnet/BoundValidator.json @@ -0,0 +1,582 @@ +{ + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "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": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "upperBound", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "lowerBound", + "type": "uint256" + } + ], + "name": "ValidateConfigAdded", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "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": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "internalType": "struct BoundValidator.ValidateConfig", + "name": "config", + "type": "tuple" + } + ], + "name": "setValidateConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "internalType": "struct BoundValidator.ValidateConfig[]", + "name": "configs", + "type": "tuple[]" + } + ], + "name": "setValidateConfigs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "validateConfigs", + "outputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "reportedPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "anchorPrice", + "type": "uint256" + } + ], + "name": "validatePriceWithAnchorPrice", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "receipt": { + "to": null, + "from": "0x4a32670436a8A662E75E64B91B3Ab989B8a00064", + "contractAddress": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "transactionIndex": 1, + "gasUsed": "698163", + "logsBloom": "0x40000000000000000000000000000000400000000000000000800000000000000000000000000000000000000000000100800000000000000000000100008000000000000000000000000000000002000001000000000000000100000000000000000000020000000000000000000800000000800000000000000000000000400000000000000000000000000000020000000000000080008000000000800000000000000000000000000000000400000000000000800000000000000000000000000020000000000000000080040000000000000400000000000000000020000000000000000000000000020000000000000800000000000000000000000000", + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1", + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 11141009, + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x00000000000000000000000047c33167d13ed2374161a6f0a9b55fc4cad09897" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1" + }, + { + "transactionIndex": 1, + "blockNumber": 11141009, + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000004a32670436a8a662e75e64b91b3ab989b8a00064" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1" + }, + { + "transactionIndex": 1, + "blockNumber": 11141009, + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6", + "logIndex": 2, + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1" + }, + { + "transactionIndex": 1, + "blockNumber": 11141009, + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1" + }, + { + "transactionIndex": 1, + "blockNumber": 11141009, + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f77bd1d893f67b3eb2cd256239c98ba3f238fb52", + "logIndex": 4, + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1" + } + ], + "blockNumber": 11141009, + "cumulativeGasUsed": "745840", + "status": 1, + "byzantium": true + }, + "args": [ + "0x47C33167d13eD2374161A6f0A9b55fc4cad09897", + "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "0xc4d66de8000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"},\"solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n\\n function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405260405162000f5f38038062000f5f83398101604081905262000026916200044a565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6200052a565b60008051602062000f188339815191521462000075576200007562000550565b62000083828260006200013c565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046200052a565b60008051602062000ef883398151915214620000d357620000d362000550565b6001600160a01b038216608081905260008051602062000ef88339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050620005b9565b620001478362000179565b600082511180620001555750805b156200017457620001728383620001bb60201b620002a91760201c565b505b505050565b6200018481620001ea565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e3838360405180606001604052806027815260200162000f3860279139620002b2565b9392505050565b62000200816200039860201b620002d51760201c565b620002685760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806200029160008051602062000f1883398151915260001b620003a760201b620002411760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606001600160a01b0384163b6200031c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200025f565b600080856001600160a01b03168560405162000339919062000566565b600060405180830381855af49150503d806000811462000376576040519150601f19603f3d011682016040523d82523d6000602084013e6200037b565b606091505b5090925090506200038e828286620003aa565b9695505050505050565b6001600160a01b03163b151590565b90565b60608315620003bb575081620001e3565b825115620003cc5782518084602001fd5b8160405162461bcd60e51b81526004016200025f919062000584565b80516001600160a01b03811681146200040057600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004385781810151838201526020016200041e565b83811115620001725750506000910152565b6000806000606084860312156200046057600080fd5b6200046b84620003e8565b92506200047b60208501620003e8565b60408501519092506001600160401b03808211156200049957600080fd5b818601915086601f830112620004ae57600080fd5b815181811115620004c357620004c362000405565b604051601f8201601f19908116603f01168101908382118183101715620004ee57620004ee62000405565b816040528281528960208487010111156200050857600080fd5b6200051b8360208301602088016200041b565b80955050505050509250925092565b6000828210156200054b57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b600082516200057a8184602087016200041b565b9190910192915050565b6020815260008251806020840152620005a58160408501602087016200041b565b601f01601f19169190910160400192915050565b608051610900620005f86000396000818161011201528181610176015281816102060152818161025e01528181610287015261030901526109006000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033", + "execute": { + "methodName": "initialize", + "args": ["0xA60Deae5344F1152426cA440fb6552eA0e3005D6"] + }, + "implementation": "0x47C33167d13eD2374161A6f0A9b55fc4cad09897", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/opbnbmainnet/BoundValidator_Implementation.json b/deployments/opbnbmainnet/BoundValidator_Implementation.json new file mode 100644 index 00000000..b526149e --- /dev/null +++ b/deployments/opbnbmainnet/BoundValidator_Implementation.json @@ -0,0 +1,646 @@ +{ + "address": "0x47C33167d13eD2374161A6f0A9b55fc4cad09897", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "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": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "upperBound", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "lowerBound", + "type": "uint256" + } + ], + "name": "ValidateConfigAdded", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "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": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "internalType": "struct BoundValidator.ValidateConfig", + "name": "config", + "type": "tuple" + } + ], + "name": "setValidateConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "internalType": "struct BoundValidator.ValidateConfig[]", + "name": "configs", + "type": "tuple[]" + } + ], + "name": "setValidateConfigs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "validateConfigs", + "outputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "upperBoundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lowerBoundRatio", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "reportedPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "anchorPrice", + "type": "uint256" + } + ], + "name": "validatePriceWithAnchorPrice", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x7ad0aa16f3059297d00251070f8d456e5d14b160ac659ccc88f43020701fefa3", + "receipt": { + "to": null, + "from": "0x4a32670436a8A662E75E64B91B3Ab989B8a00064", + "contractAddress": "0x47C33167d13eD2374161A6f0A9b55fc4cad09897", + "transactionIndex": 1, + "gasUsed": "863113", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000100000000000000400000000000000000000400000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xa6aa6d48278e22364ef040130dbf7d0ab9e51d438fd0518be41e9b1249525c64", + "transactionHash": "0x7ad0aa16f3059297d00251070f8d456e5d14b160ac659ccc88f43020701fefa3", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 11141003, + "transactionHash": "0x7ad0aa16f3059297d00251070f8d456e5d14b160ac659ccc88f43020701fefa3", + "address": "0x47C33167d13eD2374161A6f0A9b55fc4cad09897", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", + "logIndex": 0, + "blockHash": "0xa6aa6d48278e22364ef040130dbf7d0ab9e51d438fd0518be41e9b1249525c64" + } + ], + "blockNumber": 11141003, + "cumulativeGasUsed": "910790", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "1e37f6e5d619feb70cefe47611ec524e", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"calledContract\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"methodSignature\",\"type\":\"string\"}],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAccessControlManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAccessControlManager\",\"type\":\"address\"}],\"name\":\"NewAccessControlManager\",\"type\":\"event\"},{\"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\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"upperBound\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"lowerBound\",\"type\":\"uint256\"}],\"name\":\"ValidateConfigAdded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accessControlManager\",\"outputs\":[{\"internalType\":\"contract IAccessControlManagerV8\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"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\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"setAccessControlManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"upperBoundRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"lowerBoundRatio\",\"type\":\"uint256\"}],\"internalType\":\"struct BoundValidator.ValidateConfig\",\"name\":\"config\",\"type\":\"tuple\"}],\"name\":\"setValidateConfig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"upperBoundRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"lowerBoundRatio\",\"type\":\"uint256\"}],\"internalType\":\"struct BoundValidator.ValidateConfig[]\",\"name\":\"configs\",\"type\":\"tuple[]\"}],\"name\":\"setValidateConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"validateConfigs\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"upperBoundRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"lowerBoundRatio\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"reportedPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"anchorPrice\",\"type\":\"uint256\"}],\"name\":\"validatePriceWithAnchorPrice\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"initialize(address)\":{\"params\":{\"accessControlManager_\":\"Address of the access control manager contract\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"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.\"},\"setAccessControlManager(address)\":{\"custom:access\":\"Only Governance\",\"custom:event\":\"Emits NewAccessControlManager event\",\"details\":\"Admin function to set address of AccessControlManager\",\"params\":{\"accessControlManager_\":\"The new address of the AccessControlManager\"}},\"setValidateConfig((address,uint256,uint256))\":{\"custom:access\":\"Only Governance\",\"custom:error\":\"Null address error is thrown if asset address is nullRange error thrown if bound ratio is not positiveRange error thrown if lower bound is greater than or equal to upper bound\",\"custom:event\":\"Emits ValidateConfigAdded when a validation config is successfully set\",\"params\":{\"config\":\"Validation config struct\"}},\"setValidateConfigs((address,uint256,uint256)[])\":{\"custom:access\":\"Only Governance\",\"custom:error\":\"Zero length error is thrown if length of the config array is 0\",\"custom:event\":\"Emits ValidateConfigAdded for each validation config that is successfully set\",\"params\":{\"configs\":\"Array of validation configs\"}},\"transferOwnership(address)\":{\"details\":\"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.\"},\"validatePriceWithAnchorPrice(address,uint256,uint256)\":{\"custom:error\":\"Missing error thrown if asset config is not setPrice error thrown if anchor price is not valid\",\"params\":{\"asset\":\"asset address\",\"reportedPrice\":\"The price to be tested\"}}},\"title\":\"BoundValidator\",\"version\":1},\"userdoc\":{\"errors\":{\"Unauthorized(address,address,string)\":[{\"notice\":\"Thrown when the action is prohibited by AccessControlManager\"}]},\"events\":{\"NewAccessControlManager(address,address)\":{\"notice\":\"Emitted when access control manager contract address is changed\"},\"ValidateConfigAdded(address,uint256,uint256)\":{\"notice\":\"Emit this event when new validation configs are added\"}},\"kind\":\"user\",\"methods\":{\"accessControlManager()\":{\"notice\":\"Returns the address of the access control manager contract\"},\"constructor\":{\"notice\":\"Constructor for the implementation contract. Sets immutable variables.\"},\"initialize(address)\":{\"notice\":\"Initializes the owner of the contract\"},\"setAccessControlManager(address)\":{\"notice\":\"Sets the address of AccessControlManager\"},\"setValidateConfig((address,uint256,uint256))\":{\"notice\":\"Add a single validation config\"},\"setValidateConfigs((address,uint256,uint256)[])\":{\"notice\":\"Add multiple validation configs at the same time\"},\"validateConfigs(address)\":{\"notice\":\"validation configs by asset\"},\"validatePriceWithAnchorPrice(address,uint256,uint256)\":{\"notice\":\"Test reported asset price against anchor price\"}},\"notice\":\"The BoundValidator contract is used to validate prices fetched from two different sources. Each asset has an upper and lower bound ratio set in the config. In order for a price to be valid it must fall within this range of the validator price.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/oracles/BoundValidator.sol\":\"BoundValidator\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./OwnableUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\\n function __Ownable2Step_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable2Step_init_unchained() internal onlyInitializing {\\n }\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() public virtual {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x84efb8889801b0ac817324aff6acc691d07bbee816b671817132911d287a8c63\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x4075622496acc77fd6d4de4cc30a8577a744d5c75afad33fdeacf1704d6eda98\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```solidity\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n *\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized != type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x89be10e757d242e9b18d5a32c9fbe2019f6d63052bbe46397a430a1d60d7f794\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n *\\n * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9c80f545915582e63fe206c6ce27cbe85a86fc10b9cd2a0e8c9488fb7c2ee422\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x287b55befed2961a7eabd7d7b1b2839cbca8a5b80ef8dcbb25ed3d4c2002c305\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\\\";\\n\\nimport \\\"./IAccessControlManagerV8.sol\\\";\\n\\n/**\\n * @title AccessControlledV8\\n * @author Venus\\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\\n */\\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\\n /// @notice Access control manager contract\\n IAccessControlManagerV8 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /// @notice Thrown when the action is prohibited by AccessControlManager\\n error Unauthorized(address sender, address calledContract, string methodSignature);\\n\\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\\n __Ownable2Step_init();\\n __AccessControlled_init_unchained(accessControlManager_);\\n }\\n\\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Sets the address of AccessControlManager\\n * @dev Admin function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n * @custom:event Emits NewAccessControlManager event\\n * @custom:access Only Governance\\n */\\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV8) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert Unauthorized(msg.sender, address(this), signature);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1b805a5d09990e2c4f7839afe7726a02f8452261eb3d0d488e24129ec0a7736d\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/access/IAccessControl.sol\\\";\\n\\n/**\\n * @title IAccessControlManagerV8\\n * @author Venus\\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\\n */\\ninterface IAccessControlManagerV8 is IAccessControl {\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x8adbe291d659987faf4de606736227ad9d8e1a0e284a33a6ca12b30ab2a504b2\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface OracleInterface {\\n function getPrice(address asset) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n\\n function updateAssetPrice(address asset) external;\\n\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address asset) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address asset,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x40031b19684ca0c912e794d08c2c0b0d8be77d3c1bdc937830a0658eff899650\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/VBep20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\ninterface VBep20Interface is IERC20Metadata {\\n /**\\n * @notice Underlying asset for this VToken\\n */\\n function underlying() external view returns (address);\\n}\\n\",\"keccak256\":\"0x3f845cd51b2d82f7932ac6c0ab714df97f733b01ce50f6fb0adb4c28447d4618\",\"license\":\"BSD-3-Clause\"},\"contracts/oracles/BoundValidator.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"../interfaces/VBep20Interface.sol\\\";\\nimport \\\"../interfaces/OracleInterface.sol\\\";\\nimport \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\\\";\\n\\n/**\\n * @title BoundValidator\\n * @author Venus\\n * @notice The BoundValidator contract is used to validate prices fetched from two different sources.\\n * Each asset has an upper and lower bound ratio set in the config. In order for a price to be valid\\n * it must fall within this range of the validator price.\\n */\\ncontract BoundValidator is AccessControlledV8, BoundValidatorInterface {\\n struct ValidateConfig {\\n /// @notice asset address\\n address asset;\\n /// @notice Upper bound of deviation between reported price and anchor price,\\n /// beyond which the reported price will be invalidated\\n uint256 upperBoundRatio;\\n /// @notice Lower bound of deviation between reported price and anchor price,\\n /// below which the reported price will be invalidated\\n uint256 lowerBoundRatio;\\n }\\n\\n /// @notice validation configs by asset\\n mapping(address => ValidateConfig) public validateConfigs;\\n\\n /// @notice Emit this event when new validation configs are added\\n event ValidateConfigAdded(address indexed asset, uint256 indexed upperBound, uint256 indexed lowerBound);\\n\\n /// @notice Constructor for the implementation contract. Sets immutable variables.\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /**\\n * @notice Initializes the owner of the contract\\n * @param accessControlManager_ Address of the access control manager contract\\n */\\n function initialize(address accessControlManager_) external initializer {\\n __AccessControlled_init(accessControlManager_);\\n }\\n\\n /**\\n * @notice Add multiple validation configs at the same time\\n * @param configs Array of validation configs\\n * @custom:access Only Governance\\n * @custom:error Zero length error is thrown if length of the config array is 0\\n * @custom:event Emits ValidateConfigAdded for each validation config that is successfully set\\n */\\n function setValidateConfigs(ValidateConfig[] memory configs) external {\\n uint256 length = configs.length;\\n if (length == 0) revert(\\\"invalid validate config length\\\");\\n for (uint256 i; i < length; ) {\\n setValidateConfig(configs[i]);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Add a single validation config\\n * @param config Validation config struct\\n * @custom:access Only Governance\\n * @custom:error Null address error is thrown if asset address is null\\n * @custom:error Range error thrown if bound ratio is not positive\\n * @custom:error Range error thrown if lower bound is greater than or equal to upper bound\\n * @custom:event Emits ValidateConfigAdded when a validation config is successfully set\\n */\\n function setValidateConfig(ValidateConfig memory config) public {\\n _checkAccessAllowed(\\\"setValidateConfig(ValidateConfig)\\\");\\n\\n if (config.asset == address(0)) revert(\\\"asset can't be zero address\\\");\\n if (config.upperBoundRatio == 0 || config.lowerBoundRatio == 0) revert(\\\"bound must be positive\\\");\\n if (config.upperBoundRatio <= config.lowerBoundRatio) revert(\\\"upper bound must be higher than lowner bound\\\");\\n validateConfigs[config.asset] = config;\\n emit ValidateConfigAdded(config.asset, config.upperBoundRatio, config.lowerBoundRatio);\\n }\\n\\n /**\\n * @notice Test reported asset price against anchor price\\n * @param asset asset address\\n * @param reportedPrice The price to be tested\\n * @custom:error Missing error thrown if asset config is not set\\n * @custom:error Price error thrown if anchor price is not valid\\n */\\n function validatePriceWithAnchorPrice(\\n address asset,\\n uint256 reportedPrice,\\n uint256 anchorPrice\\n ) public view virtual override returns (bool) {\\n if (validateConfigs[asset].upperBoundRatio == 0) revert(\\\"validation config not exist\\\");\\n if (anchorPrice == 0) revert(\\\"anchor price is not valid\\\");\\n return _isWithinAnchor(asset, reportedPrice, anchorPrice);\\n }\\n\\n /**\\n * @notice Test whether the reported price is within the valid bounds\\n * @param asset Asset address\\n * @param reportedPrice The price to be tested\\n * @param anchorPrice The reported price must be within the the valid bounds of this price\\n */\\n function _isWithinAnchor(address asset, uint256 reportedPrice, uint256 anchorPrice) private view returns (bool) {\\n if (reportedPrice != 0) {\\n // we need to multiply anchorPrice by 1e18 to make the ratio 18 decimals\\n uint256 anchorRatio = (anchorPrice * 1e18) / reportedPrice;\\n uint256 upperBoundAnchorRatio = validateConfigs[asset].upperBoundRatio;\\n uint256 lowerBoundAnchorRatio = validateConfigs[asset].lowerBoundRatio;\\n return anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio;\\n }\\n return false;\\n }\\n\\n // BoundValidator is to get inherited, so it's a good practice to add some storage gaps like\\n // OpenZepplin proposed in their contracts: https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // solhint-disable-next-line\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xf9f5d042a7d26924bbc753a9cfc281df3298c761c114813a80a82e6659083035\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061001961001e565b6100dd565b600054610100900460ff161561008a5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146100db576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b610e2c806100ec6000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c8063af9e6c5b11610071578063af9e6c5b1461013e578063b4a0bdf314610151578063bca9e11614610162578063c4d66de8146101c0578063e30c3978146101d3578063f2fde38b146101e457600080fd5b80630e32cb86146100b9578063715018a6146100ce57806379ba5097146100d65780638da5cb5b146100de57806397c7033e146101085780639c3576151461012b575b600080fd5b6100cc6100c7366004610a9b565b6101f7565b005b6100cc61020b565b6100cc61021f565b6033546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b61011b610116366004610ab6565b61029b565b60405190151581526020016100ff565b6100cc610139366004610b91565b61036a565b6100cc61014c366004610c41565b6103f7565b6097546001600160a01b03166100eb565b61019b610170366004610a9b565b60c9602052600090815260409020805460018201546002909201546001600160a01b03909116919083565b604080516001600160a01b0390941684526020840192909252908201526060016100ff565b6100cc6101ce366004610a9b565b6105ad565b6065546001600160a01b03166100eb565b6100cc6101f2366004610a9b565b6106c1565b6101ff610732565b6102088161078c565b50565b610213610732565b61021d600061084a565b565b60655433906001600160a01b031681146102925760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084015b60405180910390fd5b6102088161084a565b6001600160a01b038316600090815260c9602052604081206001015481036103055760405162461bcd60e51b815260206004820152601b60248201527f76616c69646174696f6e20636f6e666967206e6f7420657869737400000000006044820152606401610289565b816000036103555760405162461bcd60e51b815260206004820152601960248201527f616e63686f72207072696365206973206e6f742076616c6964000000000000006044820152606401610289565b610360848484610863565b90505b9392505050565b805160008190036103bd5760405162461bcd60e51b815260206004820152601e60248201527f696e76616c69642076616c696461746520636f6e666967206c656e67746800006044820152606401610289565b60005b818110156103f2576103ea8382815181106103dd576103dd610c5d565b60200260200101516103f7565b6001016103c0565b505050565b610418604051806060016040528060218152602001610dd6602191396108d5565b80516001600160a01b031661046f5760405162461bcd60e51b815260206004820152601b60248201527f61737365742063616e2774206265207a65726f206164647265737300000000006044820152606401610289565b6020810151158061048257506040810151155b156104c85760405162461bcd60e51b8152602060048201526016602482015275626f756e64206d75737420626520706f73697469766560501b6044820152606401610289565b80604001518160200151116105345760405162461bcd60e51b815260206004820152602c60248201527f757070657220626f756e64206d75737420626520686967686572207468616e2060448201526b1b1bdddb995c88189bdd5b9960a21b6064820152608401610289565b80516001600160a01b03908116600090815260c960209081526040808320855181546001600160a01b03191695169485178155918501516001830181905581860151600290930183905590519193909290917f28e2d96bdcf74fe6203e40d159d27ec2e15230239c0aee4a0a914196c550e6d19190a450565b600054610100900460ff16158080156105cd5750600054600160ff909116105b806105e75750303b1580156105e7575060005460ff166001145b61064a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610289565b6000805460ff19166001179055801561066d576000805461ff0019166101001790555b6106768261096f565b80156106bd576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b6106c9610732565b606580546001600160a01b0383166001600160a01b031990911681179091556106fa6033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6033546001600160a01b0316331461021d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610289565b6001600160a01b0381166107f05760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610289565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa091016106b4565b606580546001600160a01b0319169055610208816109a7565b600082156108cb5760008361088084670de0b6b3a7640000610c73565b61088a9190610ca0565b6001600160a01b038616600090815260c9602052604090206001810154600290910154919250908183118015906108c15750808310155b9350505050610363565b5060009392505050565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906109089033908690600401610d0f565b602060405180830381865afa158015610925573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109499190610d33565b9050806106bd57333083604051634a3fa29360e01b815260040161028993929190610d55565b600054610100900460ff166109965760405162461bcd60e51b815260040161028990610d8a565b61099e6109f9565b61020881610a28565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16610a205760405162461bcd60e51b815260040161028990610d8a565b61021d610a4f565b600054610100900460ff166101ff5760405162461bcd60e51b815260040161028990610d8a565b600054610100900460ff16610a765760405162461bcd60e51b815260040161028990610d8a565b61021d3361084a565b80356001600160a01b0381168114610a9657600080fd5b919050565b600060208284031215610aad57600080fd5b61036382610a7f565b600080600060608486031215610acb57600080fd5b610ad484610a7f565b95602085013595506040909401359392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610b2857610b28610ae9565b604052919050565b600060608284031215610b4257600080fd5b6040516060810181811067ffffffffffffffff82111715610b6557610b65610ae9565b604052905080610b7483610a7f565b815260208301356020820152604083013560408201525092915050565b60006020808385031215610ba457600080fd5b823567ffffffffffffffff80821115610bbc57600080fd5b818501915085601f830112610bd057600080fd5b813581811115610be257610be2610ae9565b610bf0848260051b01610aff565b81815284810192506060918202840185019188831115610c0f57600080fd5b938501935b82851015610c3557610c268986610b30565b84529384019392850192610c14565b50979650505050505050565b600060608284031215610c5357600080fd5b6103638383610b30565b634e487b7160e01b600052603260045260246000fd5b6000816000190483118215151615610c9b57634e487b7160e01b600052601160045260246000fd5b500290565b600082610cbd57634e487b7160e01b600052601260045260246000fd5b500490565b6000815180845260005b81811015610ce857602081850181015186830182015201610ccc565b81811115610cfa576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009061036090830184610cc2565b600060208284031215610d4557600080fd5b8151801515811461036357600080fd5b6001600160a01b03848116825283166020820152606060408201819052600090610d8190830184610cc2565b95945050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fe73657456616c6964617465436f6e6669672856616c6964617465436f6e66696729a2646970667358221220c4f8ddb5e43784db1ef793f73fe48aba4416063a3d2b8509e8b018efeb9f80bd64736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063af9e6c5b11610071578063af9e6c5b1461013e578063b4a0bdf314610151578063bca9e11614610162578063c4d66de8146101c0578063e30c3978146101d3578063f2fde38b146101e457600080fd5b80630e32cb86146100b9578063715018a6146100ce57806379ba5097146100d65780638da5cb5b146100de57806397c7033e146101085780639c3576151461012b575b600080fd5b6100cc6100c7366004610a9b565b6101f7565b005b6100cc61020b565b6100cc61021f565b6033546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b61011b610116366004610ab6565b61029b565b60405190151581526020016100ff565b6100cc610139366004610b91565b61036a565b6100cc61014c366004610c41565b6103f7565b6097546001600160a01b03166100eb565b61019b610170366004610a9b565b60c9602052600090815260409020805460018201546002909201546001600160a01b03909116919083565b604080516001600160a01b0390941684526020840192909252908201526060016100ff565b6100cc6101ce366004610a9b565b6105ad565b6065546001600160a01b03166100eb565b6100cc6101f2366004610a9b565b6106c1565b6101ff610732565b6102088161078c565b50565b610213610732565b61021d600061084a565b565b60655433906001600160a01b031681146102925760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084015b60405180910390fd5b6102088161084a565b6001600160a01b038316600090815260c9602052604081206001015481036103055760405162461bcd60e51b815260206004820152601b60248201527f76616c69646174696f6e20636f6e666967206e6f7420657869737400000000006044820152606401610289565b816000036103555760405162461bcd60e51b815260206004820152601960248201527f616e63686f72207072696365206973206e6f742076616c6964000000000000006044820152606401610289565b610360848484610863565b90505b9392505050565b805160008190036103bd5760405162461bcd60e51b815260206004820152601e60248201527f696e76616c69642076616c696461746520636f6e666967206c656e67746800006044820152606401610289565b60005b818110156103f2576103ea8382815181106103dd576103dd610c5d565b60200260200101516103f7565b6001016103c0565b505050565b610418604051806060016040528060218152602001610dd6602191396108d5565b80516001600160a01b031661046f5760405162461bcd60e51b815260206004820152601b60248201527f61737365742063616e2774206265207a65726f206164647265737300000000006044820152606401610289565b6020810151158061048257506040810151155b156104c85760405162461bcd60e51b8152602060048201526016602482015275626f756e64206d75737420626520706f73697469766560501b6044820152606401610289565b80604001518160200151116105345760405162461bcd60e51b815260206004820152602c60248201527f757070657220626f756e64206d75737420626520686967686572207468616e2060448201526b1b1bdddb995c88189bdd5b9960a21b6064820152608401610289565b80516001600160a01b03908116600090815260c960209081526040808320855181546001600160a01b03191695169485178155918501516001830181905581860151600290930183905590519193909290917f28e2d96bdcf74fe6203e40d159d27ec2e15230239c0aee4a0a914196c550e6d19190a450565b600054610100900460ff16158080156105cd5750600054600160ff909116105b806105e75750303b1580156105e7575060005460ff166001145b61064a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610289565b6000805460ff19166001179055801561066d576000805461ff0019166101001790555b6106768261096f565b80156106bd576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b6106c9610732565b606580546001600160a01b0383166001600160a01b031990911681179091556106fa6033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6033546001600160a01b0316331461021d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610289565b6001600160a01b0381166107f05760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610289565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa091016106b4565b606580546001600160a01b0319169055610208816109a7565b600082156108cb5760008361088084670de0b6b3a7640000610c73565b61088a9190610ca0565b6001600160a01b038616600090815260c9602052604090206001810154600290910154919250908183118015906108c15750808310155b9350505050610363565b5060009392505050565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906109089033908690600401610d0f565b602060405180830381865afa158015610925573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109499190610d33565b9050806106bd57333083604051634a3fa29360e01b815260040161028993929190610d55565b600054610100900460ff166109965760405162461bcd60e51b815260040161028990610d8a565b61099e6109f9565b61020881610a28565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16610a205760405162461bcd60e51b815260040161028990610d8a565b61021d610a4f565b600054610100900460ff166101ff5760405162461bcd60e51b815260040161028990610d8a565b600054610100900460ff16610a765760405162461bcd60e51b815260040161028990610d8a565b61021d3361084a565b80356001600160a01b0381168114610a9657600080fd5b919050565b600060208284031215610aad57600080fd5b61036382610a7f565b600080600060608486031215610acb57600080fd5b610ad484610a7f565b95602085013595506040909401359392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610b2857610b28610ae9565b604052919050565b600060608284031215610b4257600080fd5b6040516060810181811067ffffffffffffffff82111715610b6557610b65610ae9565b604052905080610b7483610a7f565b815260208301356020820152604083013560408201525092915050565b60006020808385031215610ba457600080fd5b823567ffffffffffffffff80821115610bbc57600080fd5b818501915085601f830112610bd057600080fd5b813581811115610be257610be2610ae9565b610bf0848260051b01610aff565b81815284810192506060918202840185019188831115610c0f57600080fd5b938501935b82851015610c3557610c268986610b30565b84529384019392850192610c14565b50979650505050505050565b600060608284031215610c5357600080fd5b6103638383610b30565b634e487b7160e01b600052603260045260246000fd5b6000816000190483118215151615610c9b57634e487b7160e01b600052601160045260246000fd5b500290565b600082610cbd57634e487b7160e01b600052601260045260246000fd5b500490565b6000815180845260005b81811015610ce857602081850181015186830182015201610ccc565b81811115610cfa576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009061036090830184610cc2565b600060208284031215610d4557600080fd5b8151801515811461036357600080fd5b6001600160a01b03848116825283166020820152606060408201819052600090610d8190830184610cc2565b95945050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fe73657456616c6964617465436f6e6669672856616c6964617465436f6e66696729a2646970667358221220c4f8ddb5e43784db1ef793f73fe48aba4416063a3d2b8509e8b018efeb9f80bd64736f6c634300080d0033", + "devdoc": { + "author": "Venus", + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "constructor": { + "custom:oz-upgrades-unsafe-allow": "constructor" + }, + "initialize(address)": { + "params": { + "accessControlManager_": "Address of the access control manager contract" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "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." + }, + "setAccessControlManager(address)": { + "custom:access": "Only Governance", + "custom:event": "Emits NewAccessControlManager event", + "details": "Admin function to set address of AccessControlManager", + "params": { + "accessControlManager_": "The new address of the AccessControlManager" + } + }, + "setValidateConfig((address,uint256,uint256))": { + "custom:access": "Only Governance", + "custom:error": "Null address error is thrown if asset address is nullRange error thrown if bound ratio is not positiveRange error thrown if lower bound is greater than or equal to upper bound", + "custom:event": "Emits ValidateConfigAdded when a validation config is successfully set", + "params": { + "config": "Validation config struct" + } + }, + "setValidateConfigs((address,uint256,uint256)[])": { + "custom:access": "Only Governance", + "custom:error": "Zero length error is thrown if length of the config array is 0", + "custom:event": "Emits ValidateConfigAdded for each validation config that is successfully set", + "params": { + "configs": "Array of validation configs" + } + }, + "transferOwnership(address)": { + "details": "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." + }, + "validatePriceWithAnchorPrice(address,uint256,uint256)": { + "custom:error": "Missing error thrown if asset config is not setPrice error thrown if anchor price is not valid", + "params": { + "asset": "asset address", + "reportedPrice": "The price to be tested" + } + } + }, + "title": "BoundValidator", + "version": 1 + }, + "userdoc": { + "errors": { + "Unauthorized(address,address,string)": [ + { + "notice": "Thrown when the action is prohibited by AccessControlManager" + } + ] + }, + "events": { + "NewAccessControlManager(address,address)": { + "notice": "Emitted when access control manager contract address is changed" + }, + "ValidateConfigAdded(address,uint256,uint256)": { + "notice": "Emit this event when new validation configs are added" + } + }, + "kind": "user", + "methods": { + "accessControlManager()": { + "notice": "Returns the address of the access control manager contract" + }, + "constructor": { + "notice": "Constructor for the implementation contract. Sets immutable variables." + }, + "initialize(address)": { + "notice": "Initializes the owner of the contract" + }, + "setAccessControlManager(address)": { + "notice": "Sets the address of AccessControlManager" + }, + "setValidateConfig((address,uint256,uint256))": { + "notice": "Add a single validation config" + }, + "setValidateConfigs((address,uint256,uint256)[])": { + "notice": "Add multiple validation configs at the same time" + }, + "validateConfigs(address)": { + "notice": "validation configs by asset" + }, + "validatePriceWithAnchorPrice(address,uint256,uint256)": { + "notice": "Test reported asset price against anchor price" + } + }, + "notice": "The BoundValidator contract is used to validate prices fetched from two different sources. Each asset has an upper and lower bound ratio set in the config. In order for a price to be valid it must fall within this range of the validator price.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 347, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 350, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1007, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 219, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 339, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 128, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "_pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 207, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 5079, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "_accessControlManager", + "offset": 0, + "slot": "151", + "type": "t_contract(IAccessControlManagerV8)5264" + }, + { + "astId": 5084, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 7334, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "validateConfigs", + "offset": 0, + "slot": "201", + "type": "t_mapping(t_address,t_struct(ValidateConfig)7328_storage)" + }, + { + "astId": 7562, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "__gap", + "offset": 0, + "slot": "202", + "type": "t_array(t_uint256)49_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IAccessControlManagerV8)5264": { + "encoding": "inplace", + "label": "contract IAccessControlManagerV8", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_struct(ValidateConfig)7328_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct BoundValidator.ValidateConfig)", + "numberOfBytes": "32", + "value": "t_struct(ValidateConfig)7328_storage" + }, + "t_struct(ValidateConfig)7328_storage": { + "encoding": "inplace", + "label": "struct BoundValidator.ValidateConfig", + "members": [ + { + "astId": 7321, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "asset", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 7324, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "upperBoundRatio", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 7327, + "contract": "contracts/oracles/BoundValidator.sol:BoundValidator", + "label": "lowerBoundRatio", + "offset": 0, + "slot": "2", + "type": "t_uint256" + } + ], + "numberOfBytes": "96" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/bsctestnet/TwapOracle_Proxy.json b/deployments/opbnbmainnet/BoundValidator_Proxy.json similarity index 94% rename from deployments/bsctestnet/TwapOracle_Proxy.json rename to deployments/opbnbmainnet/BoundValidator_Proxy.json index 273d343f..52a20f7e 100644 --- a/deployments/bsctestnet/TwapOracle_Proxy.json +++ b/deployments/opbnbmainnet/BoundValidator_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", "abi": [ { "inputs": [ @@ -133,84 +133,84 @@ "type": "receive" } ], - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", "receipt": { "to": null, - "from": "0x8BDA9f9E1fEF0DFd404Fef338D9fE4c543d172e1", - "contractAddress": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", - "transactionIndex": 0, - "gasUsed": "696602", - "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000000000000000000000000000004000000000000000000000000000000000000008000000000000000000000000000000002000001040000000080000000000000000000000000020000000000000200000800000000800000000000000000000000400000000000000000000000000000000080000000000080000000000000804000000000000000000010000000000400000000000000800000000000000000200000000020000000000200000000040000000000000400000000000000000020000000000000000000000000000000000000000800000000000000000000000000", - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae", - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", + "from": "0x4a32670436a8A662E75E64B91B3Ab989B8a00064", + "contractAddress": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "transactionIndex": 1, + "gasUsed": "698163", + "logsBloom": "0x40000000000000000000000000000000400000000000000000800000000000000000000000000000000000000000000100800000000000000000000100008000000000000000000000000000000002000001000000000000000100000000000000000000020000000000000000000800000000800000000000000000000000400000000000000000000000000000020000000000000080008000000000800000000000000000000000000000000400000000000000800000000000000000000000000020000000000000000080040000000000000400000000000000000020000000000000000000000000020000000000000800000000000000000000000000", + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1", + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", "logs": [ { - "transactionIndex": 0, - "blockNumber": 30137623, - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "transactionIndex": 1, + "blockNumber": 11141009, + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000a65d9c3593b8ca0ef4c475e16eb93f92ca81f98b" + "0x00000000000000000000000047c33167d13ed2374161a6f0a9b55fc4cad09897" ], "data": "0x", "logIndex": 0, - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae" + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1" }, { - "transactionIndex": 0, - "blockNumber": 30137623, - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "transactionIndex": 1, + "blockNumber": 11141009, + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000008bda9f9e1fef0dfd404fef338d9fe4c543d172e1" + "0x0000000000000000000000004a32670436a8a662e75e64b91b3ab989b8a00064" ], "data": "0x", "logIndex": 1, - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae" + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1" }, { - "transactionIndex": 0, - "blockNumber": 30137623, - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "transactionIndex": 1, + "blockNumber": 11141009, + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], - "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045f8a08f534f34a97187626e05d4b6648eeaa9aa", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6", "logIndex": 2, - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae" + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1" }, { - "transactionIndex": 0, - "blockNumber": 30137623, - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "transactionIndex": 1, + "blockNumber": 11141009, + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 3, - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae" + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1" }, { - "transactionIndex": 0, - "blockNumber": 30137623, - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "transactionIndex": 1, + "blockNumber": 11141009, + "transactionHash": "0xb2aea7897a8e4f60c3e32eeb7207b5cff1ccdcee1fdc600d2ee2f3bc2aa88c9f", + "address": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ef480a5654b231ff7d80a0681f938f3db71a6ca6", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f77bd1d893f67b3eb2cd256239c98ba3f238fb52", "logIndex": 4, - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae" + "blockHash": "0x6c6adcfb6f7e7f1ca1579d841aa4866c713d34a70be4a4128a4b3155b3afcdd1" } ], - "blockNumber": 30137623, - "cumulativeGasUsed": "696602", + "blockNumber": 11141009, + "cumulativeGasUsed": "745840", "status": 1, "byzantium": true }, "args": [ - "0xA65d9c3593B8ca0EF4C475E16Eb93f92Ca81F98B", - "0xef480a5654b231ff7d80A0681F938f3Db71a6Ca6", - "0xc4d66de800000000000000000000000045f8a08f534f34a97187626e05d4b6648eeaa9aa" + "0x47C33167d13eD2374161A6f0A9b55fc4cad09897", + "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "0xc4d66de8000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6" ], "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", diff --git a/deployments/opbnbmainnet/DefaultProxyAdmin.json b/deployments/opbnbmainnet/DefaultProxyAdmin.json new file mode 100644 index 00000000..57a59887 --- /dev/null +++ b/deployments/opbnbmainnet/DefaultProxyAdmin.json @@ -0,0 +1,257 @@ +{ + "address": "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "initialOwner", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeProxyAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + } + ], + "name": "getProxyAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + } + ], + "name": "getProxyImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "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": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } + ], + "transactionHash": "0x6f5ff5936ce3f5d1814c53cb3358b4e3067d65a516d478dd1237c938bb8655b8", + "receipt": { + "to": null, + "from": "0x4a32670436a8A662E75E64B91B3Ab989B8a00064", + "contractAddress": "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "transactionIndex": 1, + "gasUsed": "643983", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000002000000000000000000000000000000000000000000000000000000000000000000000080000000000000002000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000020000000000", + "blockHash": "0xba81734f171082bd28bbc9a0d472a2b8e8e543d688bac1c61e5094ec8ca9f461", + "transactionHash": "0x6f5ff5936ce3f5d1814c53cb3358b4e3067d65a516d478dd1237c938bb8655b8", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 11140997, + "transactionHash": "0x6f5ff5936ce3f5d1814c53cb3358b4e3067d65a516d478dd1237c938bb8655b8", + "address": "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000c46796a21a3a9fab6546af3434f2ebffd0604207" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xba81734f171082bd28bbc9a0d472a2b8e8e543d688bac1c61e5094ec8ca9f461" + } + ], + "blockNumber": 11140997, + "cumulativeGasUsed": "690872", + "status": 1, + "byzantium": true + }, + "args": ["0xC46796a21a3A9FAB6546aF3434F2eBfFd0604207"], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"initialOwner\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeProxyAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"}],\"name\":\"getProxyAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"}],\"name\":\"getProxyImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"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\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\",\"kind\":\"dev\",\"methods\":{\"changeProxyAdmin(address,address)\":{\"details\":\"Changes the admin of `proxy` to `newAdmin`. Requirements: - This contract must be the current admin of `proxy`.\"},\"getProxyAdmin(address)\":{\"details\":\"Returns the current admin of `proxy`. Requirements: - This contract must be the admin of `proxy`.\"},\"getProxyImplementation(address)\":{\"details\":\"Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgrade(address,address)\":{\"details\":\"Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. Requirements: - This contract must be the admin of `proxy`.\"},\"upgradeAndCall(address,address,bytes)\":{\"details\":\"Upgrades `proxy` to `implementation` and calls a function on the new implementation. See {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol\":\"ProxyAdmin\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor (address initialOwner) {\\n _transferOwnership(initialOwner);\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x9b2bbba5bb04f53f277739c1cdff896ba8b3bf591cfc4eab2098c655e8ac251e\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./TransparentUpgradeableProxy.sol\\\";\\nimport \\\"../../access/Ownable.sol\\\";\\n\\n/**\\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\\n */\\ncontract ProxyAdmin is Ownable {\\n\\n constructor (address initialOwner) Ownable(initialOwner) {}\\n\\n /**\\n * @dev Returns the current implementation of `proxy`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\\n // We need to manually run the static call since the getter cannot be flagged as view\\n // bytes4(keccak256(\\\"implementation()\\\")) == 0x5c60da1b\\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\\\"5c60da1b\\\");\\n require(success);\\n return abi.decode(returndata, (address));\\n }\\n\\n /**\\n * @dev Returns the current admin of `proxy`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\\n // We need to manually run the static call since the getter cannot be flagged as view\\n // bytes4(keccak256(\\\"admin()\\\")) == 0xf851a440\\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\\\"f851a440\\\");\\n require(success);\\n return abi.decode(returndata, (address));\\n }\\n\\n /**\\n * @dev Changes the admin of `proxy` to `newAdmin`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the current admin of `proxy`.\\n */\\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\\n proxy.changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\\n proxy.upgradeTo(implementation);\\n }\\n\\n /**\\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function upgradeAndCall(\\n TransparentUpgradeableProxy proxy,\\n address implementation,\\n bytes memory data\\n ) public payable virtual onlyOwner {\\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\\n }\\n}\\n\",\"keccak256\":\"0x754888b9c9ab5525343460b0a4fa2e2f4fca9b6a7e0e7ddea4154e2b1182a45d\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50604051610b17380380610b1783398101604081905261002f91610090565b8061003981610040565b50506100c0565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100a257600080fd5b81516001600160a01b03811681146100b957600080fd5b9392505050565b610a48806100cf6000396000f3fe60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b3660046107e4565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb366004610808565b6102e7565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610870565b6103ee565b34801561014a57600080fd5b506100de610159366004610808565b6104fc565b34801561016a57600080fd5b506100de6101793660046107e4565b6105d1565b34801561018a57600080fd5b506100a06101993660046107e4565b610701565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610964565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102e5600061074d565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef2869034906104c59086908690600401610981565b6000604051808303818588803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461057d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016103b8565b60005473ffffffffffffffffffffffffffffffffffffffff163314610652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b73ffffffffffffffffffffffffffffffffffffffff81166106f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102d2565b6106fe8161074d565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146106fe57600080fd5b6000602082840312156107f657600080fd5b8135610801816107c2565b9392505050565b6000806040838503121561081b57600080fd5b8235610826816107c2565b91506020830135610836816107c2565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561088557600080fd5b8335610890816107c2565b925060208401356108a0816107c2565b9150604084013567ffffffffffffffff808211156108bd57600080fd5b818601915086601f8301126108d157600080fd5b8135818111156108e3576108e3610841565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561092957610929610841565b8160405282815289602084870101111561094257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561097657600080fd5b8151610801816107c2565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156109cb578581018301518582016060015282016109af565b818111156109dd576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160600194935050505056fea2646970667358221220bd6c09ab03bfaf9ec60a4bf8cd98903cecb891974e17e2d76a3b2002c97eeb8964736f6c634300080a0033", + "deployedBytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b3660046107e4565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb366004610808565b6102e7565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610870565b6103ee565b34801561014a57600080fd5b506100de610159366004610808565b6104fc565b34801561016a57600080fd5b506100de6101793660046107e4565b6105d1565b34801561018a57600080fd5b506100a06101993660046107e4565b610701565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610964565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102e5600061074d565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef2869034906104c59086908690600401610981565b6000604051808303818588803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461057d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016103b8565b60005473ffffffffffffffffffffffffffffffffffffffff163314610652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b73ffffffffffffffffffffffffffffffffffffffff81166106f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102d2565b6106fe8161074d565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146106fe57600080fd5b6000602082840312156107f657600080fd5b8135610801816107c2565b9392505050565b6000806040838503121561081b57600080fd5b8235610826816107c2565b91506020830135610836816107c2565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561088557600080fd5b8335610890816107c2565b925060208401356108a0816107c2565b9150604084013567ffffffffffffffff808211156108bd57600080fd5b818601915086601f8301126108d157600080fd5b8135818111156108e3576108e3610841565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561092957610929610841565b8160405282815289602084870101111561094257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561097657600080fd5b8151610801816107c2565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156109cb578581018301518582016060015282016109af565b818111156109dd576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160600194935050505056fea2646970667358221220bd6c09ab03bfaf9ec60a4bf8cd98903cecb891974e17e2d76a3b2002c97eeb8964736f6c634300080a0033", + "devdoc": { + "details": "This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.", + "kind": "dev", + "methods": { + "changeProxyAdmin(address,address)": { + "details": "Changes the admin of `proxy` to `newAdmin`. Requirements: - This contract must be the current admin of `proxy`." + }, + "getProxyAdmin(address)": { + "details": "Returns the current admin of `proxy`. Requirements: - This contract must be the admin of `proxy`." + }, + "getProxyImplementation(address)": { + "details": "Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "upgrade(address,address)": { + "details": "Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. Requirements: - This contract must be the admin of `proxy`." + }, + "upgradeAndCall(address,address,bytes)": { + "details": "Upgrades `proxy` to `implementation` and calls a function on the new implementation. See {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 7, + "contract": "solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + } + } + } +} diff --git a/deployments/bsctestnet/TwapOracle.json b/deployments/opbnbmainnet/ResilientOracle.json similarity index 89% rename from deployments/bsctestnet/TwapOracle.json rename to deployments/opbnbmainnet/ResilientOracle.json index ff1dd619..48e460cc 100644 --- a/deployments/bsctestnet/TwapOracle.json +++ b/deployments/opbnbmainnet/ResilientOracle.json @@ -1,5 +1,5 @@ { - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "abi": [ { "anonymous": false, @@ -135,64 +135,83 @@ { "anonymous": false, "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, { "indexed": false, - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ { "indexed": false, - "internalType": "uint256", - "name": "oldTimestamp", - "type": "uint256" + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" }, { "indexed": false, - "internalType": "uint256", - "name": "newTimestamp", - "type": "uint256" + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" } ], - "name": "AnchorPriceUpdated", + "name": "NewAccessControlManager", "type": "event" }, { "anonymous": false, "inputs": [ { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "role", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bool", + "name": "enable", + "type": "bool" } ], - "name": "Initialized", + "name": "OracleEnabled", "type": "event" }, { "anonymous": false, "inputs": [ { - "indexed": false, + "indexed": true, "internalType": "address", - "name": "oldAccessControlManager", + "name": "asset", "type": "address" }, { - "indexed": false, + "indexed": true, "internalType": "address", - "name": "newAccessControlManager", + "name": "oracle", "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "role", + "type": "uint256" } ], - "name": "NewAccessControlManager", + "name": "OracleSet", "type": "event" }, { @@ -237,25 +256,13 @@ "anonymous": false, "inputs": [ { - "indexed": true, - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "indexed": true, + "indexed": false, "internalType": "address", - "name": "pancakePool", + "name": "account", "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" } ], - "name": "TokenConfigAdded", + "name": "Paused", "type": "event" }, { @@ -268,36 +275,43 @@ "type": "address" }, { - "indexed": false, - "internalType": "uint256", - "name": "oldTimestamp", - "type": "uint256" + "indexed": true, + "internalType": "address", + "name": "mainOracle", + "type": "address" }, { - "indexed": false, - "internalType": "uint256", - "name": "oldAcc", - "type": "uint256" + "indexed": true, + "internalType": "address", + "name": "pivotOracle", + "type": "address" }, { "indexed": false, - "internalType": "uint256", - "name": "newTimestamp", - "type": "uint256" - }, + "internalType": "address", + "name": "fallbackOracle", + "type": "address" + } + ], + "name": "TokenConfigAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ { "indexed": false, - "internalType": "uint256", - "name": "newAcc", - "type": "uint256" + "internalType": "address", + "name": "account", + "type": "address" } ], - "name": "TwapWindowUpdated", + "name": "Unpaused", "type": "event" }, { "inputs": [], - "name": "BNB_BASE_UNIT", + "name": "INVALID_PRICE", "outputs": [ { "internalType": "uint256", @@ -310,12 +324,12 @@ }, { "inputs": [], - "name": "BUSD_BASE_UNIT", + "name": "NATIVE_TOKEN_ADDR", "outputs": [ { - "internalType": "uint256", + "internalType": "address", "name": "", - "type": "uint256" + "type": "address" } ], "stateMutability": "view", @@ -323,10 +337,17 @@ }, { "inputs": [], - "name": "WBNB", + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", "outputs": [ { - "internalType": "address", + "internalType": "contract IAccessControlManagerV8", "name": "", "type": "address" } @@ -336,26 +357,98 @@ }, { "inputs": [], - "name": "acceptOwnership", + "name": "boundValidator", + "outputs": [ + { + "internalType": "contract BoundValidatorInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "enable", + "type": "bool" + } + ], + "name": "enableOracle", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [], - "name": "accessControlManager", + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + } + ], + "name": "getOracle", "outputs": [ { - "internalType": "contract IAccessControlManagerV8", - "name": "", + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", "type": "address" } ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getTokenConfig", + "outputs": [ { "components": [ { @@ -364,42 +457,19 @@ "type": "address" }, { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" }, { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" } ], - "internalType": "struct TwapOracle.TokenConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "currentCumulativePrice", - "outputs": [ - { - "internalType": "uint256", + "internalType": "struct ResilientOracle.TokenConfig", "name": "", - "type": "uint256" + "type": "tuple" } ], "stateMutability": "view", @@ -438,29 +508,13 @@ "type": "function" }, { - "inputs": [ + "inputs": [], + "name": "nativeMarket", + "outputs": [ { "internalType": "address", "name": "", "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "observations", - "outputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "acc", - "type": "uint256" } ], "stateMutability": "view", @@ -481,33 +535,34 @@ }, { "inputs": [], - "name": "pendingOwner", + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", "outputs": [ { - "internalType": "address", + "internalType": "bool", "name": "", - "type": "address" + "type": "bool" } ], "stateMutability": "view", "type": "function" }, { - "inputs": [ + "inputs": [], + "name": "pendingOwner", + "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], - "name": "prices", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], "stateMutability": "view", "type": "function" }, @@ -531,6 +586,29 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -541,33 +619,18 @@ "type": "address" }, { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" }, { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" } ], - "internalType": "struct TwapOracle.TokenConfig", - "name": "config", + "internalType": "struct ResilientOracle.TokenConfig", + "name": "tokenConfig", "type": "tuple" } ], @@ -586,33 +649,18 @@ "type": "address" }, { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", - "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" }, { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" } ], - "internalType": "struct TwapOracle.TokenConfig[]", - "name": "configs", + "internalType": "struct ResilientOracle.TokenConfig[]", + "name": "tokenConfigs_", "type": "tuple[]" } ], @@ -625,55 +673,18 @@ "inputs": [ { "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "tokenConfigs", - "outputs": [ - { - "internalType": "address", - "name": "asset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "baseUnit", - "type": "uint256" - }, - { - "internalType": "address", - "name": "pancakePool", + "name": "newOwner", "type": "address" - }, - { - "internalType": "bool", - "name": "isBnbBased", - "type": "bool" - }, - { - "internalType": "bool", - "name": "isReversedPool", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "anchorPeriod", - "type": "uint256" } ], - "stateMutability": "view", + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", + "inputs": [], + "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -682,32 +693,26 @@ "inputs": [ { "internalType": "address", - "name": "vToken", + "name": "asset", "type": "address" } ], - "name": "updateTwap", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], + "name": "updateAssetPrice", + "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [], - "name": "vBnb", - "outputs": [ + "inputs": [ { "internalType": "address", - "name": "", + "name": "vToken", "type": "address" } ], - "stateMutability": "view", + "name": "updatePrice", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { @@ -723,25 +728,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "windowStart", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -764,84 +750,84 @@ "type": "constructor" } ], - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", "receipt": { "to": null, - "from": "0x8BDA9f9E1fEF0DFd404Fef338D9fE4c543d172e1", - "contractAddress": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", - "transactionIndex": 0, - "gasUsed": "696602", - "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000000000000000000000000000004000000000000000000000000000000000000008000000000000000000000000000000002000001040000000080000000000000000000000000020000000000000200000800000000800000000000000000000000400000000000000000000000000000000080000000000080000000000000804000000000000000000010000000000400000000000000800000000000000000200000000020000000000200000000040000000000000400000000000000000020000000000000000000000000000000000000000800000000000000000000000000", - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae", - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", + "from": "0x4a32670436a8A662E75E64B91B3Ab989B8a00064", + "contractAddress": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", + "transactionIndex": 1, + "gasUsed": "700702", + "logsBloom": "0x000000000000000000000000000000004000000000000000008000000000000000000000000000008000000000000001000000000000000000000001000080000020000000000000000000000000020000010000000000040000000000000000400000000200000000000000000008000000008000000000000000000000004000000000000000000000000000000200000000000000a0000000000000800000000000000000000000000000000400000000000000800000000000000000000000000020000000000000000000040000000000000400000100000000000020000000000000000000000000000000000000000800000000000000000000000000", + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8", + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", "logs": [ { - "transactionIndex": 0, - "blockNumber": 30137623, - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "transactionIndex": 1, + "blockNumber": 11141022, + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000a65d9c3593b8ca0ef4c475e16eb93f92ca81f98b" + "0x000000000000000000000000bc3ee948ba5d78880c6ecb005274257e60d017c8" ], "data": "0x", "logIndex": 0, - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae" + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8" }, { - "transactionIndex": 0, - "blockNumber": 30137623, - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "transactionIndex": 1, + "blockNumber": 11141022, + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000008bda9f9e1fef0dfd404fef338d9fe4c543d172e1" + "0x0000000000000000000000004a32670436a8a662e75e64b91b3ab989b8a00064" ], "data": "0x", "logIndex": 1, - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae" + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8" }, { - "transactionIndex": 0, - "blockNumber": 30137623, - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "transactionIndex": 1, + "blockNumber": 11141022, + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], - "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045f8a08f534f34a97187626e05d4b6648eeaa9aa", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6", "logIndex": 2, - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae" + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8" }, { - "transactionIndex": 0, - "blockNumber": 30137623, - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "transactionIndex": 1, + "blockNumber": 11141022, + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 3, - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae" + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8" }, { - "transactionIndex": 0, - "blockNumber": 30137623, - "transactionHash": "0x3efb22545b047f193a166c3fe9575bb2ec0142f23bdbb87a63eb9a4805ecbc18", - "address": "0x3eeE05d929D1E9816185B1b6d8c470eC192b4432", + "transactionIndex": 1, + "blockNumber": 11141022, + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ef480a5654b231ff7d80a0681f938f3db71a6ca6", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f77bd1d893f67b3eb2cd256239c98ba3f238fb52", "logIndex": 4, - "blockHash": "0x6e074a9560e1a6b6abc2011ef72c0a87dbfada6a95c5f34624def3b2c13585ae" + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8" } ], - "blockNumber": 30137623, - "cumulativeGasUsed": "696602", + "blockNumber": 11141022, + "cumulativeGasUsed": "764691", "status": 1, "byzantium": true }, "args": [ - "0xA65d9c3593B8ca0EF4C475E16Eb93f92Ca81F98B", - "0xef480a5654b231ff7d80A0681F938f3Db71a6Ca6", - "0xc4d66de800000000000000000000000045f8a08f534f34a97187626e05d4b6648eeaa9aa" + "0xbC3ee948Ba5D78880c6ECb005274257e60d017c8", + "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "0xc4d66de8000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6" ], "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", @@ -850,9 +836,9 @@ "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b5061005061007536600461076c565b6100fa565b610050610088366004610787565b61015e565b34801561009957600080fd5b506100a26101ec565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d757600080fd5b506100a2610244565b6100e86102f1565b6100f86100f36103e2565b610422565b565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101565761015381604051806020016040528060008152506000610446565b50565b6101536100e0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156101e4576101df8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610446915050565b505050565b6101df6100e0565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161415610239576102346103e2565b905090565b6102416100e0565b90565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016141561023957507f000000000000000000000000000000000000000000000000000000000000000090565b60606102ce83836040518060600160405280602781526020016108a460279139610471565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156100f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b3660008037600080366000845af43d6000803e808015610441573d6000f35b3d6000fd5b61044f83610599565b60008251118061045c5750805b156101df5761046b83836102a9565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103d9565b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161053f9190610836565b600060405180830381855af49150503d806000811461057a576040519150601f19603f3d011682016040523d82523d6000602084013e61057f565b606091505b509150915061058f8282866105e6565b9695505050505050565b6105a281610639565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156105f55750816102ce565b8251156106055782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d99190610852565b73ffffffffffffffffffffffffffffffffffffffff81163b6106dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103d9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b803573ffffffffffffffffffffffffffffffffffffffff8116811461076757600080fd5b919050565b60006020828403121561077e57600080fd5b6102ce82610743565b60008060006040848603121561079c57600080fd5b6107a584610743565b9250602084013567ffffffffffffffff808211156107c257600080fd5b818601915086601f8301126107d657600080fd5b8135818111156107e557600080fd5b8760208285010111156107f757600080fd5b6020830194508093505050509250925092565b60005b8381101561082557818101518382015260200161080d565b8381111561046b5750506000910152565b6000825161084881846020870161080a565b9190910192915050565b602081526000825180602084015261087181604085016020870161080a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206f70214c51cdd41c05ba0ffeb72b309ca3c8be178fd6e73c12162330799984f364736f6c634300080a0033", "execute": { "methodName": "initialize", - "args": ["0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA"] + "args": ["0xA60Deae5344F1152426cA440fb6552eA0e3005D6"] }, - "implementation": "0xA65d9c3593B8ca0EF4C475E16Eb93f92Ca81F98B", + "implementation": "0xbC3ee948Ba5D78880c6ECb005274257e60d017c8", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/deployments/opbnbmainnet/ResilientOracle_Implementation.json b/deployments/opbnbmainnet/ResilientOracle_Implementation.json new file mode 100644 index 00000000..41e8377e --- /dev/null +++ b/deployments/opbnbmainnet/ResilientOracle_Implementation.json @@ -0,0 +1,1102 @@ +{ + "address": "0xbC3ee948Ba5D78880c6ECb005274257e60d017c8", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "nativeMarketAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "vaiAddress", + "type": "address" + }, + { + "internalType": "contract BoundValidatorInterface", + "name": "_boundValidator", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "role", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bool", + "name": "enable", + "type": "bool" + } + ], + "name": "OracleEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "role", + "type": "uint256" + } + ], + "name": "OracleSet", + "type": "event" + }, + { + "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": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "mainOracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pivotOracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "fallbackOracle", + "type": "address" + } + ], + "name": "TokenConfigAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "INVALID_PRICE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_TOKEN_ADDR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "boundValidator", + "outputs": [ + { + "internalType": "contract BoundValidatorInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "enable", + "type": "bool" + } + ], + "name": "enableOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + } + ], + "name": "getOracle", + "outputs": [ + { + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getTokenConfig", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" + }, + { + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" + } + ], + "internalType": "struct ResilientOracle.TokenConfig", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "getUnderlyingPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "nativeMarket", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "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": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "internalType": "enum ResilientOracle.OracleRole", + "name": "role", + "type": "uint8" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" + }, + { + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" + } + ], + "internalType": "struct ResilientOracle.TokenConfig", + "name": "tokenConfig", + "type": "tuple" + } + ], + "name": "setTokenConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address[3]", + "name": "oracles", + "type": "address[3]" + }, + { + "internalType": "bool[3]", + "name": "enableFlagsForOracles", + "type": "bool[3]" + } + ], + "internalType": "struct ResilientOracle.TokenConfig[]", + "name": "tokenConfigs_", + "type": "tuple[]" + } + ], + "name": "setTokenConfigs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "updateAssetPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "updatePrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vai", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x9841f20baf2933e74f06cb93662149446c9035940217cbe91de41e3cb7105a3b", + "receipt": { + "to": null, + "from": "0x4a32670436a8A662E75E64B91B3Ab989B8a00064", + "contractAddress": "0xbC3ee948Ba5D78880c6ECb005274257e60d017c8", + "transactionIndex": 1, + "gasUsed": "1904455", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400008000000000000000000000000000000000080000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000", + "blockHash": "0xcdd8900b418bc3dda9266faf1250a444369192f4f8e39f56fdd30b401570c06a", + "transactionHash": "0x9841f20baf2933e74f06cb93662149446c9035940217cbe91de41e3cb7105a3b", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 11141016, + "transactionHash": "0x9841f20baf2933e74f06cb93662149446c9035940217cbe91de41e3cb7105a3b", + "address": "0xbC3ee948Ba5D78880c6ECb005274257e60d017c8", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", + "logIndex": 0, + "blockHash": "0xcdd8900b418bc3dda9266faf1250a444369192f4f8e39f56fdd30b401570c06a" + } + ], + "blockNumber": 11141016, + "cumulativeGasUsed": "1968444", + "status": 1, + "byzantium": true + }, + "args": [ + "0x0000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000", + "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE" + ], + "numDeployments": 1, + "solcInputHash": "1e37f6e5d619feb70cefe47611ec524e", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeMarketAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"vaiAddress\",\"type\":\"address\"},{\"internalType\":\"contract BoundValidatorInterface\",\"name\":\"_boundValidator\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"calledContract\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"methodSignature\",\"type\":\"string\"}],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAccessControlManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAccessControlManager\",\"type\":\"address\"}],\"name\":\"NewAccessControlManager\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"role\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"enable\",\"type\":\"bool\"}],\"name\":\"OracleEnabled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"role\",\"type\":\"uint256\"}],\"name\":\"OracleSet\",\"type\":\"event\"},{\"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\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"mainOracle\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"pivotOracle\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"fallbackOracle\",\"type\":\"address\"}],\"name\":\"TokenConfigAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"INVALID_PRICE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NATIVE_TOKEN_ADDR\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accessControlManager\",\"outputs\":[{\"internalType\":\"contract IAccessControlManagerV8\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"boundValidator\",\"outputs\":[{\"internalType\":\"contract BoundValidatorInterface\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"enum ResilientOracle.OracleRole\",\"name\":\"role\",\"type\":\"uint8\"},{\"internalType\":\"bool\",\"name\":\"enable\",\"type\":\"bool\"}],\"name\":\"enableOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"enum ResilientOracle.OracleRole\",\"name\":\"role\",\"type\":\"uint8\"}],\"name\":\"getOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getTokenConfig\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"address[3]\",\"name\":\"oracles\",\"type\":\"address[3]\"},{\"internalType\":\"bool[3]\",\"name\":\"enableFlagsForOracles\",\"type\":\"bool[3]\"}],\"internalType\":\"struct ResilientOracle.TokenConfig\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"getUnderlyingPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nativeMarket\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"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\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"setAccessControlManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"enum ResilientOracle.OracleRole\",\"name\":\"role\",\"type\":\"uint8\"}],\"name\":\"setOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"address[3]\",\"name\":\"oracles\",\"type\":\"address[3]\"},{\"internalType\":\"bool[3]\",\"name\":\"enableFlagsForOracles\",\"type\":\"bool[3]\"}],\"internalType\":\"struct ResilientOracle.TokenConfig\",\"name\":\"tokenConfig\",\"type\":\"tuple\"}],\"name\":\"setTokenConfig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"address[3]\",\"name\":\"oracles\",\"type\":\"address[3]\"},{\"internalType\":\"bool[3]\",\"name\":\"enableFlagsForOracles\",\"type\":\"bool[3]\"}],\"internalType\":\"struct ResilientOracle.TokenConfig[]\",\"name\":\"tokenConfigs_\",\"type\":\"tuple[]\"}],\"name\":\"setTokenConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"updateAssetPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"updatePrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"vai\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\",\"details\":\"nativeMarketAddress can be address(0) if on the chain we do not support native market (e.g vETH on ethereum would not be supported, only vWETH)\",\"params\":{\"_boundValidator\":\"Address of the bound validator contract\",\"nativeMarketAddress\":\"The address of a native market (for bsc it would be vBNB address)\",\"vaiAddress\":\"The address of the VAI token (if there is VAI on the deployed chain). Set to address(0) of VAI is not existent.\"}},\"enableOracle(address,uint8,bool)\":{\"custom:access\":\"Only Governance\",\"custom:error\":\"NotNullAddress error is thrown if asset address is nullTokenConfigExistance error is thrown if token config is not set\",\"details\":\"Configuration for the asset **must** already exist and the asset cannot be 0 address\",\"params\":{\"asset\":\"Asset address\",\"enable\":\"Enabled boolean of the oracle\",\"role\":\"Oracle role\"}},\"getOracle(address,uint8)\":{\"params\":{\"asset\":\"asset address\",\"role\":\"Oracle role\"},\"returns\":{\"enabled\":\"Enabled flag of the oracle based on token config\",\"oracle\":\"Oracle address based on role\"}},\"getPrice(address)\":{\"custom:error\":\"Paused error is thrown when resilent oracle is pausedInvalid resilient oracle price error is thrown if fetched prices from oracle is invalid\",\"params\":{\"asset\":\"asset address\"},\"returns\":{\"_0\":\"price USD price in scaled decimal places.\"}},\"getTokenConfig(address)\":{\"details\":\"Gets token config by asset address\",\"params\":{\"asset\":\"asset address\"},\"returns\":{\"_0\":\"tokenConfig Config for the asset\"}},\"getUnderlyingPrice(address)\":{\"custom:error\":\"Paused error is thrown when resilent oracle is pausedInvalid resilient oracle price error is thrown if fetched prices from oracle is invalid\",\"params\":{\"vToken\":\"vToken address\"},\"returns\":{\"_0\":\"price USD price in scaled decimal places.\"}},\"initialize(address)\":{\"params\":{\"accessControlManager_\":\"Address of the access control manager contract\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pause()\":{\"custom:access\":\"Only Governance\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"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.\"},\"setAccessControlManager(address)\":{\"custom:access\":\"Only Governance\",\"custom:event\":\"Emits NewAccessControlManager event\",\"details\":\"Admin function to set address of AccessControlManager\",\"params\":{\"accessControlManager_\":\"The new address of the AccessControlManager\"}},\"setOracle(address,address,uint8)\":{\"custom:access\":\"Only Governance\",\"custom:error\":\"Null address error if main-role oracle address is nullNotNullAddress error is thrown if asset address is nullTokenConfigExistance error is thrown if token config is not set\",\"custom:event\":\"Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\",\"details\":\"Supplied asset **must** exist and main oracle may not be null\",\"params\":{\"asset\":\"Asset address\",\"oracle\":\"Oracle address\",\"role\":\"Oracle role\"}},\"setTokenConfig((address,address[3],bool[3]))\":{\"custom:access\":\"Only Governance\",\"custom:error\":\"NotNullAddress is thrown if asset address is nullNotNullAddress is thrown if main-role oracle address for asset is null\",\"custom:event\":\"Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\",\"details\":\"main oracle **must not** be a null address\",\"params\":{\"tokenConfig\":\"Token config struct\"}},\"setTokenConfigs((address,address[3],bool[3])[])\":{\"custom:access\":\"Only Governance\",\"custom:error\":\"Throws a length error if the length of the token configs array is 0\",\"params\":{\"tokenConfigs_\":\"Token config array\"}},\"transferOwnership(address)\":{\"details\":\"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.\"},\"unpause()\":{\"custom:access\":\"Only Governance\"},\"updateAssetPrice(address)\":{\"details\":\"This function should always be called before calling getPrice\",\"params\":{\"asset\":\"asset address\"}},\"updatePrice(address)\":{\"details\":\"This function should always be called before calling getUnderlyingPrice\",\"params\":{\"vToken\":\"vToken address\"}}},\"stateVariables\":{\"boundValidator\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"nativeMarket\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"vai\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"ResilientOracle\",\"version\":1},\"userdoc\":{\"errors\":{\"Unauthorized(address,address,string)\":[{\"notice\":\"Thrown when the action is prohibited by AccessControlManager\"}]},\"events\":{\"NewAccessControlManager(address,address)\":{\"notice\":\"Emitted when access control manager contract address is changed\"},\"OracleEnabled(address,uint256,bool)\":{\"notice\":\"Event emitted when an oracle is enabled or disabled\"},\"OracleSet(address,address,uint256)\":{\"notice\":\"Event emitted when an oracle is set\"}},\"kind\":\"user\",\"methods\":{\"NATIVE_TOKEN_ADDR()\":{\"notice\":\"Set this as asset address for Native token on each chain.This is the underlying for vBNB (on bsc) and can serve as any underlying asset of a market that supports native tokens\"},\"accessControlManager()\":{\"notice\":\"Returns the address of the access control manager contract\"},\"boundValidator()\":{\"notice\":\"Bound validator contract address\"},\"constructor\":{\"notice\":\"Constructor for the implementation contract. Sets immutable variables.\"},\"enableOracle(address,uint8,bool)\":{\"notice\":\"Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\"},\"getOracle(address,uint8)\":{\"notice\":\"Gets oracle and enabled status by asset address\"},\"getPrice(address)\":{\"notice\":\"Gets price of the asset\"},\"getUnderlyingPrice(address)\":{\"notice\":\"Gets price of the underlying asset for a given vToken. Validation flow: - Check if the oracle is paused globally - Validate price from main oracle against pivot oracle - Validate price from fallback oracle against pivot oracle if the first validation failed - Validate price from main oracle against fallback oracle if the second validation failed In the case that the pivot oracle is not available but main price is available and validation is successful, main oracle price is returned.\"},\"initialize(address)\":{\"notice\":\"Initializes the contract admin and sets the BoundValidator contract address\"},\"nativeMarket()\":{\"notice\":\"Native market address\"},\"pause()\":{\"notice\":\"Pauses oracle\"},\"setAccessControlManager(address)\":{\"notice\":\"Sets the address of AccessControlManager\"},\"setOracle(address,address,uint8)\":{\"notice\":\"Sets oracle for a given asset and role.\"},\"setTokenConfig((address,address[3],bool[3]))\":{\"notice\":\"Sets/resets single token configs.\"},\"setTokenConfigs((address,address[3],bool[3])[])\":{\"notice\":\"Batch sets token configs\"},\"unpause()\":{\"notice\":\"Unpauses oracle\"},\"updateAssetPrice(address)\":{\"notice\":\"Updates the pivot oracle price. Currently using TWAP\"},\"updatePrice(address)\":{\"notice\":\"Updates the TWAP pivot oracle price.\"},\"vai()\":{\"notice\":\"VAI address\"}},\"notice\":\"The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets. DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly reported prices. If only one oracle is used, this creates a single point of failure and opens a vector for attacking the protocol. The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source. For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every market. The upper bound ratio represents the deviation between reported price (the price that\\u2019s being validated) and the anchor price (the price we are validating against) above which the reported price will be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below which the reported price will be invalidated. So for oracle price to be considered valid the below statement should be true: ``` anchorRatio = anchorPrice/reporterPrice isValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio ``` In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the oracle to be stagnant and treat it like it's disabled.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ResilientOracle.sol\":\"ResilientOracle\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./OwnableUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\\n function __Ownable2Step_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable2Step_init_unchained() internal onlyInitializing {\\n }\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() public virtual {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x84efb8889801b0ac817324aff6acc691d07bbee816b671817132911d287a8c63\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x4075622496acc77fd6d4de4cc30a8577a744d5c75afad33fdeacf1704d6eda98\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```solidity\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n *\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized != type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x89be10e757d242e9b18d5a32c9fbe2019f6d63052bbe46397a430a1d60d7f794\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which allows children to implement an emergency stop\\n * mechanism that can be triggered by an authorized account.\\n *\\n * This module is used through inheritance. It will make available the\\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\\n * the functions of your contract. Note that they will not be pausable by\\n * simply including this module, only once the modifiers are put in place.\\n */\\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\\n /**\\n * @dev Emitted when the pause is triggered by `account`.\\n */\\n event Paused(address account);\\n\\n /**\\n * @dev Emitted when the pause is lifted by `account`.\\n */\\n event Unpaused(address account);\\n\\n bool private _paused;\\n\\n /**\\n * @dev Initializes the contract in unpaused state.\\n */\\n function __Pausable_init() internal onlyInitializing {\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal onlyInitializing {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n _requireNotPaused();\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n _requirePaused();\\n _;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x40c636b4572ff5f1dc50cf22097e93c0723ee14eff87e99ac2b02636eeca1250\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n *\\n * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9c80f545915582e63fe206c6ce27cbe85a86fc10b9cd2a0e8c9488fb7c2ee422\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x287b55befed2961a7eabd7d7b1b2839cbca8a5b80ef8dcbb25ed3d4c2002c305\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\\\";\\n\\nimport \\\"./IAccessControlManagerV8.sol\\\";\\n\\n/**\\n * @title AccessControlledV8\\n * @author Venus\\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\\n */\\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\\n /// @notice Access control manager contract\\n IAccessControlManagerV8 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /// @notice Thrown when the action is prohibited by AccessControlManager\\n error Unauthorized(address sender, address calledContract, string methodSignature);\\n\\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\\n __Ownable2Step_init();\\n __AccessControlled_init_unchained(accessControlManager_);\\n }\\n\\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Sets the address of AccessControlManager\\n * @dev Admin function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n * @custom:event Emits NewAccessControlManager event\\n * @custom:access Only Governance\\n */\\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV8) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert Unauthorized(msg.sender, address(this), signature);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1b805a5d09990e2c4f7839afe7726a02f8452261eb3d0d488e24129ec0a7736d\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/access/IAccessControl.sol\\\";\\n\\n/**\\n * @title IAccessControlManagerV8\\n * @author Venus\\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\\n */\\ninterface IAccessControlManagerV8 is IAccessControl {\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x8adbe291d659987faf4de606736227ad9d8e1a0e284a33a6ca12b30ab2a504b2\",\"license\":\"BSD-3-Clause\"},\"contracts/ResilientOracle.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\n// SPDX-FileCopyrightText: 2022 Venus\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\\\";\\nimport \\\"./interfaces/VBep20Interface.sol\\\";\\nimport \\\"./interfaces/OracleInterface.sol\\\";\\nimport \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\\\";\\n\\n/**\\n * @title ResilientOracle\\n * @author Venus\\n * @notice The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets.\\n * \\n * DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly\\n * reported prices. If only one oracle is used, this creates a single point of failure and opens a vector\\n * for attacking the protocol.\\n * \\n * The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect\\n * the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle\\n * and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.\\n * \\n * For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per \\n * vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot \\n * oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. \\n * \\n * To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every\\n * market. The upper bound ratio represents the deviation between reported price (the price that\\u2019s being\\n * validated) and the anchor price (the price we are validating against) above which the reported price will\\n * be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below\\n * which the reported price will be invalidated. So for oracle price to be considered valid the below statement\\n * should be true:\\n\\n```\\nanchorRatio = anchorPrice/reporterPrice\\nisValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio\\n```\\n\\n * In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending\\n * on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may\\n * use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. \\n * \\n * For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the\\n * oracle to be stagnant and treat it like it's disabled.\\n */\\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\\n /**\\n * @dev Oracle roles:\\n * **main**: The most trustworthy price source\\n * **pivot**: Price oracle used as a loose sanity checker\\n * **fallback**: The backup source when main oracle price is invalidated\\n */\\n enum OracleRole {\\n MAIN,\\n PIVOT,\\n FALLBACK\\n }\\n\\n struct TokenConfig {\\n /// @notice asset address\\n address asset;\\n /// @notice `oracles` stores the oracles based on their role in the following order:\\n /// [main, pivot, fallback],\\n /// It can be indexed with the corresponding enum OracleRole value\\n address[3] oracles;\\n /// @notice `enableFlagsForOracles` stores the enabled state\\n /// for each oracle in the same order as `oracles`\\n bool[3] enableFlagsForOracles;\\n }\\n\\n uint256 public constant INVALID_PRICE = 0;\\n\\n /// @notice Native market address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable nativeMarket;\\n\\n /// @notice VAI address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable vai;\\n\\n /// @notice Set this as asset address for Native token on each chain.This is the underlying for vBNB (on bsc)\\n /// and can serve as any underlying asset of a market that supports native tokens\\n address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\\n\\n /// @notice Bound validator contract address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n BoundValidatorInterface public immutable boundValidator;\\n\\n mapping(address => TokenConfig) private tokenConfigs;\\n\\n event TokenConfigAdded(\\n address indexed asset,\\n address indexed mainOracle,\\n address indexed pivotOracle,\\n address fallbackOracle\\n );\\n\\n /// Event emitted when an oracle is set\\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\\n\\n /// Event emitted when an oracle is enabled or disabled\\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\\n\\n /**\\n * @notice Checks whether an address is null or not\\n */\\n modifier notNullAddress(address someone) {\\n if (someone == address(0)) revert(\\\"can't be zero address\\\");\\n _;\\n }\\n\\n /**\\n * @notice Checks whether token config exists by checking whether asset is null address\\n * @dev address can't be null, so it's suitable to be used to check the validity of the config\\n * @param asset asset address\\n */\\n modifier checkTokenConfigExistence(address asset) {\\n if (tokenConfigs[asset].asset == address(0)) revert(\\\"token config must exist\\\");\\n _;\\n }\\n\\n /// @notice Constructor for the implementation contract. Sets immutable variables.\\n /// @dev nativeMarketAddress can be address(0) if on the chain we do not support native market\\n /// (e.g vETH on ethereum would not be supported, only vWETH)\\n /// @param nativeMarketAddress The address of a native market (for bsc it would be vBNB address)\\n /// @param vaiAddress The address of the VAI token (if there is VAI on the deployed chain).\\n /// Set to address(0) of VAI is not existent.\\n /// @param _boundValidator Address of the bound validator contract\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n address nativeMarketAddress,\\n address vaiAddress,\\n BoundValidatorInterface _boundValidator\\n ) notNullAddress(address(_boundValidator)) {\\n nativeMarket = nativeMarketAddress;\\n vai = vaiAddress;\\n boundValidator = _boundValidator;\\n\\n _disableInitializers();\\n }\\n\\n /**\\n * @notice Initializes the contract admin and sets the BoundValidator contract address\\n * @param accessControlManager_ Address of the access control manager contract\\n */\\n function initialize(address accessControlManager_) external initializer {\\n __AccessControlled_init(accessControlManager_);\\n __Pausable_init();\\n }\\n\\n /**\\n * @notice Pauses oracle\\n * @custom:access Only Governance\\n */\\n function pause() external {\\n _checkAccessAllowed(\\\"pause()\\\");\\n _pause();\\n }\\n\\n /**\\n * @notice Unpauses oracle\\n * @custom:access Only Governance\\n */\\n function unpause() external {\\n _checkAccessAllowed(\\\"unpause()\\\");\\n _unpause();\\n }\\n\\n /**\\n * @notice Batch sets token configs\\n * @param tokenConfigs_ Token config array\\n * @custom:access Only Governance\\n * @custom:error Throws a length error if the length of the token configs array is 0\\n */\\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\\n if (tokenConfigs_.length == 0) revert(\\\"length can't be 0\\\");\\n uint256 numTokenConfigs = tokenConfigs_.length;\\n for (uint256 i; i < numTokenConfigs; ) {\\n setTokenConfig(tokenConfigs_[i]);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Sets oracle for a given asset and role.\\n * @dev Supplied asset **must** exist and main oracle may not be null\\n * @param asset Asset address\\n * @param oracle Oracle address\\n * @param role Oracle role\\n * @custom:access Only Governance\\n * @custom:error Null address error if main-role oracle address is null\\n * @custom:error NotNullAddress error is thrown if asset address is null\\n * @custom:error TokenConfigExistance error is thrown if token config is not set\\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\\n */\\n function setOracle(\\n address asset,\\n address oracle,\\n OracleRole role\\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\\n _checkAccessAllowed(\\\"setOracle(address,address,uint8)\\\");\\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\\\"can't set zero address to main oracle\\\");\\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\\n emit OracleSet(asset, oracle, uint256(role));\\n }\\n\\n /**\\n * @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\\n * @dev Configuration for the asset **must** already exist and the asset cannot be 0 address\\n * @param asset Asset address\\n * @param role Oracle role\\n * @param enable Enabled boolean of the oracle\\n * @custom:access Only Governance\\n * @custom:error NotNullAddress error is thrown if asset address is null\\n * @custom:error TokenConfigExistance error is thrown if token config is not set\\n */\\n function enableOracle(\\n address asset,\\n OracleRole role,\\n bool enable\\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\\n _checkAccessAllowed(\\\"enableOracle(address,uint8,bool)\\\");\\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\\n emit OracleEnabled(asset, uint256(role), enable);\\n }\\n\\n /**\\n * @notice Updates the TWAP pivot oracle price.\\n * @dev This function should always be called before calling getUnderlyingPrice\\n * @param vToken vToken address\\n */\\n function updatePrice(address vToken) external override {\\n address asset = _getUnderlyingAsset(vToken);\\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\\n if (pivotOracle != address(0) && pivotOracleEnabled) {\\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\\n }\\n }\\n\\n /**\\n * @notice Updates the pivot oracle price. Currently using TWAP\\n * @dev This function should always be called before calling getPrice\\n * @param asset asset address\\n */\\n function updateAssetPrice(address asset) external {\\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\\n if (pivotOracle != address(0) && pivotOracleEnabled) {\\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\\n }\\n }\\n\\n /**\\n * @dev Gets token config by asset address\\n * @param asset asset address\\n * @return tokenConfig Config for the asset\\n */\\n function getTokenConfig(address asset) external view returns (TokenConfig memory) {\\n return tokenConfigs[asset];\\n }\\n\\n /**\\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\\n * - Check if the oracle is paused globally\\n * - Validate price from main oracle against pivot oracle\\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\\n * - Validate price from main oracle against fallback oracle if the second validation failed\\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\\n * main oracle price is returned.\\n * @param vToken vToken address\\n * @return price USD price in scaled decimal places.\\n * @custom:error Paused error is thrown when resilent oracle is paused\\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\\n */\\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\\n if (paused()) revert(\\\"resilient oracle is paused\\\");\\n\\n address asset = _getUnderlyingAsset(vToken);\\n return _getPrice(asset);\\n }\\n\\n /**\\n * @notice Gets price of the asset\\n * @param asset asset address\\n * @return price USD price in scaled decimal places.\\n * @custom:error Paused error is thrown when resilent oracle is paused\\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\\n */\\n function getPrice(address asset) external view override returns (uint256) {\\n if (paused()) revert(\\\"resilient oracle is paused\\\");\\n return _getPrice(asset);\\n }\\n\\n /**\\n * @notice Sets/resets single token configs.\\n * @dev main oracle **must not** be a null address\\n * @param tokenConfig Token config struct\\n * @custom:access Only Governance\\n * @custom:error NotNullAddress is thrown if asset address is null\\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\\n * @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\\n */\\n function setTokenConfig(\\n TokenConfig memory tokenConfig\\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\\n _checkAccessAllowed(\\\"setTokenConfig(TokenConfig)\\\");\\n\\n tokenConfigs[tokenConfig.asset] = tokenConfig;\\n emit TokenConfigAdded(\\n tokenConfig.asset,\\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\\n );\\n }\\n\\n /**\\n * @notice Gets oracle and enabled status by asset address\\n * @param asset asset address\\n * @param role Oracle role\\n * @return oracle Oracle address based on role\\n * @return enabled Enabled flag of the oracle based on token config\\n */\\n function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {\\n oracle = tokenConfigs[asset].oracles[uint256(role)];\\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\\n }\\n\\n function _getPrice(address asset) internal view returns (uint256) {\\n uint256 pivotPrice = INVALID_PRICE;\\n\\n // Get pivot oracle price, Invalid price if not available or error\\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\\n if (pivotOracleEnabled && pivotOracle != address(0)) {\\n try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {\\n pivotPrice = pricePivot;\\n } catch {}\\n }\\n\\n // Compare main price and pivot price, return main price and if validation was successful\\n // note: In case pivot oracle is not available but main price is available and\\n // validation is successful, the main oracle price is returned.\\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\\n asset,\\n pivotPrice,\\n pivotOracleEnabled && pivotOracle != address(0)\\n );\\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\\n\\n // Compare fallback and pivot if main oracle comparision fails with pivot\\n // Return fallback price when fallback price is validated successfully with pivot oracle\\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);\\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\\n\\n // Lastly compare main price and fallback price\\n if (\\n mainPrice != INVALID_PRICE &&\\n fallbackPrice != INVALID_PRICE &&\\n boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)\\n ) {\\n return mainPrice;\\n }\\n\\n revert(\\\"invalid resilient oracle price\\\");\\n }\\n\\n /**\\n * @notice Gets a price for the provided asset\\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\\n * able to fetch a correct price\\n * @param asset asset address\\n * @param pivotPrice Pivot oracle price\\n * @param pivotEnabled If pivot oracle is not empty and enabled\\n * @return price USD price in scaled decimals\\n * e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\\n * @return pivotValidated Boolean representing if the validation of main oracle price\\n * and pivot oracle price were successful\\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset\\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\\n * address is null\\n */\\n function _getMainOraclePrice(\\n address asset,\\n uint256 pivotPrice,\\n bool pivotEnabled\\n ) internal view returns (uint256, bool) {\\n (address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);\\n if (mainOracleEnabled && mainOracle != address(0)) {\\n try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {\\n if (!pivotEnabled) {\\n return (mainOraclePrice, true);\\n }\\n if (pivotPrice == INVALID_PRICE) {\\n return (mainOraclePrice, false);\\n }\\n return (\\n mainOraclePrice,\\n boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)\\n );\\n } catch {\\n return (INVALID_PRICE, false);\\n }\\n }\\n\\n return (INVALID_PRICE, false);\\n }\\n\\n /**\\n * @dev This function won't revert when the price is 0 because getPrice checks if price is > 0\\n * @param asset asset address\\n * @return price USD price in 18 decimals\\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\\n * and pivot oracle price were successfull\\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset\\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\\n * address is null\\n */\\n function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {\\n (address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);\\n if (fallbackEnabled && fallbackOracle != address(0)) {\\n try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {\\n if (pivotPrice == INVALID_PRICE) {\\n return (fallbackOraclePrice, false);\\n }\\n return (\\n fallbackOraclePrice,\\n boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)\\n );\\n } catch {\\n return (INVALID_PRICE, false);\\n }\\n }\\n\\n return (INVALID_PRICE, false);\\n }\\n\\n /**\\n * @dev This function returns the underlying asset of a vToken\\n * @param vToken vToken address\\n * @return asset underlying asset address\\n */\\n function _getUnderlyingAsset(address vToken) private view notNullAddress(vToken) returns (address asset) {\\n if (vToken == nativeMarket) {\\n asset = NATIVE_TOKEN_ADDR;\\n } else if (vToken == vai) {\\n asset = vai;\\n } else {\\n asset = VBep20Interface(vToken).underlying();\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3bead63c5f2aca7e1ea5e9a075816e9e3551ce3a886f5f3707040262ad6d2c35\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface OracleInterface {\\n function getPrice(address asset) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n\\n function updateAssetPrice(address asset) external;\\n\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address asset) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address asset,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x40031b19684ca0c912e794d08c2c0b0d8be77d3c1bdc937830a0658eff899650\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/VBep20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\ninterface VBep20Interface is IERC20Metadata {\\n /**\\n * @notice Underlying asset for this VToken\\n */\\n function underlying() external view returns (address);\\n}\\n\",\"keccak256\":\"0x3f845cd51b2d82f7932ac6c0ab714df97f733b01ce50f6fb0adb4c28447d4618\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", + "bytecode": "0x60e06040523480156200001157600080fd5b506040516200233538038062002335833981016040819052620000349162000195565b806001600160a01b038116620000915760405162461bcd60e51b815260206004820152601560248201527f63616e2774206265207a65726f2061646472657373000000000000000000000060448201526064015b60405180910390fd5b6001600160a01b0380851660805283811660a052821660c052620000b4620000be565b50505050620001e9565b600054610100900460ff1615620001285760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840162000088565b60005460ff908116146200017a576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6001600160a01b03811681146200019257600080fd5b50565b600080600060608486031215620001ab57600080fd5b8351620001b8816200017c565b6020850151909350620001cb816200017c565b6040850151909250620001de816200017c565b809150509250925092565b60805160a05160c0516120f262000243600039600081816101d3015281816112b3015281816116bd015261182d0152600081816103580152818161144e015261148701526000818161028901526113f901526120f26000f3fe608060405234801561001057600080fd5b506004361061018e5760003560e01c80638b855da4116100de578063b62cad6911610097578063cb67e3b111610071578063cb67e3b11461038d578063e30c3978146103ad578063f2fde38b146103be578063fc57d4df146103d157600080fd5b8063b62cad6914610340578063b62e4c9214610353578063c4d66de81461037a57600080fd5b80638b855da4146102ab5780638da5cb5b146102dd57806396e85ced146102ee578063a6b1344a14610301578063a9534f8a14610314578063b4a0bdf31461032f57600080fd5b80634b932b8f1161014b578063715018a611610125578063715018a61461026c57806379ba5097146102745780638456cb591461027c5780638a2f7f6d1461028457600080fd5b80634b932b8f1461023b5780634bf39cba1461024e5780635c975abb1461025657600080fd5b80630e32cb86146101935780632cfa3871146101a8578063333a21b0146101bb57806333d33494146101ce5780633f4ba83a1461021257806341976e091461021a575b600080fd5b6101a66101a1366004611b6a565b6103e4565b005b6101a66101b6366004611cf5565b6103f8565b6101a66101c9366004611da5565b61047e565b6101f57f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6101a66105d0565b61022d610228366004611b6a565b610604565b604051908152602001610209565b6101a6610249366004611dd5565b61066e565b61022d600081565b60335460ff166040519015158152602001610209565b6101a66107e4565b6101a66107f6565b6101a661086d565b6101f57f000000000000000000000000000000000000000000000000000000000000000081565b6102be6102b9366004611e1e565b61089d565b604080516001600160a01b039093168352901515602083015201610209565b6065546001600160a01b03166101f5565b6101a66102fc366004611b6a565b61093f565b6101a661030f366004611e53565b6109ea565b6101f573bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb81565b60c9546001600160a01b03166101f5565b6101a661034e366004611b6a565b610bec565b6101f57f000000000000000000000000000000000000000000000000000000000000000081565b6101a6610388366004611b6a565b610c88565b6103a061039b366004611b6a565b610da4565b6040516102099190611e9a565b6097546001600160a01b03166101f5565b6101a66103cc366004611b6a565b610e79565b61022d6103df366004611b6a565b610eea565b6103ec610f62565b6103f581610fbc565b50565b80516000036104425760405162461bcd60e51b815260206004820152601160248201527006c656e6774682063616e2774206265203607c1b60448201526064015b60405180910390fd5b805160005b818110156104795761047183828151811061046457610464611f15565b602002602001015161047e565b600101610447565b505050565b80516001600160a01b0381166104a65760405162461bcd60e51b815260040161043990611f2b565b6020820151516001600160a01b0381166104d25760405162461bcd60e51b815260040161043990611f2b565b6105106040518060400160405280601b81526020017f736574546f6b656e436f6e66696728546f6b656e436f6e66696729000000000081525061107a565b82516001600160a01b03908116600090815260fb60209081526040909120855181546001600160a01b031916931692909217825584015184919061055a9060018301906003611a08565b5060408201516105709060048301906003611a60565b505050602083810151808201518151865160409384015193516001600160a01b039485168152928416949184169316917fa51ad01e2270c314a7b78f0c60fe66c723f2d06c121d63fcdce776e654878fc1910160405180910390a4505050565b6105fa60405180604001604052806009815260200168756e7061757365282960b81b81525061107a565b610602611114565b565b600061061260335460ff1690565b1561065f5760405162461bcd60e51b815260206004820152601a60248201527f726573696c69656e74206f7261636c65206973207061757365640000000000006044820152606401610439565b61066882611166565b92915050565b826001600160a01b0381166106955760405162461bcd60e51b815260040161043990611f2b565b6001600160a01b03808516600090815260fb60205260409020548591166106f85760405162461bcd60e51b81526020600482015260176024820152761d1bdad95b8818dbdb999a59c81b5d5cdd08195e1a5cdd604a1b6044820152606401610439565b6107366040518060400160405280602081526020017f656e61626c654f7261636c6528616464726573732c75696e74382c626f6f6c2981525061107a565b6001600160a01b038516600090815260fb60205260409020839060040185600281111561076557610765611f5a565b6003811061077557610775611f15565b602091828204019190066101000a81548160ff0219169083151502179055508215158460028111156107a9576107a9611f5a565b6040516001600160a01b038816907fcf3cad1ec87208efbde5d82a0557484a78d4182c3ad16926a5463bc1f7234b3d90600090a45050505050565b6107ec610f62565b6106026000611378565b60975433906001600160a01b031681146108645760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610439565b6103f581611378565b610895604051806040016040528060078152602001667061757365282960c81b81525061107a565b610602611391565b6001600160a01b038216600090815260fb6020526040812081906001018360028111156108cc576108cc611f5a565b600381106108dc576108dc611f15565b01546001600160a01b03858116600090815260fb602052604090209116925060040183600281111561091057610910611f5a565b6003811061092057610920611f15565b602091828204019190069054906101000a900460ff1690509250929050565b600061094a826113ce565b905060008061095a83600161089d565b90925090506001600160a01b038216158015906109745750805b156109e45760405163725068a560e01b81526001600160a01b03848116600483015283169063725068a5906024016020604051808303816000875af19250505080156109dd575060408051601f3d908101601f191682019092526109da91810190611f70565b60015b156109e457505b50505050565b826001600160a01b038116610a115760405162461bcd60e51b815260040161043990611f2b565b6001600160a01b03808516600090815260fb6020526040902054859116610a745760405162461bcd60e51b81526020600482015260176024820152761d1bdad95b8818dbdb999a59c81b5d5cdd08195e1a5cdd604a1b6044820152606401610439565b610ab26040518060400160405280602081526020017f7365744f7261636c6528616464726573732c616464726573732c75696e74382981525061107a565b6001600160a01b038416158015610ada57506000836002811115610ad857610ad8611f5a565b145b15610b355760405162461bcd60e51b815260206004820152602560248201527f63616e277420736574207a65726f206164647265737320746f206d61696e206f6044820152647261636c6560d81b6064820152608401610439565b6001600160a01b038516600090815260fb602052604090208490600101846002811115610b6457610b64611f5a565b60038110610b7457610b74611f15565b0180546001600160a01b0319166001600160a01b0392909216919091179055826002811115610ba557610ba5611f5a565b846001600160a01b0316866001600160a01b03167fea681d3efb830ef032a9c29a7215b5ceeeb546250d2c463dbf87817aecda1bf160405160405180910390a45050505050565b600080610bfa83600161089d565b90925090506001600160a01b03821615801590610c145750805b156104795760405163725068a560e01b81526001600160a01b03848116600483015283169063725068a5906024016020604051808303816000875af1925050508015610c7d575060408051601f3d908101601f19168201909252610c7a91810190611f70565b60015b156104795750505050565b600054610100900460ff1615808015610ca85750600054600160ff909116105b80610cc25750303b158015610cc2575060005460ff166001145b610d255760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610439565b6000805460ff191660011790558015610d48576000805461ff0019166101001790555b610d5182611515565b610d5961154d565b8015610da0576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b610dac611aed565b6001600160a01b03828116600090815260fb60209081526040918290208251606080820185528254909516815283519485019384905293909291840191600184019060039082845b81546001600160a01b03168152600190910190602001808311610df4575050509183525050604080516060810191829052602090920191906004840190600390826000855b825461010083900a900460ff161515815260206001928301818104948501949093039092029101808411610e395790505050505050815250509050919050565b610e81610f62565b609780546001600160a01b0383166001600160a01b03199091168117909155610eb26065546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000610ef860335460ff1690565b15610f455760405162461bcd60e51b815260206004820152601a60248201527f726573696c69656e74206f7261636c65206973207061757365640000000000006044820152606401610439565b6000610f50836113ce565b9050610f5b81611166565b9392505050565b6065546001600160a01b031633146106025760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610439565b6001600160a01b0381166110205760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610439565b60c980546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa09101610d97565b60c9546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906110ad9033908690600401611fd6565b602060405180830381865afa1580156110ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ee9190612002565b905080610da057333083604051634a3fa29360e01b81526004016104399392919061201f565b61111c61157c565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080808061117685600161089d565b9150915080801561118f57506001600160a01b03821615155b156111fe576040516341976e0960e01b81526001600160a01b0386811660048301528316906341976e0990602401602060405180830381865afa9250505080156111f6575060408051601f3d908101601f191682019092526111f391810190611f70565b60015b156111fe5792505b600080611220878685801561121b57506001600160a01b03871615155b6115c5565b91509150600082141580156112325750805b15611241575095945050505050565b60008061124e8988611748565b91509150600082141580156112605750805b156112715750979650505050505050565b831580159061127f57508115155b801561131e5750604051634be3819f60e11b81526001600160a01b038a8116600483015260248201869052604482018490527f000000000000000000000000000000000000000000000000000000000000000016906397c7033e90606401602060405180830381865afa1580156112fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131e9190612002565b15611330575091979650505050505050565b60405162461bcd60e51b815260206004820152601e60248201527f696e76616c696420726573696c69656e74206f7261636c6520707269636500006044820152606401610439565b609780546001600160a01b03191690556103f5816118b7565b611399611909565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586111493390565b6000816001600160a01b0381166113f75760405162461bcd60e51b815260040161043990611f2b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03160361144c5773bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb915061150f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b0316036114ad577f0000000000000000000000000000000000000000000000000000000000000000915061150f565b826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114eb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5b9190612054565b50919050565b600054610100900460ff1661153c5760405162461bcd60e51b815260040161043990612071565b61154461194f565b6103f58161197e565b600054610100900460ff166115745760405162461bcd60e51b815260040161043990612071565b6106026119a5565b60335460ff166106025760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610439565b6000806000806115d687600061089d565b915091508080156115ef57506001600160a01b03821615155b15611736576040516341976e0960e01b81526001600160a01b0388811660048301528316906341976e0990602401602060405180830381865afa925050508015611656575060408051601f3d908101601f1916820190925261165391810190611f70565b60015b61166857600080935093505050611740565b8561167b57935060019250611740915050565b8661168e57935060009250611740915050565b604051634be3819f60e11b81526001600160a01b038981166004830152602482018390526044820189905282917f0000000000000000000000000000000000000000000000000000000000000000909116906397c7033e90606401602060405180830381865afa158015611706573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172a9190612002565b94509450505050611740565b6000809350935050505b935093915050565b60008060008061175986600261089d565b9150915080801561177257506001600160a01b03821615155b156118a6576040516341976e0960e01b81526001600160a01b0387811660048301528316906341976e0990602401602060405180830381865afa9250505080156117d9575060408051601f3d908101601f191682019092526117d691810190611f70565b60015b6117eb576000809350935050506118b0565b856117fe579350600092506118b0915050565b604051634be3819f60e11b81526001600160a01b038881166004830152602482018390526044820188905282917f0000000000000000000000000000000000000000000000000000000000000000909116906397c7033e90606401602060405180830381865afa158015611876573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189a9190612002565b945094505050506118b0565b6000809350935050505b9250929050565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60335460ff16156106025760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610439565b600054610100900460ff166119765760405162461bcd60e51b815260040161043990612071565b6106026119d8565b600054610100900460ff166103ec5760405162461bcd60e51b815260040161043990612071565b600054610100900460ff166119cc5760405162461bcd60e51b815260040161043990612071565b6033805460ff19169055565b600054610100900460ff166119ff5760405162461bcd60e51b815260040161043990612071565b61060233611378565b8260038101928215611a50579160200282015b82811115611a5057825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190611a1b565b50611a5c929150611b22565b5090565b600183019183908215611a505791602002820160005b83821115611ab357835183826101000a81548160ff0219169083151502179055509260200192600101602081600001049283019260010302611a76565b8015611ae05782816101000a81549060ff0219169055600101602081600001049283019260010302611ab3565b5050611a5c929150611b22565b604051806060016040528060006001600160a01b03168152602001611b10611b37565b8152602001611b1d611b37565b905290565b5b80821115611a5c5760008155600101611b23565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b03811681146103f557600080fd5b600060208284031215611b7c57600080fd5b8135610f5b81611b55565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715611bc057611bc0611b87565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611bef57611bef611b87565b604052919050565b80151581146103f557600080fd5b600082601f830112611c1657600080fd5b611c1e611b9d565b806060840185811115611c3057600080fd5b845b81811015611c53578035611c4581611bf7565b845260209384019301611c32565b509095945050505050565b600060e08284031215611c7057600080fd5b611c78611b9d565b90508135611c8581611b55565b81526020603f83018413611c9857600080fd5b611ca0611b9d565b806080850186811115611cb257600080fd5b8386015b81811015611cd6578035611cc981611b55565b8452928401928401611cb6565b508184860152611ce68782611c05565b60408601525050505092915050565b60006020808385031215611d0857600080fd5b823567ffffffffffffffff80821115611d2057600080fd5b818501915085601f830112611d3457600080fd5b813581811115611d4657611d46611b87565b611d54848260051b01611bc6565b818152848101925060e0918202840185019188831115611d7357600080fd5b938501935b82851015611d9957611d8a8986611c5e565b84529384019392850192611d78565b50979650505050505050565b600060e08284031215611db757600080fd5b610f5b8383611c5e565b803560038110611dd057600080fd5b919050565b600080600060608486031215611dea57600080fd5b8335611df581611b55565b9250611e0360208501611dc1565b91506040840135611e1381611bf7565b809150509250925092565b60008060408385031215611e3157600080fd5b8235611e3c81611b55565b9150611e4a60208401611dc1565b90509250929050565b600080600060608486031215611e6857600080fd5b8335611e7381611b55565b92506020840135611e8381611b55565b9150611e9160408501611dc1565b90509250925092565b81516001600160a01b03908116825260208084015160e0840192919081850160005b6003811015611edb578251851682529183019190830190600101611ebc565b505050604085015191506080840160005b6003811015611f0b578351151582529282019290820190600101611eec565b5050505092915050565b634e487b7160e01b600052603260045260246000fd5b60208082526015908201527463616e2774206265207a65726f206164647265737360581b604082015260600190565b634e487b7160e01b600052602160045260246000fd5b600060208284031215611f8257600080fd5b5051919050565b6000815180845260005b81811015611faf57602081850181015186830182015201611f93565b81811115611fc1576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090611ffa90830184611f89565b949350505050565b60006020828403121561201457600080fd5b8151610f5b81611bf7565b6001600160a01b0384811682528316602082015260606040820181905260009061204b90830184611f89565b95945050505050565b60006020828403121561206657600080fd5b8151610f5b81611b55565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea2646970667358221220b9bc3df89eecf428639ba62dabee9cb25456e2d7118fa1429ca77d62dab25bef64736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061018e5760003560e01c80638b855da4116100de578063b62cad6911610097578063cb67e3b111610071578063cb67e3b11461038d578063e30c3978146103ad578063f2fde38b146103be578063fc57d4df146103d157600080fd5b8063b62cad6914610340578063b62e4c9214610353578063c4d66de81461037a57600080fd5b80638b855da4146102ab5780638da5cb5b146102dd57806396e85ced146102ee578063a6b1344a14610301578063a9534f8a14610314578063b4a0bdf31461032f57600080fd5b80634b932b8f1161014b578063715018a611610125578063715018a61461026c57806379ba5097146102745780638456cb591461027c5780638a2f7f6d1461028457600080fd5b80634b932b8f1461023b5780634bf39cba1461024e5780635c975abb1461025657600080fd5b80630e32cb86146101935780632cfa3871146101a8578063333a21b0146101bb57806333d33494146101ce5780633f4ba83a1461021257806341976e091461021a575b600080fd5b6101a66101a1366004611b6a565b6103e4565b005b6101a66101b6366004611cf5565b6103f8565b6101a66101c9366004611da5565b61047e565b6101f57f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6101a66105d0565b61022d610228366004611b6a565b610604565b604051908152602001610209565b6101a6610249366004611dd5565b61066e565b61022d600081565b60335460ff166040519015158152602001610209565b6101a66107e4565b6101a66107f6565b6101a661086d565b6101f57f000000000000000000000000000000000000000000000000000000000000000081565b6102be6102b9366004611e1e565b61089d565b604080516001600160a01b039093168352901515602083015201610209565b6065546001600160a01b03166101f5565b6101a66102fc366004611b6a565b61093f565b6101a661030f366004611e53565b6109ea565b6101f573bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb81565b60c9546001600160a01b03166101f5565b6101a661034e366004611b6a565b610bec565b6101f57f000000000000000000000000000000000000000000000000000000000000000081565b6101a6610388366004611b6a565b610c88565b6103a061039b366004611b6a565b610da4565b6040516102099190611e9a565b6097546001600160a01b03166101f5565b6101a66103cc366004611b6a565b610e79565b61022d6103df366004611b6a565b610eea565b6103ec610f62565b6103f581610fbc565b50565b80516000036104425760405162461bcd60e51b815260206004820152601160248201527006c656e6774682063616e2774206265203607c1b60448201526064015b60405180910390fd5b805160005b818110156104795761047183828151811061046457610464611f15565b602002602001015161047e565b600101610447565b505050565b80516001600160a01b0381166104a65760405162461bcd60e51b815260040161043990611f2b565b6020820151516001600160a01b0381166104d25760405162461bcd60e51b815260040161043990611f2b565b6105106040518060400160405280601b81526020017f736574546f6b656e436f6e66696728546f6b656e436f6e66696729000000000081525061107a565b82516001600160a01b03908116600090815260fb60209081526040909120855181546001600160a01b031916931692909217825584015184919061055a9060018301906003611a08565b5060408201516105709060048301906003611a60565b505050602083810151808201518151865160409384015193516001600160a01b039485168152928416949184169316917fa51ad01e2270c314a7b78f0c60fe66c723f2d06c121d63fcdce776e654878fc1910160405180910390a4505050565b6105fa60405180604001604052806009815260200168756e7061757365282960b81b81525061107a565b610602611114565b565b600061061260335460ff1690565b1561065f5760405162461bcd60e51b815260206004820152601a60248201527f726573696c69656e74206f7261636c65206973207061757365640000000000006044820152606401610439565b61066882611166565b92915050565b826001600160a01b0381166106955760405162461bcd60e51b815260040161043990611f2b565b6001600160a01b03808516600090815260fb60205260409020548591166106f85760405162461bcd60e51b81526020600482015260176024820152761d1bdad95b8818dbdb999a59c81b5d5cdd08195e1a5cdd604a1b6044820152606401610439565b6107366040518060400160405280602081526020017f656e61626c654f7261636c6528616464726573732c75696e74382c626f6f6c2981525061107a565b6001600160a01b038516600090815260fb60205260409020839060040185600281111561076557610765611f5a565b6003811061077557610775611f15565b602091828204019190066101000a81548160ff0219169083151502179055508215158460028111156107a9576107a9611f5a565b6040516001600160a01b038816907fcf3cad1ec87208efbde5d82a0557484a78d4182c3ad16926a5463bc1f7234b3d90600090a45050505050565b6107ec610f62565b6106026000611378565b60975433906001600160a01b031681146108645760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610439565b6103f581611378565b610895604051806040016040528060078152602001667061757365282960c81b81525061107a565b610602611391565b6001600160a01b038216600090815260fb6020526040812081906001018360028111156108cc576108cc611f5a565b600381106108dc576108dc611f15565b01546001600160a01b03858116600090815260fb602052604090209116925060040183600281111561091057610910611f5a565b6003811061092057610920611f15565b602091828204019190069054906101000a900460ff1690509250929050565b600061094a826113ce565b905060008061095a83600161089d565b90925090506001600160a01b038216158015906109745750805b156109e45760405163725068a560e01b81526001600160a01b03848116600483015283169063725068a5906024016020604051808303816000875af19250505080156109dd575060408051601f3d908101601f191682019092526109da91810190611f70565b60015b156109e457505b50505050565b826001600160a01b038116610a115760405162461bcd60e51b815260040161043990611f2b565b6001600160a01b03808516600090815260fb6020526040902054859116610a745760405162461bcd60e51b81526020600482015260176024820152761d1bdad95b8818dbdb999a59c81b5d5cdd08195e1a5cdd604a1b6044820152606401610439565b610ab26040518060400160405280602081526020017f7365744f7261636c6528616464726573732c616464726573732c75696e74382981525061107a565b6001600160a01b038416158015610ada57506000836002811115610ad857610ad8611f5a565b145b15610b355760405162461bcd60e51b815260206004820152602560248201527f63616e277420736574207a65726f206164647265737320746f206d61696e206f6044820152647261636c6560d81b6064820152608401610439565b6001600160a01b038516600090815260fb602052604090208490600101846002811115610b6457610b64611f5a565b60038110610b7457610b74611f15565b0180546001600160a01b0319166001600160a01b0392909216919091179055826002811115610ba557610ba5611f5a565b846001600160a01b0316866001600160a01b03167fea681d3efb830ef032a9c29a7215b5ceeeb546250d2c463dbf87817aecda1bf160405160405180910390a45050505050565b600080610bfa83600161089d565b90925090506001600160a01b03821615801590610c145750805b156104795760405163725068a560e01b81526001600160a01b03848116600483015283169063725068a5906024016020604051808303816000875af1925050508015610c7d575060408051601f3d908101601f19168201909252610c7a91810190611f70565b60015b156104795750505050565b600054610100900460ff1615808015610ca85750600054600160ff909116105b80610cc25750303b158015610cc2575060005460ff166001145b610d255760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610439565b6000805460ff191660011790558015610d48576000805461ff0019166101001790555b610d5182611515565b610d5961154d565b8015610da0576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b610dac611aed565b6001600160a01b03828116600090815260fb60209081526040918290208251606080820185528254909516815283519485019384905293909291840191600184019060039082845b81546001600160a01b03168152600190910190602001808311610df4575050509183525050604080516060810191829052602090920191906004840190600390826000855b825461010083900a900460ff161515815260206001928301818104948501949093039092029101808411610e395790505050505050815250509050919050565b610e81610f62565b609780546001600160a01b0383166001600160a01b03199091168117909155610eb26065546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000610ef860335460ff1690565b15610f455760405162461bcd60e51b815260206004820152601a60248201527f726573696c69656e74206f7261636c65206973207061757365640000000000006044820152606401610439565b6000610f50836113ce565b9050610f5b81611166565b9392505050565b6065546001600160a01b031633146106025760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610439565b6001600160a01b0381166110205760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610439565b60c980546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa09101610d97565b60c9546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906110ad9033908690600401611fd6565b602060405180830381865afa1580156110ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ee9190612002565b905080610da057333083604051634a3fa29360e01b81526004016104399392919061201f565b61111c61157c565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080808061117685600161089d565b9150915080801561118f57506001600160a01b03821615155b156111fe576040516341976e0960e01b81526001600160a01b0386811660048301528316906341976e0990602401602060405180830381865afa9250505080156111f6575060408051601f3d908101601f191682019092526111f391810190611f70565b60015b156111fe5792505b600080611220878685801561121b57506001600160a01b03871615155b6115c5565b91509150600082141580156112325750805b15611241575095945050505050565b60008061124e8988611748565b91509150600082141580156112605750805b156112715750979650505050505050565b831580159061127f57508115155b801561131e5750604051634be3819f60e11b81526001600160a01b038a8116600483015260248201869052604482018490527f000000000000000000000000000000000000000000000000000000000000000016906397c7033e90606401602060405180830381865afa1580156112fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131e9190612002565b15611330575091979650505050505050565b60405162461bcd60e51b815260206004820152601e60248201527f696e76616c696420726573696c69656e74206f7261636c6520707269636500006044820152606401610439565b609780546001600160a01b03191690556103f5816118b7565b611399611909565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586111493390565b6000816001600160a01b0381166113f75760405162461bcd60e51b815260040161043990611f2b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03160361144c5773bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb915061150f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b0316036114ad577f0000000000000000000000000000000000000000000000000000000000000000915061150f565b826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114eb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5b9190612054565b50919050565b600054610100900460ff1661153c5760405162461bcd60e51b815260040161043990612071565b61154461194f565b6103f58161197e565b600054610100900460ff166115745760405162461bcd60e51b815260040161043990612071565b6106026119a5565b60335460ff166106025760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610439565b6000806000806115d687600061089d565b915091508080156115ef57506001600160a01b03821615155b15611736576040516341976e0960e01b81526001600160a01b0388811660048301528316906341976e0990602401602060405180830381865afa925050508015611656575060408051601f3d908101601f1916820190925261165391810190611f70565b60015b61166857600080935093505050611740565b8561167b57935060019250611740915050565b8661168e57935060009250611740915050565b604051634be3819f60e11b81526001600160a01b038981166004830152602482018390526044820189905282917f0000000000000000000000000000000000000000000000000000000000000000909116906397c7033e90606401602060405180830381865afa158015611706573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172a9190612002565b94509450505050611740565b6000809350935050505b935093915050565b60008060008061175986600261089d565b9150915080801561177257506001600160a01b03821615155b156118a6576040516341976e0960e01b81526001600160a01b0387811660048301528316906341976e0990602401602060405180830381865afa9250505080156117d9575060408051601f3d908101601f191682019092526117d691810190611f70565b60015b6117eb576000809350935050506118b0565b856117fe579350600092506118b0915050565b604051634be3819f60e11b81526001600160a01b038881166004830152602482018390526044820188905282917f0000000000000000000000000000000000000000000000000000000000000000909116906397c7033e90606401602060405180830381865afa158015611876573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189a9190612002565b945094505050506118b0565b6000809350935050505b9250929050565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60335460ff16156106025760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610439565b600054610100900460ff166119765760405162461bcd60e51b815260040161043990612071565b6106026119d8565b600054610100900460ff166103ec5760405162461bcd60e51b815260040161043990612071565b600054610100900460ff166119cc5760405162461bcd60e51b815260040161043990612071565b6033805460ff19169055565b600054610100900460ff166119ff5760405162461bcd60e51b815260040161043990612071565b61060233611378565b8260038101928215611a50579160200282015b82811115611a5057825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190611a1b565b50611a5c929150611b22565b5090565b600183019183908215611a505791602002820160005b83821115611ab357835183826101000a81548160ff0219169083151502179055509260200192600101602081600001049283019260010302611a76565b8015611ae05782816101000a81549060ff0219169055600101602081600001049283019260010302611ab3565b5050611a5c929150611b22565b604051806060016040528060006001600160a01b03168152602001611b10611b37565b8152602001611b1d611b37565b905290565b5b80821115611a5c5760008155600101611b23565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b03811681146103f557600080fd5b600060208284031215611b7c57600080fd5b8135610f5b81611b55565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715611bc057611bc0611b87565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611bef57611bef611b87565b604052919050565b80151581146103f557600080fd5b600082601f830112611c1657600080fd5b611c1e611b9d565b806060840185811115611c3057600080fd5b845b81811015611c53578035611c4581611bf7565b845260209384019301611c32565b509095945050505050565b600060e08284031215611c7057600080fd5b611c78611b9d565b90508135611c8581611b55565b81526020603f83018413611c9857600080fd5b611ca0611b9d565b806080850186811115611cb257600080fd5b8386015b81811015611cd6578035611cc981611b55565b8452928401928401611cb6565b508184860152611ce68782611c05565b60408601525050505092915050565b60006020808385031215611d0857600080fd5b823567ffffffffffffffff80821115611d2057600080fd5b818501915085601f830112611d3457600080fd5b813581811115611d4657611d46611b87565b611d54848260051b01611bc6565b818152848101925060e0918202840185019188831115611d7357600080fd5b938501935b82851015611d9957611d8a8986611c5e565b84529384019392850192611d78565b50979650505050505050565b600060e08284031215611db757600080fd5b610f5b8383611c5e565b803560038110611dd057600080fd5b919050565b600080600060608486031215611dea57600080fd5b8335611df581611b55565b9250611e0360208501611dc1565b91506040840135611e1381611bf7565b809150509250925092565b60008060408385031215611e3157600080fd5b8235611e3c81611b55565b9150611e4a60208401611dc1565b90509250929050565b600080600060608486031215611e6857600080fd5b8335611e7381611b55565b92506020840135611e8381611b55565b9150611e9160408501611dc1565b90509250925092565b81516001600160a01b03908116825260208084015160e0840192919081850160005b6003811015611edb578251851682529183019190830190600101611ebc565b505050604085015191506080840160005b6003811015611f0b578351151582529282019290820190600101611eec565b5050505092915050565b634e487b7160e01b600052603260045260246000fd5b60208082526015908201527463616e2774206265207a65726f206164647265737360581b604082015260600190565b634e487b7160e01b600052602160045260246000fd5b600060208284031215611f8257600080fd5b5051919050565b6000815180845260005b81811015611faf57602081850181015186830182015201611f93565b81811115611fc1576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090611ffa90830184611f89565b949350505050565b60006020828403121561201457600080fd5b8151610f5b81611bf7565b6001600160a01b0384811682528316602082015260606040820181905260009061204b90830184611f89565b95945050505050565b60006020828403121561206657600080fd5b8151610f5b81611b55565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea2646970667358221220b9bc3df89eecf428639ba62dabee9cb25456e2d7118fa1429ca77d62dab25bef64736f6c634300080d0033", + "devdoc": { + "author": "Venus", + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "constructor": { + "custom:oz-upgrades-unsafe-allow": "constructor", + "details": "nativeMarketAddress can be address(0) if on the chain we do not support native market (e.g vETH on ethereum would not be supported, only vWETH)", + "params": { + "_boundValidator": "Address of the bound validator contract", + "nativeMarketAddress": "The address of a native market (for bsc it would be vBNB address)", + "vaiAddress": "The address of the VAI token (if there is VAI on the deployed chain). Set to address(0) of VAI is not existent." + } + }, + "enableOracle(address,uint8,bool)": { + "custom:access": "Only Governance", + "custom:error": "NotNullAddress error is thrown if asset address is nullTokenConfigExistance error is thrown if token config is not set", + "details": "Configuration for the asset **must** already exist and the asset cannot be 0 address", + "params": { + "asset": "Asset address", + "enable": "Enabled boolean of the oracle", + "role": "Oracle role" + } + }, + "getOracle(address,uint8)": { + "params": { + "asset": "asset address", + "role": "Oracle role" + }, + "returns": { + "enabled": "Enabled flag of the oracle based on token config", + "oracle": "Oracle address based on role" + } + }, + "getPrice(address)": { + "custom:error": "Paused error is thrown when resilent oracle is pausedInvalid resilient oracle price error is thrown if fetched prices from oracle is invalid", + "params": { + "asset": "asset address" + }, + "returns": { + "_0": "price USD price in scaled decimal places." + } + }, + "getTokenConfig(address)": { + "details": "Gets token config by asset address", + "params": { + "asset": "asset address" + }, + "returns": { + "_0": "tokenConfig Config for the asset" + } + }, + "getUnderlyingPrice(address)": { + "custom:error": "Paused error is thrown when resilent oracle is pausedInvalid resilient oracle price error is thrown if fetched prices from oracle is invalid", + "params": { + "vToken": "vToken address" + }, + "returns": { + "_0": "price USD price in scaled decimal places." + } + }, + "initialize(address)": { + "params": { + "accessControlManager_": "Address of the access control manager contract" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pause()": { + "custom:access": "Only Governance" + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "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." + }, + "setAccessControlManager(address)": { + "custom:access": "Only Governance", + "custom:event": "Emits NewAccessControlManager event", + "details": "Admin function to set address of AccessControlManager", + "params": { + "accessControlManager_": "The new address of the AccessControlManager" + } + }, + "setOracle(address,address,uint8)": { + "custom:access": "Only Governance", + "custom:error": "Null address error if main-role oracle address is nullNotNullAddress error is thrown if asset address is nullTokenConfigExistance error is thrown if token config is not set", + "custom:event": "Emits OracleSet event with asset address, oracle address and role of the oracle for the asset", + "details": "Supplied asset **must** exist and main oracle may not be null", + "params": { + "asset": "Asset address", + "oracle": "Oracle address", + "role": "Oracle role" + } + }, + "setTokenConfig((address,address[3],bool[3]))": { + "custom:access": "Only Governance", + "custom:error": "NotNullAddress is thrown if asset address is nullNotNullAddress is thrown if main-role oracle address for asset is null", + "custom:event": "Emits TokenConfigAdded event when the asset config is set successfully by the authorized account", + "details": "main oracle **must not** be a null address", + "params": { + "tokenConfig": "Token config struct" + } + }, + "setTokenConfigs((address,address[3],bool[3])[])": { + "custom:access": "Only Governance", + "custom:error": "Throws a length error if the length of the token configs array is 0", + "params": { + "tokenConfigs_": "Token config array" + } + }, + "transferOwnership(address)": { + "details": "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." + }, + "unpause()": { + "custom:access": "Only Governance" + }, + "updateAssetPrice(address)": { + "details": "This function should always be called before calling getPrice", + "params": { + "asset": "asset address" + } + }, + "updatePrice(address)": { + "details": "This function should always be called before calling getUnderlyingPrice", + "params": { + "vToken": "vToken address" + } + } + }, + "stateVariables": { + "boundValidator": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "nativeMarket": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "vai": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + } + }, + "title": "ResilientOracle", + "version": 1 + }, + "userdoc": { + "errors": { + "Unauthorized(address,address,string)": [ + { + "notice": "Thrown when the action is prohibited by AccessControlManager" + } + ] + }, + "events": { + "NewAccessControlManager(address,address)": { + "notice": "Emitted when access control manager contract address is changed" + }, + "OracleEnabled(address,uint256,bool)": { + "notice": "Event emitted when an oracle is enabled or disabled" + }, + "OracleSet(address,address,uint256)": { + "notice": "Event emitted when an oracle is set" + } + }, + "kind": "user", + "methods": { + "NATIVE_TOKEN_ADDR()": { + "notice": "Set this as asset address for Native token on each chain.This is the underlying for vBNB (on bsc) and can serve as any underlying asset of a market that supports native tokens" + }, + "accessControlManager()": { + "notice": "Returns the address of the access control manager contract" + }, + "boundValidator()": { + "notice": "Bound validator contract address" + }, + "constructor": { + "notice": "Constructor for the implementation contract. Sets immutable variables." + }, + "enableOracle(address,uint8,bool)": { + "notice": "Enables/ disables oracle for the input asset. Token config for the input asset **must** exist" + }, + "getOracle(address,uint8)": { + "notice": "Gets oracle and enabled status by asset address" + }, + "getPrice(address)": { + "notice": "Gets price of the asset" + }, + "getUnderlyingPrice(address)": { + "notice": "Gets price of the underlying asset for a given vToken. Validation flow: - Check if the oracle is paused globally - Validate price from main oracle against pivot oracle - Validate price from fallback oracle against pivot oracle if the first validation failed - Validate price from main oracle against fallback oracle if the second validation failed In the case that the pivot oracle is not available but main price is available and validation is successful, main oracle price is returned." + }, + "initialize(address)": { + "notice": "Initializes the contract admin and sets the BoundValidator contract address" + }, + "nativeMarket()": { + "notice": "Native market address" + }, + "pause()": { + "notice": "Pauses oracle" + }, + "setAccessControlManager(address)": { + "notice": "Sets the address of AccessControlManager" + }, + "setOracle(address,address,uint8)": { + "notice": "Sets oracle for a given asset and role." + }, + "setTokenConfig((address,address[3],bool[3]))": { + "notice": "Sets/resets single token configs." + }, + "setTokenConfigs((address,address[3],bool[3])[])": { + "notice": "Batch sets token configs" + }, + "unpause()": { + "notice": "Unpauses oracle" + }, + "updateAssetPrice(address)": { + "notice": "Updates the pivot oracle price. Currently using TWAP" + }, + "updatePrice(address)": { + "notice": "Updates the TWAP pivot oracle price." + }, + "vai()": { + "notice": "VAI address" + } + }, + "notice": "The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets. DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly reported prices. If only one oracle is used, this creates a single point of failure and opens a vector for attacking the protocol. The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source. For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every market. The upper bound ratio represents the deviation between reported price (the price that’s being validated) and the anchor price (the price we are validating against) above which the reported price will be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below which the reported price will be invalidated. So for oracle price to be considered valid the below statement should be true: ``` anchorRatio = anchorPrice/reporterPrice isValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio ``` In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the oracle to be stagnant and treat it like it's disabled.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 347, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 350, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1007, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 530, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "_paused", + "offset": 0, + "slot": "51", + "type": "t_bool" + }, + { + "astId": 635, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 219, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "_owner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 339, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 128, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "_pendingOwner", + "offset": 0, + "slot": "151", + "type": "t_address" + }, + { + "astId": 207, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 5079, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "_accessControlManager", + "offset": 0, + "slot": "201", + "type": "t_contract(IAccessControlManagerV8)5264" + }, + { + "astId": 5084, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "__gap", + "offset": 0, + "slot": "202", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 5317, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "tokenConfigs", + "offset": 0, + "slot": "251", + "type": "t_mapping(t_address,t_struct(TokenConfig)5295_storage)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)3_storage": { + "base": "t_address", + "encoding": "inplace", + "label": "address[3]", + "numberOfBytes": "96" + }, + "t_array(t_bool)3_storage": { + "base": "t_bool", + "encoding": "inplace", + "label": "bool[3]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IAccessControlManagerV8)5264": { + "encoding": "inplace", + "label": "contract IAccessControlManagerV8", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_struct(TokenConfig)5295_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct ResilientOracle.TokenConfig)", + "numberOfBytes": "32", + "value": "t_struct(TokenConfig)5295_storage" + }, + "t_struct(TokenConfig)5295_storage": { + "encoding": "inplace", + "label": "struct ResilientOracle.TokenConfig", + "members": [ + { + "astId": 5284, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "asset", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 5289, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "oracles", + "offset": 0, + "slot": "1", + "type": "t_array(t_address)3_storage" + }, + { + "astId": 5294, + "contract": "contracts/ResilientOracle.sol:ResilientOracle", + "label": "enableFlagsForOracles", + "offset": 0, + "slot": "4", + "type": "t_array(t_bool)3_storage" + } + ], + "numberOfBytes": "160" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/bscmainnet/TwapOracle_Proxy.json b/deployments/opbnbmainnet/ResilientOracle_Proxy.json similarity index 94% rename from deployments/bscmainnet/TwapOracle_Proxy.json rename to deployments/opbnbmainnet/ResilientOracle_Proxy.json index 1ca82d76..f5653003 100644 --- a/deployments/bscmainnet/TwapOracle_Proxy.json +++ b/deployments/opbnbmainnet/ResilientOracle_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "abi": [ { "inputs": [ @@ -133,84 +133,84 @@ "type": "receive" } ], - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", "receipt": { "to": null, - "from": "0xa05f990d647287e4E84715b813BC000aEA970467", - "contractAddress": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", - "transactionIndex": 79, - "gasUsed": "696602", - "logsBloom": "0x00000000000000000000000000000000400000000000000000800000400000000000000000000000000000000000000000000000000000000000002000008000000000000000000000008000000002000001000000000100000000000000000000000004020000000000000000000800000000800000000000000000000000400000000000000000000000000008000000000000000080400000000000800000000000400000000000000000000400000000000000808000000000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000000000000000000000000000800000000000000000000000000", - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001", - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", + "from": "0x4a32670436a8A662E75E64B91B3Ab989B8a00064", + "contractAddress": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", + "transactionIndex": 1, + "gasUsed": "700702", + "logsBloom": "0x000000000000000000000000000000004000000000000000008000000000000000000000000000008000000000000001000000000000000000000001000080000020000000000000000000000000020000010000000000040000000000000000400000000200000000000000000008000000008000000000000000000000004000000000000000000000000000000200000000000000a0000000000000800000000000000000000000000000000400000000000000800000000000000000000000000020000000000000000000040000000000000400000100000000000020000000000000000000000000000000000000000800000000000000000000000000", + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8", + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", "logs": [ { - "transactionIndex": 79, - "blockNumber": 28525821, - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "transactionIndex": 1, + "blockNumber": 11141022, + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x00000000000000000000000017d00a8926566cb4b02b25f4ee6ecc2ceb34a784" + "0x000000000000000000000000bc3ee948ba5d78880c6ecb005274257e60d017c8" ], "data": "0x", - "logIndex": 134, - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001" + "logIndex": 0, + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8" }, { - "transactionIndex": 79, - "blockNumber": 28525821, - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "transactionIndex": 1, + "blockNumber": 11141022, + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000a05f990d647287e4e84715b813bc000aea970467" + "0x0000000000000000000000004a32670436a8a662e75e64b91b3ab989b8a00064" ], "data": "0x", - "logIndex": 135, - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001" + "logIndex": 1, + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8" }, { - "transactionIndex": 79, - "blockNumber": 28525821, - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "transactionIndex": 1, + "blockNumber": 11141022, + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000004788629abc6cfca10f9f969efdeaa1cf70c23555", - "logIndex": 136, - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001" + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6", + "logIndex": 2, + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8" }, { - "transactionIndex": 79, - "blockNumber": 28525821, - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "transactionIndex": 1, + "blockNumber": 11141022, + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", - "logIndex": 137, - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001" + "logIndex": 3, + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8" }, { - "transactionIndex": 79, - "blockNumber": 28525821, - "transactionHash": "0x48fe5010c77767718ab00a0a5ac18dfb9406a8b196709989b197fb6478f781a9", - "address": "0xea2f042e1A4f057EF8A5220e57733AD747ea8867", + "transactionIndex": 1, + "blockNumber": 11141022, + "transactionHash": "0x5450c50967c9c7dff8e605e2f35df87c989ae030f924456a67b286642db19907", + "address": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001bb765b741a5f3c2a338369dab539385534e3343", - "logIndex": 138, - "blockHash": "0x71eb6332b355a038b44448f4c5c36b9953b03fe4c612d71b57a0d22f5e9fb001" + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f77bd1d893f67b3eb2cd256239c98ba3f238fb52", + "logIndex": 4, + "blockHash": "0x0a82569731aefbbfe8ad3dc18c03362b3b6a8bec8ec4784e6f9224c17a520ae8" } ], - "blockNumber": 28525821, - "cumulativeGasUsed": "8096175", + "blockNumber": 11141022, + "cumulativeGasUsed": "764691", "status": 1, "byzantium": true }, "args": [ - "0x17D00a8926566CB4b02B25f4EE6ecC2cEB34A784", - "0x1BB765b741A5f3C2A338369DAb539385534E3343", - "0xc4d66de80000000000000000000000004788629abc6cfca10f9f969efdeaa1cf70c23555" + "0xbC3ee948Ba5D78880c6ECb005274257e60d017c8", + "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "0xc4d66de8000000000000000000000000a60deae5344f1152426ca440fb6552ea0e3005d6" ], "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", diff --git a/deployments/opbnbmainnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json b/deployments/opbnbmainnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json new file mode 100644 index 00000000..557e5cb0 --- /dev/null +++ b/deployments/opbnbmainnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json @@ -0,0 +1,78 @@ +{ + "language": "Solidity", + "sources": { + "solc_0.8/openzeppelin/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor (address initialOwner) {\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "solc_0.8/openzeppelin/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n\n constructor (address initialOwner) Ownable(initialOwner) {}\n\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internall call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overriden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view virtual returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(Address.isContract(IBeacon(newBeacon).implementation()), \"ERC1967: beacon implementation is not a contract\");\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "solc_0.8/openzeppelin/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "solc_0.8/openzeppelin/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\n address internal immutable _ADMIN;\n\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _ADMIN = admin_;\n\n // still store it to work with EIP-1967\n bytes32 slot = _ADMIN_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, admin_)\n }\n emit AdminChanged(address(0), admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n\n function _getAdmin() internal view virtual override returns (address) {\n return _ADMIN;\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/utils/UUPSUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is IERC1822Proxiable, ERC1967Upgrade {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n address private immutable __self = address(this);\n\n /**\n * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case\n * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n * fail.\n */\n modifier onlyProxy() {\n require(address(this) != __self, \"Function must be called through delegatecall\");\n require(_getImplementation() == __self, \"Function must be called through active proxy\");\n _;\n }\n\n /**\n * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n * callable on the implementing contract but not through proxies.\n */\n modifier notDelegated() {\n require(address(this) == __self, \"UUPSUpgradeable: must not be called through delegatecall\");\n _;\n }\n\n /**\n * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the\n * implementation. It is used to validate that the this implementation remains valid after an upgrade.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.\n */\n function proxiableUUID() external view virtual override notDelegated returns (bytes32) {\n return _IMPLEMENTATION_SLOT;\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n */\n function upgradeTo(address newImplementation) external virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n * encoded in `data`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n */\n function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, data, true);\n }\n\n /**\n * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n * {upgradeTo} and {upgradeToAndCall}.\n *\n * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n *\n * ```solidity\n * function _authorizeUpgrade(address) internal override onlyOwner {}\n * ```\n */\n function _authorizeUpgrade(address newImplementation) internal virtual;\n}\n" + }, + "solc_0.8/openzeppelin/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() initializer {}\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\n // contract may have been reentered.\n require(_initializing ? _isConstructor() : !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} modifier, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n function _isConstructor() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/beacon/UpgradeableBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n address private _implementation;\n\n /**\n * @dev Emitted when the implementation returned by the beacon is changed.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n * beacon.\n */\n\n constructor(address implementation_, address initialOwner) Ownable(initialOwner) {\n _setImplementation(implementation_);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view virtual override returns (address) {\n return _implementation;\n }\n\n /**\n * @dev Upgrades the beacon to a new implementation.\n *\n * Emits an {Upgraded} event.\n *\n * Requirements:\n *\n * - msg.sender must be the owner of the contract.\n * - `newImplementation` must be a contract.\n */\n function upgradeTo(address newImplementation) public virtual onlyOwner {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Sets the implementation contract address for this beacon\n *\n * Requirements:\n *\n * - `newImplementation` must be a contract.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n _implementation = newImplementation;\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/beacon/BeaconProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/BeaconProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the proxy with `beacon`.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity\n * constructor.\n *\n * Requirements:\n *\n * - `beacon` must be a contract with the interface {IBeacon}.\n */\n constructor(address beacon, bytes memory data) payable {\n assert(_BEACON_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.beacon\")) - 1));\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n\n /**\n * @dev Returns the current beacon address.\n */\n function _beacon() internal view virtual returns (address) {\n return _getBeacon();\n }\n\n /**\n * @dev Returns the current implementation address of the associated beacon.\n */\n function _implementation() internal view virtual override returns (address) {\n return IBeacon(_getBeacon()).implementation();\n }\n\n /**\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n *\n * Requirements:\n *\n * - `beacon` must be a contract.\n * - The implementation returned by `beacon` must be a contract.\n */\n function _setBeacon(address beacon, bytes memory data) internal virtual {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 999999 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} diff --git a/deployments/opbnbmainnet/solcInputs/1e37f6e5d619feb70cefe47611ec524e.json b/deployments/opbnbmainnet/solcInputs/1e37f6e5d619feb70cefe47611ec524e.json new file mode 100644 index 00000000..59a986db --- /dev/null +++ b/deployments/opbnbmainnet/solcInputs/1e37f6e5d619feb70cefe47611ec524e.json @@ -0,0 +1,174 @@ +{ + "language": "Solidity", + "sources": { + "@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorInterface {\n function latestAnswer() external view returns (int256);\n\n function latestTimestamp() external view returns (uint256);\n\n function latestRound() external view returns (uint256);\n\n function getAnswer(uint256 roundId) external view returns (int256);\n\n function getTimestamp(uint256 roundId) external view returns (uint256);\n\n event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);\n\n event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./AggregatorInterface.sol\";\nimport \"./AggregatorV3Interface.sol\";\n\ninterface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface {}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./OwnableUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\n function __Ownable2Step_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable2Step_init_unchained() internal onlyInitializing {\n }\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() public virtual {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(account),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(address from, address to, uint256 amount) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(address owner, address spender, uint256 amount) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/utils/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1, \"Math: mulDiv overflow\");\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/SignedMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toString(int256 value) internal pure returns (string memory) {\n return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value))));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\n\nimport \"./IAccessControlManagerV8.sol\";\n\n/**\n * @title AccessControlledV8\n * @author Venus\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\n */\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\n /// @notice Access control manager contract\n IAccessControlManagerV8 private _accessControlManager;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n\n /// @notice Emitted when access control manager contract address is changed\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\n\n /// @notice Thrown when the action is prohibited by AccessControlManager\n error Unauthorized(address sender, address calledContract, string methodSignature);\n\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\n __Ownable2Step_init();\n __AccessControlled_init_unchained(accessControlManager_);\n }\n\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\n _setAccessControlManager(accessControlManager_);\n }\n\n /**\n * @notice Sets the address of AccessControlManager\n * @dev Admin function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n * @custom:event Emits NewAccessControlManager event\n * @custom:access Only Governance\n */\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\n _setAccessControlManager(accessControlManager_);\n }\n\n /**\n * @notice Returns the address of the access control manager contract\n */\n function accessControlManager() external view returns (IAccessControlManagerV8) {\n return _accessControlManager;\n }\n\n /**\n * @dev Internal function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n */\n function _setAccessControlManager(address accessControlManager_) internal {\n require(address(accessControlManager_) != address(0), \"invalid acess control manager address\");\n address oldAccessControlManager = address(_accessControlManager);\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\n }\n\n /**\n * @notice Reverts if the call is not allowed by AccessControlManager\n * @param signature Method signature\n */\n function _checkAccessAllowed(string memory signature) internal view {\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\n\n if (!isAllowedToCall) {\n revert Unauthorized(msg.sender, address(this), signature);\n }\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"./IAccessControlManagerV8.sol\";\n\n/**\n * @title AccessControlManager\n * @author Venus\n * @dev This contract is a wrapper of OpenZeppelin AccessControl extending it in a way to standartize access control within Venus Smart Contract Ecosystem.\n * @notice Access control plays a crucial role in the Venus governance model. It is used to restrict functions so that they can only be called from one\n * account or list of accounts (EOA or Contract Accounts).\n *\n * The implementation of `AccessControlManager`(https://github.com/VenusProtocol/governance-contracts/blob/main/contracts/Governance/AccessControlManager.sol)\n * inherits the [Open Zeppelin AccessControl](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol)\n * contract as a base for role management logic. There are two role types: admin and granular permissions.\n * \n * ## Granular Roles\n * \n * Granular roles are built by hashing the contract address and its function signature. For example, given contract `Foo` with function `Foo.bar()` which\n * is guarded by ACM, calling `giveRolePermission` for account B do the following:\n * \n * 1. Compute `keccak256(contractFooAddress,functionSignatureBar)`\n * 1. Add the computed role to the roles of account B\n * 1. Account B now can call `ContractFoo.bar()`\n * \n * ## Admin Roles\n * \n * Admin roles allow for an address to call a function signature on any contract guarded by the `AccessControlManager`. This is particularly useful for\n * contracts created by factories.\n * \n * For Admin roles a null address is hashed in place of the contract address (`keccak256(0x0000000000000000000000000000000000000000,functionSignatureBar)`.\n * \n * In the previous example, giving account B the admin role, account B will have permissions to call the `bar()` function on any contract that is guarded by\n * ACM, not only contract A.\n * \n * ## Protocol Integration\n * \n * All restricted functions in Venus Protocol use a hook to ACM in order to check if the caller has the right permission to call the guarded function.\n * `AccessControlledV5` and `AccessControlledV8` abstract contract makes this integration easier. They call ACM's external method\n * `isAllowedToCall(address caller, string functionSig)`. Here is an example of how `setCollateralFactor` function in `Comptroller` is integrated with ACM:\n\n```\n contract Comptroller is [...] AccessControlledV8 {\n [...]\n function setCollateralFactor(VToken vToken, uint256 newCollateralFactorMantissa, uint256 newLiquidationThresholdMantissa) external {\n _checkAccessAllowed(\"setCollateralFactor(address,uint256,uint256)\");\n [...]\n }\n }\n```\n */\ncontract AccessControlManager is AccessControl, IAccessControlManagerV8 {\n /// @notice Emitted when an account is given a permission to a certain contract function\n /// @dev If contract address is 0x000..0 this means that the account is a default admin of this function and\n /// can call any contract function with this signature\n event PermissionGranted(address account, address contractAddress, string functionSig);\n\n /// @notice Emitted when an account is revoked a permission to a certain contract function\n event PermissionRevoked(address account, address contractAddress, string functionSig);\n\n constructor() {\n // Grant the contract deployer the default admin role: it will be able\n // to grant and revoke any roles\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n }\n\n /**\n * @notice Gives a function call permission to one single account\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\n * @param contractAddress address of contract for which call permissions will be granted\n * @dev if contractAddress is zero address, the account can access the specified function\n * on **any** contract managed by this ACL\n * @param functionSig signature e.g. \"functionName(uint256,bool)\"\n * @param accountToPermit account that will be given access to the contract function\n * @custom:event Emits a {RoleGranted} and {PermissionGranted} events.\n */\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) public {\n bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));\n grantRole(role, accountToPermit);\n emit PermissionGranted(accountToPermit, contractAddress, functionSig);\n }\n\n /**\n * @notice Revokes an account's permission to a particular function call\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\n * \t\tMay emit a {RoleRevoked} event.\n * @param contractAddress address of contract for which call permissions will be revoked\n * @param functionSig signature e.g. \"functionName(uint256,bool)\"\n * @custom:event Emits {RoleRevoked} and {PermissionRevoked} events.\n */\n function revokeCallPermission(\n address contractAddress,\n string calldata functionSig,\n address accountToRevoke\n ) public {\n bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));\n revokeRole(role, accountToRevoke);\n emit PermissionRevoked(accountToRevoke, contractAddress, functionSig);\n }\n\n /**\n * @notice Verifies if the given account can call a contract's guarded function\n * @dev Since restricted contracts using this function as a permission hook, we can get contracts address with msg.sender\n * @param account for which call permissions will be checked\n * @param functionSig restricted function signature e.g. \"functionName(uint256,bool)\"\n * @return false if the user account cannot call the particular contract function\n *\n */\n function isAllowedToCall(address account, string calldata functionSig) public view returns (bool) {\n bytes32 role = keccak256(abi.encodePacked(msg.sender, functionSig));\n\n if (hasRole(role, account)) {\n return true;\n } else {\n role = keccak256(abi.encodePacked(address(0), functionSig));\n return hasRole(role, account);\n }\n }\n\n /**\n * @notice Verifies if the given account can call a contract's guarded function\n * @dev This function is used as a view function to check permissions rather than contract hook for access restriction check.\n * @param account for which call permissions will be checked against\n * @param contractAddress address of the restricted contract\n * @param functionSig signature of the restricted function e.g. \"functionName(uint256,bool)\"\n * @return false if the user account cannot call the particular contract function\n */\n function hasPermission(\n address account,\n address contractAddress,\n string calldata functionSig\n ) public view returns (bool) {\n bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));\n return hasRole(role, account);\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/access/IAccessControl.sol\";\n\n/**\n * @title IAccessControlManagerV8\n * @author Venus\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\n */\ninterface IAccessControlManagerV8 is IAccessControl {\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\n\n function revokeCallPermission(\n address contractAddress,\n string calldata functionSig,\n address accountToRevoke\n ) external;\n\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\n\n function hasPermission(\n address account,\n address contractAddress,\n string calldata functionSig\n ) external view returns (bool);\n}\n" + }, + "contracts/interfaces/FeedRegistryInterface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\ninterface FeedRegistryInterface {\n function latestRoundDataByName(\n string memory base,\n string memory quote\n )\n external\n view\n returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);\n\n function decimalsByName(string memory base, string memory quote) external view returns (uint8);\n}\n" + }, + "contracts/interfaces/OracleInterface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\ninterface OracleInterface {\n function getPrice(address asset) external view returns (uint256);\n}\n\ninterface ResilientOracleInterface is OracleInterface {\n function updatePrice(address vToken) external;\n\n function updateAssetPrice(address asset) external;\n\n function getUnderlyingPrice(address vToken) external view returns (uint256);\n}\n\ninterface TwapInterface is OracleInterface {\n function updateTwap(address asset) external returns (uint256);\n}\n\ninterface BoundValidatorInterface {\n function validatePriceWithAnchorPrice(\n address asset,\n uint256 reporterPrice,\n uint256 anchorPrice\n ) external view returns (bool);\n}\n" + }, + "contracts/interfaces/PublicResolverInterface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\ninterface PublicResolverInterface {\n function addr(bytes32 node) external view returns (address payable);\n}\n" + }, + "contracts/interfaces/PythInterface.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\n// SPDX-FileCopyrightText: 2021 Pyth Data Foundation\npragma solidity 0.8.13;\n\ncontract PythStructs {\n // A price with a degree of uncertainty, represented as a price +- a confidence interval.\n //\n // The confidence interval roughly corresponds to the standard error of a normal distribution.\n // Both the price and confidence are stored in a fixed-point numeric representation,\n // `x * (10^expo)`, where `expo` is the exponent.\n //\n // Please refer to the documentation at https://docs.pyth.network/consumers/best-practices for how\n // to how this price safely.\n struct Price {\n // Price\n int64 price;\n // Confidence interval around the price\n uint64 conf;\n // Price exponent\n int32 expo;\n // Unix timestamp describing when the price was published\n uint256 publishTime;\n }\n\n // PriceFeed represents a current aggregate price from pyth publisher feeds.\n struct PriceFeed {\n // The price ID.\n bytes32 id;\n // Latest available price\n Price price;\n // Latest available exponentially-weighted moving average price\n Price emaPrice;\n }\n}\n\n/// @title Consume prices from the Pyth Network (https://pyth.network/).\n/// @dev Please refer to the guidance at https://docs.pyth.network/consumers/best-practices\n/// for how to consume prices safely.\n/// @author Pyth Data Association\ninterface IPyth {\n /// @dev Emitted when an update for price feed with `id` is processed successfully.\n /// @param id The Pyth Price Feed ID.\n /// @param fresh True if the price update is more recent and stored.\n /// @param chainId ID of the source chain that the batch price update containing this price.\n /// This value comes from Wormhole, and you can find the corresponding chains\n /// at https://docs.wormholenetwork.com/wormhole/contracts.\n /// @param sequenceNumber Sequence number of the batch price update containing this price.\n /// @param lastPublishTime Publish time of the previously stored price.\n /// @param publishTime Publish time of the given price update.\n /// @param price Price of the given price update.\n /// @param conf Confidence interval of the given price update.\n event PriceFeedUpdate(\n bytes32 indexed id,\n bool indexed fresh,\n uint16 chainId,\n uint64 sequenceNumber,\n uint256 lastPublishTime,\n uint256 publishTime,\n int64 price,\n uint64 conf\n );\n\n /// @dev Emitted when a batch price update is processed successfully.\n /// @param chainId ID of the source chain that the batch price update comes from.\n /// @param sequenceNumber Sequence number of the batch price update.\n /// @param batchSize Number of prices within the batch price update.\n /// @param freshPricesInBatch Number of prices that were more recent and were stored.\n event BatchPriceFeedUpdate(uint16 chainId, uint64 sequenceNumber, uint256 batchSize, uint256 freshPricesInBatch);\n\n /// @dev Emitted when a call to `updatePriceFeeds` is processed successfully.\n /// @param sender Sender of the call (`msg.sender`).\n /// @param batchCount Number of batches that this function processed.\n /// @param fee Amount of paid fee for updating the prices.\n event UpdatePriceFeeds(address indexed sender, uint256 batchCount, uint256 fee);\n\n /// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time\n function getValidTimePeriod() external view returns (uint256 validTimePeriod);\n\n /// @notice Returns the price and confidence interval.\n /// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds.\n /// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getPrice(bytes32 id) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the exponentially-weighted moving average price and confidence interval.\n /// @dev Reverts if the EMA price is not available.\n /// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getEmaPrice(bytes32 id) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the price of a price feed without any sanity checks.\n /// @dev This function returns the most recent price update in this contract without any recency checks.\n /// This function is unsafe as the returned price update may be arbitrarily far in the past.\n ///\n /// Users of this function should check the `publishTime` in the price to ensure that the returned price is\n /// sufficiently recent for their application. If you are considering using this function, it may be\n /// safer / easier to use either `getPrice` or `getPriceNoOlderThan`.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getPriceUnsafe(bytes32 id) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the price that is no older than `age` seconds of the current time.\n /// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in\n /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently\n /// recently.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getPriceNoOlderThan(bytes32 id, uint256 age) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks.\n /// @dev This function returns the same price as `getEmaPrice` in the case where the price is available.\n /// However, if the price is not recent this function returns the latest available price.\n ///\n /// The returned price can be from arbitrarily far in the past; this function makes no guarantees that\n /// the returned price is recent or useful for any particular application.\n ///\n /// Users of this function should check the `publishTime` in the price to ensure that the returned price is\n /// sufficiently recent for their application. If you are considering using this function, it may be\n /// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getEmaPriceUnsafe(bytes32 id) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds\n /// of the current time.\n /// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in\n /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently\n /// recently.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getEmaPriceNoOlderThan(bytes32 id, uint256 age) external view returns (PythStructs.Price memory price);\n\n /// @notice Update price feeds with given update messages.\n /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling\n /// `getUpdateFee` with the length of the `updateData` array.\n /// Prices will be updated if they are more recent than the current stored prices.\n /// The call will succeed even if the update is not the most recent.\n /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.\n /// @param updateData Array of price update data.\n function updatePriceFeeds(bytes[] calldata updateData) external payable;\n\n /// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is\n /// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the\n /// given `publishTimes` for the price feeds and does not read the actual price\n /// update publish time within `updateData`.\n ///\n /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling\n /// `getUpdateFee` with the length of the `updateData` array.\n ///\n /// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime\n /// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have\n /// a newer or equal publish time than the given publish time, it will reject the transaction to save gas.\n /// Otherwise, it calls updatePriceFeeds method to update the prices.\n ///\n /// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid.\n /// @param updateData Array of price update data.\n /// @param priceIds Array of price ids.\n /// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]`\n function updatePriceFeedsIfNecessary(\n bytes[] calldata updateData,\n bytes32[] calldata priceIds,\n uint64[] calldata publishTimes\n ) external payable;\n\n /// @notice Returns the required fee to update an array of price updates.\n /// @param updateDataSize Number of price updates.\n /// @return feeAmount The required fee in Wei.\n function getUpdateFee(uint256 updateDataSize) external view returns (uint256 feeAmount);\n}\n\nabstract contract AbstractPyth is IPyth {\n /// @notice Returns the price feed with given id.\n /// @dev Reverts if the price does not exist.\n /// @param id The Pyth Price Feed ID of which to fetch the PriceFeed.\n function queryPriceFeed(bytes32 id) public view virtual returns (PythStructs.PriceFeed memory priceFeed);\n\n /// @notice Returns true if a price feed with the given id exists.\n /// @param id The Pyth Price Feed ID of which to check its existence.\n function priceFeedExists(bytes32 id) public view virtual returns (bool exists);\n\n function getValidTimePeriod() public view virtual override returns (uint256 validTimePeriod);\n\n function getPrice(bytes32 id) external view override returns (PythStructs.Price memory price) {\n return getPriceNoOlderThan(id, getValidTimePeriod());\n }\n\n function getEmaPrice(bytes32 id) external view override returns (PythStructs.Price memory price) {\n return getEmaPriceNoOlderThan(id, getValidTimePeriod());\n }\n\n function getPriceUnsafe(bytes32 id) public view override returns (PythStructs.Price memory price) {\n PythStructs.PriceFeed memory priceFeed = queryPriceFeed(id);\n return priceFeed.price;\n }\n\n function getPriceNoOlderThan(\n bytes32 id,\n uint256 age\n ) public view override returns (PythStructs.Price memory price) {\n price = getPriceUnsafe(id);\n\n require(diff(block.timestamp, price.publishTime) <= age, \"no price available which is recent enough\");\n\n return price;\n }\n\n function getEmaPriceUnsafe(bytes32 id) public view override returns (PythStructs.Price memory price) {\n PythStructs.PriceFeed memory priceFeed = queryPriceFeed(id);\n return priceFeed.emaPrice;\n }\n\n function getEmaPriceNoOlderThan(\n bytes32 id,\n uint256 age\n ) public view override returns (PythStructs.Price memory price) {\n price = getEmaPriceUnsafe(id);\n\n require(diff(block.timestamp, price.publishTime) <= age, \"no ema price available which is recent enough\");\n\n return price;\n }\n\n function diff(uint256 x, uint256 y) internal pure returns (uint256) {\n if (x > y) {\n return x - y;\n } else {\n return y - x;\n }\n }\n\n // Access modifier is overridden to public to be able to call it locally.\n function updatePriceFeeds(bytes[] calldata updateData) public payable virtual override;\n\n function updatePriceFeedsIfNecessary(\n bytes[] calldata updateData,\n bytes32[] calldata priceIds,\n uint64[] calldata publishTimes\n ) external payable override {\n require(priceIds.length == publishTimes.length, \"priceIds and publishTimes arrays should have same length\");\n\n bool updateNeeded = false;\n for (uint256 i = 0; i < priceIds.length; ) {\n if (!priceFeedExists(priceIds[i]) || queryPriceFeed(priceIds[i]).price.publishTime < publishTimes[i]) {\n updateNeeded = true;\n break;\n }\n unchecked {\n i++;\n }\n }\n\n require(updateNeeded, \"no prices in the submitted batch have fresh prices, so this update will have no effect\");\n\n updatePriceFeeds(updateData);\n }\n}\n" + }, + "contracts/interfaces/SIDRegistryInterface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\ninterface SIDRegistryInterface {\n function resolver(bytes32 node) external view returns (address);\n}\n" + }, + "contracts/interfaces/VBep20Interface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\ninterface VBep20Interface is IERC20Metadata {\n /**\n * @notice Underlying asset for this VToken\n */\n function underlying() external view returns (address);\n}\n" + }, + "contracts/libraries/PancakeLibrary.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\ninterface IPancakePair {\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n\n function price0CumulativeLast() external view returns (uint256);\n\n function price1CumulativeLast() external view returns (uint256);\n}\n\nlibrary FixedPoint {\n // range: [0, 2**112 - 1]\n // resolution: 1 / 2**112\n struct uq112x112 {\n uint224 _x;\n }\n\n // returns a uq112x112 which represents the ratio of the numerator to the denominator\n // equivalent to encode(numerator).div(denominator)\n function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {\n require(denominator > 0, \"FixedPoint: DIV_BY_ZERO\");\n return uq112x112((uint224(numerator) << 112) / denominator);\n }\n\n // decode a uq112x112 into a uint with 18 decimals of precision\n function decode112with18(uq112x112 memory self) internal pure returns (uint256) {\n // we only have 256 - 224 = 32 bits to spare, so scaling up by ~60 bits is dangerous\n // instead, get close to:\n // (x * 1e18) >> 112\n // without risk of overflowing, e.g.:\n // (x) / 2 ** (112 - lg(1e18))\n return uint256(self._x) / 5192296858534827;\n }\n}\n\n// library with helper methods for oracles that are concerned with computing average prices\nlibrary PancakeOracleLibrary {\n using FixedPoint for *;\n\n // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]\n function currentBlockTimestamp() internal view returns (uint32) {\n return uint32(block.timestamp % 2 ** 32);\n }\n\n // produces the cumulative price using counterfactuals to save gas and avoid a call to sync.\n function currentCumulativePrices(\n address pair\n ) internal view returns (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) {\n blockTimestamp = currentBlockTimestamp();\n price0Cumulative = IPancakePair(pair).price0CumulativeLast();\n price1Cumulative = IPancakePair(pair).price1CumulativeLast();\n\n // if time has elapsed since the last update on the pair, mock the accumulated price values\n (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IPancakePair(pair).getReserves();\n if (blockTimestampLast != blockTimestamp) {\n unchecked {\n // subtraction overflow is desired\n uint32 timeElapsed = blockTimestamp - blockTimestampLast;\n // addition overflow is desired\n // counterfactual\n price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;\n // counterfactual\n price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;\n }\n }\n }\n}\n" + }, + "contracts/oracles/BinanceOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"../interfaces/SIDRegistryInterface.sol\";\nimport \"../interfaces/FeedRegistryInterface.sol\";\nimport \"../interfaces/PublicResolverInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport \"../interfaces/OracleInterface.sol\";\n\n/**\n * @title BinanceOracle\n * @author Venus\n * @notice This oracle fetches price of assets from Binance.\n */\ncontract BinanceOracle is AccessControlledV8, OracleInterface {\n /// @notice Used to fetch feed registry address.\n address public sidRegistryAddress;\n\n /// @notice Set this as asset address for BNB. This is the underlying address for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Max stale period configuration for assets\n mapping(string => uint256) public maxStalePeriod;\n\n /// @notice Override symbols to be compatible with Binance feed registry\n mapping(string => string) public symbols;\n\n /// @notice Used to fetch price of assets used directly when space ID is not supported by current chain.\n address public feedRegistryAddress;\n\n /// @notice Emits when asset stale period is updated.\n event MaxStalePeriodAdded(string indexed asset, uint256 maxStalePeriod);\n\n /// @notice Emits when symbol of the asset is updated.\n event SymbolOverridden(string indexed symbol, string overriddenSymbol);\n\n /// @notice Emits when address of feed registry is updated.\n event FeedRegistryUpdated(address indexed oldFeedRegistry, address indexed newFeedRegistry);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Sets the contracts required to fetch prices\n * @param _sidRegistryAddress Address of SID registry\n * @param _accessControlManager Address of the access control manager contract\n */\n function initialize(address _sidRegistryAddress, address _accessControlManager) external initializer {\n sidRegistryAddress = _sidRegistryAddress;\n __AccessControlled_init(_accessControlManager);\n }\n\n /**\n * @notice Used to set the max stale period of an asset\n * @param symbol The symbol of the asset\n * @param _maxStalePeriod The max stake period\n */\n function setMaxStalePeriod(string memory symbol, uint256 _maxStalePeriod) external {\n _checkAccessAllowed(\"setMaxStalePeriod(string,uint256)\");\n if (_maxStalePeriod == 0) revert(\"stale period can't be zero\");\n if (bytes(symbol).length == 0) revert(\"symbol cannot be empty\");\n\n maxStalePeriod[symbol] = _maxStalePeriod;\n emit MaxStalePeriodAdded(symbol, _maxStalePeriod);\n }\n\n /**\n * @notice Used to override a symbol when fetching price\n * @param symbol The symbol to override\n * @param overrideSymbol The symbol after override\n */\n function setSymbolOverride(string calldata symbol, string calldata overrideSymbol) external {\n _checkAccessAllowed(\"setSymbolOverride(string,string)\");\n if (bytes(symbol).length == 0) revert(\"symbol cannot be empty\");\n\n symbols[symbol] = overrideSymbol;\n emit SymbolOverridden(symbol, overrideSymbol);\n }\n\n /**\n * @notice Used to set feed registry address when current chain does not support space ID.\n * @param newfeedRegistryAddress Address of new feed registry.\n */\n function setFeedRegistryAddress(\n address newfeedRegistryAddress\n ) external notNullAddress(newfeedRegistryAddress) onlyOwner {\n if (sidRegistryAddress != address(0)) revert(\"sidRegistryAddress must be zero\");\n emit FeedRegistryUpdated(feedRegistryAddress, newfeedRegistryAddress);\n feedRegistryAddress = newfeedRegistryAddress;\n }\n\n /**\n * @notice Uses Space ID to fetch the feed registry address\n * @return feedRegistryAddress Address of binance oracle feed registry.\n */\n function getFeedRegistryAddress() public view returns (address) {\n bytes32 nodeHash = 0x94fe3821e0768eb35012484db4df61890f9a6ca5bfa984ef8ff717e73139faff;\n\n SIDRegistryInterface sidRegistry = SIDRegistryInterface(sidRegistryAddress);\n address publicResolverAddress = sidRegistry.resolver(nodeHash);\n PublicResolverInterface publicResolver = PublicResolverInterface(publicResolverAddress);\n\n return publicResolver.addr(nodeHash);\n }\n\n /**\n * @notice Gets the price of a asset from the binance oracle\n * @param asset Address of the asset\n * @return Price in USD\n */\n function getPrice(address asset) public view returns (uint256) {\n string memory symbol;\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n symbol = \"BNB\";\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n symbol = token.symbol();\n decimals = token.decimals();\n }\n\n string memory overrideSymbol = symbols[symbol];\n\n if (bytes(overrideSymbol).length != 0) {\n symbol = overrideSymbol;\n }\n\n return _getPrice(symbol, decimals);\n }\n\n function _getPrice(string memory symbol, uint256 decimals) internal view returns (uint256) {\n FeedRegistryInterface feedRegistry;\n\n if (sidRegistryAddress != address(0)) {\n // If sidRegistryAddress is available, fetch feedRegistryAddress from sidRegistry\n feedRegistry = FeedRegistryInterface(getFeedRegistryAddress());\n } else {\n // Use feedRegistry directly if sidRegistryAddress is not available\n feedRegistry = FeedRegistryInterface(feedRegistryAddress);\n }\n\n (, int256 answer, , uint256 updatedAt, ) = feedRegistry.latestRoundDataByName(symbol, \"USD\");\n if (answer <= 0) revert(\"invalid binance oracle price\");\n if (block.timestamp < updatedAt) revert(\"updatedAt exceeds block time\");\n\n uint256 deltaTime;\n unchecked {\n deltaTime = block.timestamp - updatedAt;\n }\n if (deltaTime > maxStalePeriod[symbol]) revert(\"binance oracle price expired\");\n\n uint256 decimalDelta = feedRegistry.decimalsByName(symbol, \"USD\");\n return (uint256(answer) * (10 ** (18 - decimalDelta))) * (10 ** (18 - decimals));\n }\n}\n" + }, + "contracts/oracles/BoundValidator.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title BoundValidator\n * @author Venus\n * @notice The BoundValidator contract is used to validate prices fetched from two different sources.\n * Each asset has an upper and lower bound ratio set in the config. In order for a price to be valid\n * it must fall within this range of the validator price.\n */\ncontract BoundValidator is AccessControlledV8, BoundValidatorInterface {\n struct ValidateConfig {\n /// @notice asset address\n address asset;\n /// @notice Upper bound of deviation between reported price and anchor price,\n /// beyond which the reported price will be invalidated\n uint256 upperBoundRatio;\n /// @notice Lower bound of deviation between reported price and anchor price,\n /// below which the reported price will be invalidated\n uint256 lowerBoundRatio;\n }\n\n /// @notice validation configs by asset\n mapping(address => ValidateConfig) public validateConfigs;\n\n /// @notice Emit this event when new validation configs are added\n event ValidateConfigAdded(address indexed asset, uint256 indexed upperBound, uint256 indexed lowerBound);\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Add multiple validation configs at the same time\n * @param configs Array of validation configs\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the config array is 0\n * @custom:event Emits ValidateConfigAdded for each validation config that is successfully set\n */\n function setValidateConfigs(ValidateConfig[] memory configs) external {\n uint256 length = configs.length;\n if (length == 0) revert(\"invalid validate config length\");\n for (uint256 i; i < length; ) {\n setValidateConfig(configs[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Add a single validation config\n * @param config Validation config struct\n * @custom:access Only Governance\n * @custom:error Null address error is thrown if asset address is null\n * @custom:error Range error thrown if bound ratio is not positive\n * @custom:error Range error thrown if lower bound is greater than or equal to upper bound\n * @custom:event Emits ValidateConfigAdded when a validation config is successfully set\n */\n function setValidateConfig(ValidateConfig memory config) public {\n _checkAccessAllowed(\"setValidateConfig(ValidateConfig)\");\n\n if (config.asset == address(0)) revert(\"asset can't be zero address\");\n if (config.upperBoundRatio == 0 || config.lowerBoundRatio == 0) revert(\"bound must be positive\");\n if (config.upperBoundRatio <= config.lowerBoundRatio) revert(\"upper bound must be higher than lowner bound\");\n validateConfigs[config.asset] = config;\n emit ValidateConfigAdded(config.asset, config.upperBoundRatio, config.lowerBoundRatio);\n }\n\n /**\n * @notice Test reported asset price against anchor price\n * @param asset asset address\n * @param reportedPrice The price to be tested\n * @custom:error Missing error thrown if asset config is not set\n * @custom:error Price error thrown if anchor price is not valid\n */\n function validatePriceWithAnchorPrice(\n address asset,\n uint256 reportedPrice,\n uint256 anchorPrice\n ) public view virtual override returns (bool) {\n if (validateConfigs[asset].upperBoundRatio == 0) revert(\"validation config not exist\");\n if (anchorPrice == 0) revert(\"anchor price is not valid\");\n return _isWithinAnchor(asset, reportedPrice, anchorPrice);\n }\n\n /**\n * @notice Test whether the reported price is within the valid bounds\n * @param asset Asset address\n * @param reportedPrice The price to be tested\n * @param anchorPrice The reported price must be within the the valid bounds of this price\n */\n function _isWithinAnchor(address asset, uint256 reportedPrice, uint256 anchorPrice) private view returns (bool) {\n if (reportedPrice != 0) {\n // we need to multiply anchorPrice by 1e18 to make the ratio 18 decimals\n uint256 anchorRatio = (anchorPrice * 1e18) / reportedPrice;\n uint256 upperBoundAnchorRatio = validateConfigs[asset].upperBoundRatio;\n uint256 lowerBoundAnchorRatio = validateConfigs[asset].lowerBoundRatio;\n return anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio;\n }\n return false;\n }\n\n // BoundValidator is to get inherited, so it's a good practice to add some storage gaps like\n // OpenZepplin proposed in their contracts: https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n // solhint-disable-next-line\n uint256[49] private __gap;\n}\n" + }, + "contracts/oracles/ChainlinkOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ChainlinkOracle\n * @author Venus\n * @notice This oracle fetches prices of assets from the Chainlink oracle.\n */\ncontract ChainlinkOracle is AccessControlledV8, OracleInterface {\n struct TokenConfig {\n /// @notice Underlying token address, which can't be a null address\n /// @notice Used to check if a token is supported\n /// @notice 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB address for native tokens\n /// (e.g BNB for BNB chain, ETH for Ethereum network)\n address asset;\n /// @notice Chainlink feed address\n address feed;\n /// @notice Price expiration period of this asset\n uint256 maxStalePeriod;\n }\n\n /// @notice Set this as asset address for native token on each chain.\n /// This is the underlying address for vBNB on BNB chain or an underlying asset for a native market on any chain.\n address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Manually set an override price, useful under extenuating conditions such as price feed failure\n mapping(address => uint256) public prices;\n\n /// @notice Token config by assets\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when a price is manually set\n event PricePosted(address indexed asset, uint256 previousPriceMantissa, uint256 newPriceMantissa);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed asset, address feed, uint256 maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Manually set the price of a given asset\n * @param asset Asset address\n * @param price Asset price in 18 decimals\n * @custom:access Only Governance\n * @custom:event Emits PricePosted event on succesfully setup of asset price\n */\n function setDirectPrice(address asset, uint256 price) external notNullAddress(asset) {\n _checkAccessAllowed(\"setDirectPrice(address,uint256)\");\n\n uint256 previousPriceMantissa = prices[asset];\n prices[asset] = price;\n emit PricePosted(asset, previousPriceMantissa, price);\n }\n\n /**\n * @notice Add multiple token configs at the same time\n * @param tokenConfigs_ config array\n * @custom:access Only Governance\n * @custom:error Zero length error thrown, if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Add single token config. asset & feed cannot be null addresses and maxStalePeriod must be positive\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error NotNullAddress error is thrown if token feed address is null\n * @custom:error Range error is thrown if maxStale period of token is not greater than zero\n * @custom:event Emits TokenConfigAdded event on succesfully setting of the token config\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.feed) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n if (tokenConfig.maxStalePeriod == 0) revert(\"stale period can't be zero\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.feed, tokenConfig.maxStalePeriod);\n }\n\n /**\n * @notice Gets the price of a asset from the chainlink oracle\n * @param asset Address of the asset\n * @return Price in USD from Chainlink or a manually set price for the asset\n */\n function getPrice(address asset) public view returns (uint256) {\n uint256 decimals;\n\n if (asset == NATIVE_TOKEN_ADDR) {\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n return _getPriceInternal(asset, decimals);\n }\n\n /**\n * @notice Gets the Chainlink price for a given asset\n * @param asset address of the asset\n * @param decimals decimals of the asset\n * @return price Asset price in USD or a manually set price of the asset\n */\n function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256 price) {\n uint256 tokenPrice = prices[asset];\n if (tokenPrice != 0) {\n price = tokenPrice;\n } else {\n price = _getChainlinkPrice(asset);\n }\n\n uint256 decimalDelta = 18 - decimals;\n return price * (10 ** decimalDelta);\n }\n\n /**\n * @notice Get the Chainlink price for an asset, revert if token config doesn't exist\n * @dev The precision of the price feed is used to ensure the returned price has 18 decimals of precision\n * @param asset Address of the asset\n * @return price Price in USD, with 18 decimals of precision\n * @custom:error NotNullAddress error is thrown if the asset address is null\n * @custom:error Price error is thrown if the Chainlink price of asset is not greater than zero\n * @custom:error Timing error is thrown if current timestamp is less than the last updatedAt timestamp\n * @custom:error Timing error is thrown if time difference between current time and last updated time\n * is greater than maxStalePeriod\n */\n function _getChainlinkPrice(\n address asset\n ) private view notNullAddress(tokenConfigs[asset].asset) returns (uint256) {\n TokenConfig memory tokenConfig = tokenConfigs[asset];\n AggregatorV3Interface feed = AggregatorV3Interface(tokenConfig.feed);\n\n // note: maxStalePeriod cannot be 0\n uint256 maxStalePeriod = tokenConfig.maxStalePeriod;\n\n // Chainlink USD-denominated feeds store answers at 8 decimals, mostly\n uint256 decimalDelta = 18 - feed.decimals();\n\n (, int256 answer, , uint256 updatedAt, ) = feed.latestRoundData();\n if (answer <= 0) revert(\"chainlink price must be positive\");\n if (block.timestamp < updatedAt) revert(\"updatedAt exceeds block time\");\n\n uint256 deltaTime;\n unchecked {\n deltaTime = block.timestamp - updatedAt;\n }\n\n if (deltaTime > maxStalePeriod) revert(\"chainlink price expired\");\n\n return uint256(answer) * (10 ** decimalDelta);\n }\n}\n" + }, + "contracts/oracles/mocks/MockBinanceFeedRegistry.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"../../interfaces/FeedRegistryInterface.sol\";\n\ncontract MockBinanceFeedRegistry is FeedRegistryInterface {\n mapping(string => uint256) public assetPrices;\n\n function setAssetPrice(string memory base, uint256 price) external {\n assetPrices[base] = price;\n }\n\n function latestRoundDataByName(\n string memory base,\n string memory quote\n )\n external\n view\n override\n returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)\n {\n quote;\n return (0, int256(assetPrices[base]), 0, block.timestamp - 10, 0);\n }\n\n function decimalsByName(string memory base, string memory quote) external view override returns (uint8) {\n return 8;\n }\n}\n" + }, + "contracts/oracles/mocks/MockBinanceOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockBinanceOracle is OwnableUpgradeable, OracleInterface {\n mapping(address => uint256) public assetPrices;\n\n constructor() {}\n\n function initialize() public initializer {}\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" + }, + "contracts/oracles/mocks/MockChainlinkOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockChainlinkOracle is OwnableUpgradeable, OracleInterface {\n mapping(address => uint256) public assetPrices;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize() public initializer {\n __Ownable_init();\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" + }, + "contracts/oracles/mocks/MockPythOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { IPyth } from \"../PythOracle.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockPythOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice the actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize(address underlyingPythOracle_) public initializer {\n __Ownable_init();\n if (underlyingPythOracle_ == address(0)) revert(\"pyth oracle cannot be zero address\");\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" + }, + "contracts/oracles/PythOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"../interfaces/PythInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title PythOracle\n * @author Venus\n * @notice PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores\n * the updated prices from external sources\n */\ncontract PythOracle is AccessControlledV8, OracleInterface {\n // To calculate 10 ** n(which is a signed type)\n using SignedMath for int256;\n\n // To cast int64/int8 types from Pyth to unsigned types\n using SafeCast for int256;\n\n struct TokenConfig {\n bytes32 pythId;\n address asset;\n uint64 maxStalePeriod;\n }\n\n /// @notice Exponent scale (decimal precision) of prices\n uint256 public constant EXP_SCALE = 1e18;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice The actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n /// @notice Token configs by asset address\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when setting a new pyth oracle address\n event PythOracleSet(address indexed oldPythOracle, address indexed newPythOracle);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed asset, bytes32 indexed pythId, uint64 indexed maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract and sets required contracts\n * @param underlyingPythOracle_ Address of the Pyth oracle\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(\n address underlyingPythOracle_,\n address accessControlManager_\n ) external initializer notNullAddress(underlyingPythOracle_) {\n __AccessControlled_init(accessControlManager_);\n\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n emit PythOracleSet(address(0), underlyingPythOracle_);\n }\n\n /**\n * @notice Batch set token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the underlying Pyth oracle contract address\n * @param underlyingPythOracle_ Pyth oracle contract address\n * @custom:access Only Governance\n * @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero\n * @custom:event Emits PythOracleSet event with address of Pyth oracle.\n */\n function setUnderlyingPythOracle(\n IPyth underlyingPythOracle_\n ) external notNullAddress(address(underlyingPythOracle_)) {\n _checkAccessAllowed(\"setUnderlyingPythOracle(address)\");\n IPyth oldUnderlyingPythOracle = underlyingPythOracle;\n underlyingPythOracle = underlyingPythOracle_;\n emit PythOracleSet(address(oldUnderlyingPythOracle), address(underlyingPythOracle_));\n }\n\n /**\n * @notice Set single token config. `maxStalePeriod` cannot be 0 and `asset` cannot be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if max stale period is zero\n * @custom:error NotNullAddress error is thrown if asset address is null\n */\n function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n if (tokenConfig.maxStalePeriod == 0) revert(\"max stale period cannot be 0\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);\n }\n\n /**\n * @notice Gets the price of a asset from the pyth oracle\n * @param asset Address of the asset\n * @return Price in USD\n */\n function getPrice(address asset) public view returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n return _getPriceInternal(asset, decimals);\n }\n\n function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256) {\n TokenConfig storage tokenConfig = tokenConfigs[asset];\n if (tokenConfig.asset == address(0)) revert(\"asset doesn't exist\");\n\n // if the price is expired after it's compared against `maxStalePeriod`, the following call will revert\n PythStructs.Price memory priceInfo = underlyingPythOracle.getPriceNoOlderThan(\n tokenConfig.pythId,\n tokenConfig.maxStalePeriod\n );\n\n uint256 price = int256(priceInfo.price).toUint256();\n\n if (price == 0) revert(\"invalid pyth oracle price\");\n\n // the price returned from Pyth is price ** 10^expo, which is the real dollar price of the assets\n // we need to multiply it by 1e18 to make the price 18 decimals\n if (priceInfo.expo > 0) {\n return price * EXP_SCALE * (10 ** int256(priceInfo.expo).toUint256()) * (10 ** (18 - decimals));\n } else {\n return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));\n }\n }\n}\n" + }, + "contracts/ResilientOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ResilientOracle\n * @author Venus\n * @notice The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets.\n * \n * DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly\n * reported prices. If only one oracle is used, this creates a single point of failure and opens a vector\n * for attacking the protocol.\n * \n * The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect\n * the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle\n * and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.\n * \n * For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per \n * vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot \n * oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. \n * \n * To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every\n * market. The upper bound ratio represents the deviation between reported price (the price that’s being\n * validated) and the anchor price (the price we are validating against) above which the reported price will\n * be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below\n * which the reported price will be invalidated. So for oracle price to be considered valid the below statement\n * should be true:\n\n```\nanchorRatio = anchorPrice/reporterPrice\nisValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio\n```\n\n * In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending\n * on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may\n * use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. \n * \n * For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the\n * oracle to be stagnant and treat it like it's disabled.\n */\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n /**\n * @dev Oracle roles:\n * **main**: The most trustworthy price source\n * **pivot**: Price oracle used as a loose sanity checker\n * **fallback**: The backup source when main oracle price is invalidated\n */\n enum OracleRole {\n MAIN,\n PIVOT,\n FALLBACK\n }\n\n struct TokenConfig {\n /// @notice asset address\n address asset;\n /// @notice `oracles` stores the oracles based on their role in the following order:\n /// [main, pivot, fallback],\n /// It can be indexed with the corresponding enum OracleRole value\n address[3] oracles;\n /// @notice `enableFlagsForOracles` stores the enabled state\n /// for each oracle in the same order as `oracles`\n bool[3] enableFlagsForOracles;\n }\n\n uint256 public constant INVALID_PRICE = 0;\n\n /// @notice Native market address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable nativeMarket;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for Native token on each chain.This is the underlying for vBNB (on bsc)\n /// and can serve as any underlying asset of a market that supports native tokens\n address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Bound validator contract address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n BoundValidatorInterface public immutable boundValidator;\n\n mapping(address => TokenConfig) private tokenConfigs;\n\n event TokenConfigAdded(\n address indexed asset,\n address indexed mainOracle,\n address indexed pivotOracle,\n address fallbackOracle\n );\n\n /// Event emitted when an oracle is set\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n /// Event emitted when an oracle is enabled or disabled\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /**\n * @notice Checks whether token config exists by checking whether asset is null address\n * @dev address can't be null, so it's suitable to be used to check the validity of the config\n * @param asset asset address\n */\n modifier checkTokenConfigExistence(address asset) {\n if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @dev nativeMarketAddress can be address(0) if on the chain we do not support native market\n /// (e.g vETH on ethereum would not be supported, only vWETH)\n /// @param nativeMarketAddress The address of a native market (for bsc it would be vBNB address)\n /// @param vaiAddress The address of the VAI token (if there is VAI on the deployed chain).\n /// Set to address(0) of VAI is not existent.\n /// @param _boundValidator Address of the bound validator contract\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address nativeMarketAddress,\n address vaiAddress,\n BoundValidatorInterface _boundValidator\n ) notNullAddress(address(_boundValidator)) {\n nativeMarket = nativeMarketAddress;\n vai = vaiAddress;\n boundValidator = _boundValidator;\n\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract admin and sets the BoundValidator contract address\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n }\n\n /**\n * @notice Pauses oracle\n * @custom:access Only Governance\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n _pause();\n }\n\n /**\n * @notice Unpauses oracle\n * @custom:access Only Governance\n */\n function unpause() external {\n _checkAccessAllowed(\"unpause()\");\n _unpause();\n }\n\n /**\n * @notice Batch sets token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Throws a length error if the length of the token configs array is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Sets oracle for a given asset and role.\n * @dev Supplied asset **must** exist and main oracle may not be null\n * @param asset Asset address\n * @param oracle Oracle address\n * @param role Oracle role\n * @custom:access Only Governance\n * @custom:error Null address error if main-role oracle address is null\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n */\n function setOracle(\n address asset,\n address oracle,\n OracleRole role\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\n emit OracleSet(asset, oracle, uint256(role));\n }\n\n /**\n * @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\n * @dev Configuration for the asset **must** already exist and the asset cannot be 0 address\n * @param asset Asset address\n * @param role Oracle role\n * @param enable Enabled boolean of the oracle\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n */\n function enableOracle(\n address asset,\n OracleRole role,\n bool enable\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n emit OracleEnabled(asset, uint256(role), enable);\n }\n\n /**\n * @notice Updates the TWAP pivot oracle price.\n * @dev This function should always be called before calling getUnderlyingPrice\n * @param vToken vToken address\n */\n function updatePrice(address vToken) external override {\n address asset = _getUnderlyingAsset(vToken);\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @notice Updates the pivot oracle price. Currently using TWAP\n * @dev This function should always be called before calling getPrice\n * @param asset asset address\n */\n function updateAssetPrice(address asset) external {\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @dev Gets token config by asset address\n * @param asset asset address\n * @return tokenConfig Config for the asset\n */\n function getTokenConfig(address asset) external view returns (TokenConfig memory) {\n return tokenConfigs[asset];\n }\n\n /**\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n * - Check if the oracle is paused globally\n * - Validate price from main oracle against pivot oracle\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\n * - Validate price from main oracle against fallback oracle if the second validation failed\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\n * main oracle price is returned.\n * @param vToken vToken address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n\n address asset = _getUnderlyingAsset(vToken);\n return _getPrice(asset);\n }\n\n /**\n * @notice Gets price of the asset\n * @param asset asset address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getPrice(address asset) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n return _getPrice(asset);\n }\n\n /**\n * @notice Sets/resets single token configs.\n * @dev main oracle **must not** be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress is thrown if asset address is null\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n * @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(\n tokenConfig.asset,\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n );\n }\n\n /**\n * @notice Gets oracle and enabled status by asset address\n * @param asset asset address\n * @param role Oracle role\n * @return oracle Oracle address based on role\n * @return enabled Enabled flag of the oracle based on token config\n */\n function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {\n oracle = tokenConfigs[asset].oracles[uint256(role)];\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n }\n\n function _getPrice(address asset) internal view returns (uint256) {\n uint256 pivotPrice = INVALID_PRICE;\n\n // Get pivot oracle price, Invalid price if not available or error\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracleEnabled && pivotOracle != address(0)) {\n try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {\n pivotPrice = pricePivot;\n } catch {}\n }\n\n // Compare main price and pivot price, return main price and if validation was successful\n // note: In case pivot oracle is not available but main price is available and\n // validation is successful, the main oracle price is returned.\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n asset,\n pivotPrice,\n pivotOracleEnabled && pivotOracle != address(0)\n );\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n // Compare fallback and pivot if main oracle comparision fails with pivot\n // Return fallback price when fallback price is validated successfully with pivot oracle\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n // Lastly compare main price and fallback price\n if (\n mainPrice != INVALID_PRICE &&\n fallbackPrice != INVALID_PRICE &&\n boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)\n ) {\n return mainPrice;\n }\n\n revert(\"invalid resilient oracle price\");\n }\n\n /**\n * @notice Gets a price for the provided asset\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\n * able to fetch a correct price\n * @param asset asset address\n * @param pivotPrice Pivot oracle price\n * @param pivotEnabled If pivot oracle is not empty and enabled\n * @return price USD price in scaled decimals\n * e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n * @return pivotValidated Boolean representing if the validation of main oracle price\n * and pivot oracle price were successful\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n * address is null\n */\n function _getMainOraclePrice(\n address asset,\n uint256 pivotPrice,\n bool pivotEnabled\n ) internal view returns (uint256, bool) {\n (address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);\n if (mainOracleEnabled && mainOracle != address(0)) {\n try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {\n if (!pivotEnabled) {\n return (mainOraclePrice, true);\n }\n if (pivotPrice == INVALID_PRICE) {\n return (mainOraclePrice, false);\n }\n return (\n mainOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function won't revert when the price is 0 because getPrice checks if price is > 0\n * @param asset asset address\n * @return price USD price in 18 decimals\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\n * and pivot oracle price were successfull\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n * address is null\n */\n function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {\n (address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);\n if (fallbackEnabled && fallbackOracle != address(0)) {\n try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {\n if (pivotPrice == INVALID_PRICE) {\n return (fallbackOraclePrice, false);\n }\n return (\n fallbackOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view notNullAddress(vToken) returns (address asset) {\n if (vToken == nativeMarket) {\n asset = NATIVE_TOKEN_ADDR;\n } else if (vToken == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" + }, + "contracts/test/AccessControlManager.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol\";\n\ncontract AccessControlManagerScenario is AccessControlManager {}\n" + }, + "contracts/test/BEP20Harness.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract BEP20Harness is ERC20 {\n uint8 public decimalsInternal = 18;\n\n constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) {\n decimalsInternal = decimals_;\n }\n\n function faucet(uint256 amount) external {\n _mint(msg.sender, amount);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return decimalsInternal;\n }\n}\n" + }, + "contracts/test/MockPyth.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"../interfaces/PythInterface.sol\";\n\ncontract MockPyth is AbstractPyth {\n mapping(bytes32 => PythStructs.PriceFeed) priceFeeds;\n uint64 sequenceNumber;\n\n uint256 singleUpdateFeeInWei;\n uint256 validTimePeriod;\n\n constructor(uint256 _validTimePeriod, uint256 _singleUpdateFeeInWei) {\n singleUpdateFeeInWei = _singleUpdateFeeInWei;\n validTimePeriod = _validTimePeriod;\n }\n\n // simply update price feeds\n function updatePriceFeedsHarness(PythStructs.PriceFeed[] calldata feeds) external {\n require(feeds.length > 0, \"feeds length must > 0\");\n for (uint256 i = 0; i < feeds.length; ) {\n priceFeeds[feeds[i].id] = feeds[i];\n unchecked {\n ++i;\n }\n }\n }\n\n // Takes an array of encoded price feeds and stores them.\n // You can create this data either by calling createPriceFeedData or\n // by using web3.js or ethers abi utilities.\n function updatePriceFeeds(bytes[] calldata updateData) public payable override {\n uint256 requiredFee = getUpdateFee(updateData.length);\n require(msg.value >= requiredFee, \"Insufficient paid fee amount\");\n\n if (msg.value > requiredFee) {\n (bool success, ) = payable(msg.sender).call{ value: msg.value - requiredFee }(\"\");\n require(success, \"failed to transfer update fee\");\n }\n\n uint256 freshPrices = 0;\n\n // Chain ID is id of the source chain that the price update comes from. Since it is just a mock contract\n // We set it to 1.\n uint16 chainId = 1;\n\n for (uint256 i = 0; i < updateData.length; ) {\n PythStructs.PriceFeed memory priceFeed = abi.decode(updateData[i], (PythStructs.PriceFeed));\n\n bool fresh = false;\n uint256 lastPublishTime = priceFeeds[priceFeed.id].price.publishTime;\n\n if (lastPublishTime < priceFeed.price.publishTime) {\n // Price information is more recent than the existing price information.\n fresh = true;\n priceFeeds[priceFeed.id] = priceFeed;\n freshPrices += 1;\n }\n\n emit PriceFeedUpdate(\n priceFeed.id,\n fresh,\n chainId,\n sequenceNumber,\n priceFeed.price.publishTime,\n lastPublishTime,\n priceFeed.price.price,\n priceFeed.price.conf\n );\n\n unchecked {\n i++;\n }\n }\n\n // In the real contract, the input of this function contains multiple batches that each contain multiple prices.\n // This event is emitted when a batch is processed. In this mock contract we consider\n // there is only one batch of prices.\n // Each batch has (chainId, sequenceNumber) as it's unique identifier. Here chainId\n // is set to 1 and an increasing sequence number is used.\n emit BatchPriceFeedUpdate(chainId, sequenceNumber, updateData.length, freshPrices);\n sequenceNumber += 1;\n\n // There is only 1 batch of prices\n emit UpdatePriceFeeds(msg.sender, 1, requiredFee);\n }\n\n function queryPriceFeed(bytes32 id) public view override returns (PythStructs.PriceFeed memory priceFeed) {\n require(priceFeeds[id].id != 0, \"no price feed found for the given price id\");\n return priceFeeds[id];\n }\n\n function priceFeedExists(bytes32 id) public view override returns (bool) {\n return (priceFeeds[id].id != 0);\n }\n\n function getValidTimePeriod() public view override returns (uint256) {\n return validTimePeriod;\n }\n\n function getUpdateFee(uint256 updateDataSize) public view override returns (uint256 feeAmount) {\n return singleUpdateFeeInWei * updateDataSize;\n }\n\n function createPriceFeedUpdateData(\n bytes32 id,\n int64 price,\n uint64 conf,\n int32 expo,\n int64 emaPrice,\n uint64 emaConf,\n uint64 publishTime\n ) public pure returns (bytes memory priceFeedData) {\n PythStructs.PriceFeed memory priceFeed;\n\n priceFeed.id = id;\n\n priceFeed.price.price = price;\n priceFeed.price.conf = conf;\n priceFeed.price.expo = expo;\n priceFeed.price.publishTime = publishTime;\n\n priceFeed.emaPrice.price = emaPrice;\n priceFeed.emaPrice.conf = emaConf;\n priceFeed.emaPrice.expo = expo;\n priceFeed.emaPrice.publishTime = publishTime;\n\n priceFeedData = abi.encode(priceFeed);\n }\n}\n" + }, + "contracts/test/MockSimpleOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"../interfaces/OracleInterface.sol\";\n\ncontract MockSimpleOracle is OracleInterface {\n mapping(address => uint256) public prices;\n\n constructor() {\n //\n }\n\n function getUnderlyingPrice(address vToken) external view returns (uint256) {\n return prices[vToken];\n }\n\n function getPrice(address asset) external view returns (uint256) {\n return prices[asset];\n }\n\n function setPrice(address vToken, uint256 price) public {\n prices[vToken] = price;\n }\n}\n\ncontract MockBoundValidator is BoundValidatorInterface {\n mapping(address => bool) public validateResults;\n bool public twapUpdated;\n\n constructor() {\n //\n }\n\n function validatePriceWithAnchorPrice(\n address vToken,\n uint256 reporterPrice,\n uint256 anchorPrice\n ) external view returns (bool) {\n return validateResults[vToken];\n }\n\n function validateAssetPriceWithAnchorPrice(\n address asset,\n uint256 reporterPrice,\n uint256 anchorPrice\n ) external view returns (bool) {\n return validateResults[asset];\n }\n\n function setValidateResult(address token, bool pass) public {\n validateResults[token] = pass;\n }\n}\n" + }, + "contracts/test/MockV3Aggregator.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol\";\n\n/**\n * @title MockV3Aggregator\n * @notice Based on the FluxAggregator contract\n * @notice Use this contract when you need to test\n * other contract's ability to read data from an\n * aggregator contract, but how the aggregator got\n * its answer is unimportant\n */\ncontract MockV3Aggregator is AggregatorV2V3Interface {\n uint256 public constant version = 0;\n\n uint8 public decimals;\n int256 public latestAnswer;\n uint256 public latestTimestamp;\n uint256 public latestRound;\n\n mapping(uint256 => int256) public getAnswer;\n mapping(uint256 => uint256) public getTimestamp;\n mapping(uint256 => uint256) private getStartedAt;\n\n constructor(uint8 _decimals, int256 _initialAnswer) {\n decimals = _decimals;\n updateAnswer(_initialAnswer);\n }\n\n function getRoundData(\n uint80 _roundId\n )\n external\n view\n returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)\n {\n return (_roundId, getAnswer[_roundId], getStartedAt[_roundId], getTimestamp[_roundId], _roundId);\n }\n\n function latestRoundData()\n external\n view\n returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)\n {\n return (\n uint80(latestRound),\n getAnswer[latestRound],\n getStartedAt[latestRound],\n getTimestamp[latestRound],\n uint80(latestRound)\n );\n }\n\n function description() external pure returns (string memory) {\n return \"v0.6/tests/MockV3Aggregator.sol\";\n }\n\n function updateAnswer(int256 _answer) public {\n latestAnswer = _answer;\n latestTimestamp = block.timestamp;\n latestRound++;\n getAnswer[latestRound] = _answer;\n getTimestamp[latestRound] = block.timestamp;\n getStartedAt[latestRound] = block.timestamp;\n }\n\n function updateRoundData(uint80 _roundId, int256 _answer, uint256 _timestamp, uint256 _startedAt) public {\n latestRound = _roundId;\n latestAnswer = _answer;\n latestTimestamp = _timestamp;\n getAnswer[latestRound] = _answer;\n getTimestamp[latestRound] = _timestamp;\n getStartedAt[latestRound] = _startedAt;\n }\n}\n" + }, + "contracts/test/PancakePairHarness.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\n// a library for performing various math operations\n\nlibrary Math {\n function min(uint256 x, uint256 y) internal pure returns (uint256 z) {\n z = x < y ? x : y;\n }\n\n // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)\n function sqrt(uint256 y) internal pure returns (uint256 z) {\n if (y > 3) {\n z = y;\n uint256 x = y / 2 + 1;\n while (x < z) {\n z = x;\n x = (y / x + x) / 2;\n }\n } else if (y != 0) {\n z = 1;\n }\n }\n}\n\n// range: [0, 2**112 - 1]\n// resolution: 1 / 2**112\n\nlibrary UQ112x112 {\n //solhint-disable-next-line state-visibility\n uint224 constant Q112 = 2 ** 112;\n\n // encode a uint112 as a UQ112x112\n function encode(uint112 y) internal pure returns (uint224 z) {\n z = uint224(y) * Q112; // never overflows\n }\n\n // divide a UQ112x112 by a uint112, returning a UQ112x112\n function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {\n z = x / uint224(y);\n }\n}\n\ncontract PancakePairHarness {\n using UQ112x112 for uint224;\n\n address public token0;\n address public token1;\n\n uint112 private reserve0; // uses single storage slot, accessible via getReserves\n uint112 private reserve1; // uses single storage slot, accessible via getReserves\n uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves\n\n uint256 public price0CumulativeLast;\n uint256 public price1CumulativeLast;\n uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event\n\n // called once by the factory at time of deployment\n function initialize(address _token0, address _token1) external {\n token0 = _token0;\n token1 = _token1;\n }\n\n // update reserves and, on the first call per block, price accumulators\n function update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) external {\n require(balance0 <= type(uint112).max && balance1 <= type(uint112).max, \"PancakeV2: OVERFLOW\");\n uint32 blockTimestamp = uint32(block.timestamp % 2 ** 32);\n unchecked {\n uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired\n if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {\n // * never overflows, and + overflow is desired\n price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;\n price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;\n }\n }\n reserve0 = uint112(balance0);\n reserve1 = uint112(balance1);\n blockTimestampLast = blockTimestamp;\n }\n\n function currentBlockTimestamp() external view returns (uint32) {\n return uint32(block.timestamp % 2 ** 32);\n }\n\n function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {\n _reserve0 = reserve0;\n _reserve1 = reserve1;\n _blockTimestampLast = blockTimestampLast;\n }\n}\n" + }, + "contracts/test/VBEP20Harness.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"./BEP20Harness.sol\";\n\ncontract VBEP20Harness is BEP20Harness {\n /**\n * @notice Underlying asset for this VToken\n */\n address public underlying;\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals,\n address underlying_\n ) BEP20Harness(name_, symbol_, decimals) {\n underlying = underlying_;\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200, + "details": { + "yul": true + } + }, + "outputSelection": { + "*": { + "*": [ + "storageLayout", + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} diff --git a/deployments/opbnbmainnet_addresses.json b/deployments/opbnbmainnet_addresses.json index cf3419c4..fdb9c143 100644 --- a/deployments/opbnbmainnet_addresses.json +++ b/deployments/opbnbmainnet_addresses.json @@ -1,5 +1,16 @@ { "name": "opbnbmainnet", "chainId": "204", - "addresses": {} + "addresses": { + "BinanceOracle": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "BinanceOracle_Implementation": "0x7B9BFF3AEbAcE3715660e6340370810f10481b53", + "BinanceOracle_Proxy": "0xB09EC9B628d04E1287216Aa3e2432291f50F9588", + "BoundValidator": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "BoundValidator_Implementation": "0x47C33167d13eD2374161A6f0A9b55fc4cad09897", + "BoundValidator_Proxy": "0xd1f80C371C6E2Fa395A5574DB3E3b4dAf43dadCE", + "DefaultProxyAdmin": "0xF77bD1D893F67b3EB2Cd256239c98Ba3F238fb52", + "ResilientOracle": "0x8f3618c4F0183e14A218782c116fb2438571dAC9", + "ResilientOracle_Implementation": "0xbC3ee948Ba5D78880c6ECb005274257e60d017c8", + "ResilientOracle_Proxy": "0x8f3618c4F0183e14A218782c116fb2438571dAC9" + } } diff --git a/deployments/opbnbtestnet/solcInputs/3c996a10e894dc6fe519573ed39fc60f.json b/deployments/opbnbtestnet/solcInputs/3c996a10e894dc6fe519573ed39fc60f.json index b4b5e1de..5b26ef7a 100644 --- a/deployments/opbnbtestnet/solcInputs/3c996a10e894dc6fe519573ed39fc60f.json +++ b/deployments/opbnbtestnet/solcInputs/3c996a10e894dc6fe519573ed39fc60f.json @@ -115,15 +115,9 @@ "contracts/oracles/mocks/MockPythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { IPyth } from \"../PythOracle.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockPythOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice the actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize(address underlyingPythOracle_) public initializer {\n __Ownable_init();\n if (underlyingPythOracle_ == address(0)) revert(\"pyth oracle cannot be zero address\");\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" }, - "contracts/oracles/mocks/MockTwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockTwapOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice vBNB address\n address public vBNB;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize(address vBNB_) public initializer {\n __Ownable_init();\n if (vBNB_ == address(0)) revert(\"vBNB can't be zero address\");\n vBNB = vBNB_;\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" - }, "contracts/oracles/PythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"../interfaces/PythInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title PythOracle\n * @author Venus\n * @notice PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores\n * the updated prices from external sources\n */\ncontract PythOracle is AccessControlledV8, OracleInterface {\n // To calculate 10 ** n(which is a signed type)\n using SignedMath for int256;\n\n // To cast int64/int8 types from Pyth to unsigned types\n using SafeCast for int256;\n\n struct TokenConfig {\n bytes32 pythId;\n address asset;\n uint64 maxStalePeriod;\n }\n\n /// @notice Exponent scale (decimal precision) of prices\n uint256 public constant EXP_SCALE = 1e18;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice The actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n /// @notice Token configs by asset address\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when setting a new pyth oracle address\n event PythOracleSet(address indexed oldPythOracle, address indexed newPythOracle);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed asset, bytes32 indexed pythId, uint64 indexed maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract and sets required contracts\n * @param underlyingPythOracle_ Address of the Pyth oracle\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(\n address underlyingPythOracle_,\n address accessControlManager_\n ) external initializer notNullAddress(underlyingPythOracle_) {\n __AccessControlled_init(accessControlManager_);\n\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n emit PythOracleSet(address(0), underlyingPythOracle_);\n }\n\n /**\n * @notice Batch set token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the underlying Pyth oracle contract address\n * @param underlyingPythOracle_ Pyth oracle contract address\n * @custom:access Only Governance\n * @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero\n * @custom:event Emits PythOracleSet event with address of Pyth oracle.\n */\n function setUnderlyingPythOracle(\n IPyth underlyingPythOracle_\n ) external notNullAddress(address(underlyingPythOracle_)) {\n _checkAccessAllowed(\"setUnderlyingPythOracle(address)\");\n IPyth oldUnderlyingPythOracle = underlyingPythOracle;\n underlyingPythOracle = underlyingPythOracle_;\n emit PythOracleSet(address(oldUnderlyingPythOracle), address(underlyingPythOracle_));\n }\n\n /**\n * @notice Set single token config. `maxStalePeriod` cannot be 0 and `asset` cannot be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if max stale period is zero\n * @custom:error NotNullAddress error is thrown if asset address is null\n */\n function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n if (tokenConfig.maxStalePeriod == 0) revert(\"max stale period cannot be 0\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);\n }\n\n /**\n * @notice Gets the price of a asset from the pyth oracle\n * @param asset Address of the asset\n * @return Price in USD\n */\n function getPrice(address asset) public view returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n return _getPriceInternal(asset, decimals);\n }\n\n function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256) {\n TokenConfig storage tokenConfig = tokenConfigs[asset];\n if (tokenConfig.asset == address(0)) revert(\"asset doesn't exist\");\n\n // if the price is expired after it's compared against `maxStalePeriod`, the following call will revert\n PythStructs.Price memory priceInfo = underlyingPythOracle.getPriceNoOlderThan(\n tokenConfig.pythId,\n tokenConfig.maxStalePeriod\n );\n\n uint256 price = int256(priceInfo.price).toUint256();\n\n if (price == 0) revert(\"invalid pyth oracle price\");\n\n // the price returned from Pyth is price ** 10^expo, which is the real dollar price of the assets\n // we need to multiply it by 1e18 to make the price 18 decimals\n if (priceInfo.expo > 0) {\n return price * EXP_SCALE * (10 ** int256(priceInfo.expo).toUint256()) * (10 ** (18 - decimals));\n } else {\n return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));\n }\n }\n}\n" }, - "contracts/oracles/TwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../libraries/PancakeLibrary.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title TwapOracle\n * @author Venus\n * @notice This oracle fetches price of assets from PancakeSwap.\n */\ncontract TwapOracle is AccessControlledV8, TwapInterface {\n using FixedPoint for *;\n\n struct Observation {\n uint256 timestamp;\n uint256 acc;\n }\n\n struct TokenConfig {\n /// @notice Asset address, which can't be zero address and can be used for existance check\n address asset;\n /// @notice Decimals of asset represented as 1e{decimals}\n uint256 baseUnit;\n /// @notice The address of Pancake pair\n address pancakePool;\n /// @notice Whether the token is paired with WBNB\n bool isBnbBased;\n /// @notice A flag identifies whether the Pancake pair is reversed\n /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not.\n bool isReversedPool;\n /// @notice The minimum window in seconds required between TWAP updates\n uint256 anchorPeriod;\n }\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice WBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WBNB;\n\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\n uint256 public constant BNB_BASE_UNIT = 1e18;\n uint256 public constant BUSD_BASE_UNIT = 1e18;\n\n /// @notice Configs by token\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Stored price by token\n mapping(address => uint256) public prices;\n\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\n mapping(address => Observation[]) public observations;\n\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\n mapping(address => uint256) public windowStart;\n\n /// @notice Emit this event when TWAP window is updated\n event TwapWindowUpdated(\n address indexed asset,\n uint256 oldTimestamp,\n uint256 oldAcc,\n uint256 newTimestamp,\n uint256 newAcc\n );\n\n /// @notice Emit this event when TWAP price is updated\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\n\n /// @notice Emit this event when new token configs are added\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param wBnbAddress The address of the WBNB\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address wBnbAddress) notNullAddress(wBnbAddress) {\n WBNB = wBnbAddress;\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Adds multiple token configs at the same time\n * @param configs Config array\n * @custom:error Zero length error thrown, if length of the config array is 0\n */\n function setTokenConfigs(TokenConfig[] memory configs) external {\n if (configs.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = configs.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(configs[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Get the TWAP price for the given asset\n * @param asset asset address\n * @return price asset price in USD\n * @custom:error Missing error is thrown if the token config does not exist\n * @custom:error Range error is thrown if TWAP price is not greater than zero\n */\n function getPrice(address asset) external view override returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n asset = WBNB;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n uint256 price = prices[asset];\n\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\n if (price == 0) revert(\"TWAP price must be positive\");\n return (price * (10 ** (18 - decimals)));\n }\n\n /**\n * @notice Adds a single token config\n * @param config token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if anchor period is not greater than zero\n * @custom:error Range error is thrown if base unit is not greater than zero\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\n * @custom:error NotNullAddress error is thrown if address of asset is null\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\n * @custom:event Emits TokenConfigAdded event if new token config are added with\n * asset address, PancakePool address, anchor period address\n */\n function setTokenConfig(\n TokenConfig memory config\n ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n if (config.anchorPeriod == 0) revert(\"anchor period must be positive\");\n if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals())\n revert(\"base unit decimals must be same as asset decimals\");\n\n uint256 cumulativePrice = currentCumulativePrice(config);\n\n // Initialize observation data\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\n tokenConfigs[config.asset] = config;\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\n }\n\n /**\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return anchorPrice anchor price of the asset\n * @custom:error Missing error is thrown if token config does not exist\n */\n function updateTwap(address asset) public returns (uint256) {\n if (asset == BNB_ADDR) {\n asset = WBNB;\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\n if (tokenConfigs[WBNB].asset == address(0)) revert(\"WBNB not exist\");\n _updateTwapInternal(tokenConfigs[WBNB]);\n }\n return _updateTwapInternal(tokenConfigs[asset]);\n }\n\n /**\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\n * @return cumulative price of target token regardless of pair order\n */\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\n if (config.isReversedPool) {\n return price1;\n } else {\n return price0;\n }\n }\n\n /**\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return price Asset price in USD, with 18 decimals\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\n * AnchorPrice, old observation timestamp and current timestamp\n */\n function _updateTwapInternal(TokenConfig memory config) private returns (uint256) {\n // pokeWindowValues already handled reversed pool cases,\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\n\n if (block.timestamp == oldTimestamp) return prices[config.asset];\n\n // This should be impossible, but better safe than sorry\n if (block.timestamp < oldTimestamp) revert(\"now must come after before\");\n\n uint256 timeElapsed;\n unchecked {\n timeElapsed = block.timestamp - oldTimestamp;\n }\n\n // Calculate Pancake *twap**\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\n );\n // *twap** price with 1e18 decimal mantissa\n uint256 priceAverageMantissa = priceAverage.decode112with18();\n\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\n // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18)\n uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT;\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\n\n // if this token is paired with BNB, convert its price to USD\n if (config.isBnbBased) {\n uint256 bnbPrice = prices[WBNB];\n if (bnbPrice == 0) revert(\"bnb price is invalid\");\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT;\n }\n\n if (anchorPriceMantissa == 0) revert(\"twap price cannot be 0\");\n\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\n\n // save anchor price, which is 1e18 decimals\n prices[config.asset] = anchorPriceMantissa;\n\n return anchorPriceMantissa;\n }\n\n /**\n * @notice Appends current observation and pick an observation with a timestamp equal\n * or just greater than the window start timestamp. If one is not available,\n * then pick the last availableobservation. The window start index is updated in both the cases.\n * Only the current observation is saved, prior observations are deleted during this operation.\n * @return Tuple of cumulative price, old observation and timestamp\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\n * new observation timestamp, current timestamp, new observation price and cumulative price\n */\n function pokeWindowValues(\n TokenConfig memory config\n ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\n uint256 cumulativePrice = currentCumulativePrice(config);\n uint256 currentTimestamp = block.timestamp;\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\n Observation[] memory storedObservations = observations[config.asset];\n\n uint256 storedObservationsLength = storedObservations.length;\n for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) {\n if (\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\n (windowStartIndex == storedObservationsLength - 1)\n ) {\n startCumulativePrice = storedObservations[windowStartIndex].acc;\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\n windowStart[config.asset] = windowStartIndex;\n break;\n } else {\n delete observations[config.asset][windowStartIndex];\n }\n\n unchecked {\n ++windowStartIndex;\n }\n }\n\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\n emit TwapWindowUpdated(\n config.asset,\n startCumulativeTimestamp,\n startCumulativePrice,\n block.timestamp,\n cumulativePrice\n );\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\n }\n}\n" - }, "contracts/ResilientOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ResilientOracle\n * @author Venus\n * @notice The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets.\n * \n * DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly\n * reported prices. If only one oracle is used, this creates a single point of failure and opens a vector\n * for attacking the protocol.\n * \n * The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect\n * the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle\n * and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.\n * \n * For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per \n * vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot \n * oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. \n * \n * To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every\n * market. The upper bound ratio represents the deviation between reported price (the price that’s being\n * validated) and the anchor price (the price we are validating against) above which the reported price will\n * be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below\n * which the reported price will be invalidated. So for oracle price to be considered valid the below statement\n * should be true:\n\n```\nanchorRatio = anchorPrice/reporterPrice\nisValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio\n```\n\n * In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending\n * on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may\n * use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. \n * \n * For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the\n * oracle to be stagnant and treat it like it's disabled.\n */\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n /**\n * @dev Oracle roles:\n * **main**: The most trustworthy price source\n * **pivot**: Price oracle used as a loose sanity checker\n * **fallback**: The backup source when main oracle price is invalidated\n */\n enum OracleRole {\n MAIN,\n PIVOT,\n FALLBACK\n }\n\n struct TokenConfig {\n /// @notice asset address\n address asset;\n /// @notice `oracles` stores the oracles based on their role in the following order:\n /// [main, pivot, fallback],\n /// It can be indexed with the corresponding enum OracleRole value\n address[3] oracles;\n /// @notice `enableFlagsForOracles` stores the enabled state\n /// for each oracle in the same order as `oracles`\n bool[3] enableFlagsForOracles;\n }\n\n uint256 public constant INVALID_PRICE = 0;\n\n /// @notice Native market address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable nativeMarket;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for Native token on each chain.This is the underlying for vBNB (on bsc)\n /// and can serve as any underlying asset of a market that supports native tokens\n address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Bound validator contract address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n BoundValidatorInterface public immutable boundValidator;\n\n mapping(address => TokenConfig) private tokenConfigs;\n\n event TokenConfigAdded(\n address indexed asset,\n address indexed mainOracle,\n address indexed pivotOracle,\n address fallbackOracle\n );\n\n /// Event emitted when an oracle is set\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n /// Event emitted when an oracle is enabled or disabled\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /**\n * @notice Checks whether token config exists by checking whether asset is null address\n * @dev address can't be null, so it's suitable to be used to check the validity of the config\n * @param asset asset address\n */\n modifier checkTokenConfigExistence(address asset) {\n if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @dev nativeMarketAddress can be address(0) if on the chain we do not support native market\n /// (e.g vETH on ethereum would not be supported, only vWETH)\n /// @param nativeMarketAddress The address of a native market (for bsc it would be vBNB address)\n /// @param vaiAddress The address of the VAI token (if there is VAI on the deployed chain).\n /// Set to address(0) of VAI is not existent.\n /// @param _boundValidator Address of the bound validator contract\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address nativeMarketAddress,\n address vaiAddress,\n BoundValidatorInterface _boundValidator\n ) notNullAddress(address(_boundValidator)) {\n nativeMarket = nativeMarketAddress;\n vai = vaiAddress;\n boundValidator = _boundValidator;\n\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract admin and sets the BoundValidator contract address\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n }\n\n /**\n * @notice Pauses oracle\n * @custom:access Only Governance\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n _pause();\n }\n\n /**\n * @notice Unpauses oracle\n * @custom:access Only Governance\n */\n function unpause() external {\n _checkAccessAllowed(\"unpause()\");\n _unpause();\n }\n\n /**\n * @notice Batch sets token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Throws a length error if the length of the token configs array is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Sets oracle for a given asset and role.\n * @dev Supplied asset **must** exist and main oracle may not be null\n * @param asset Asset address\n * @param oracle Oracle address\n * @param role Oracle role\n * @custom:access Only Governance\n * @custom:error Null address error if main-role oracle address is null\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n */\n function setOracle(\n address asset,\n address oracle,\n OracleRole role\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\n emit OracleSet(asset, oracle, uint256(role));\n }\n\n /**\n * @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\n * @dev Configuration for the asset **must** already exist and the asset cannot be 0 address\n * @param asset Asset address\n * @param role Oracle role\n * @param enable Enabled boolean of the oracle\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n */\n function enableOracle(\n address asset,\n OracleRole role,\n bool enable\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n emit OracleEnabled(asset, uint256(role), enable);\n }\n\n /**\n * @notice Updates the TWAP pivot oracle price.\n * @dev This function should always be called before calling getUnderlyingPrice\n * @param vToken vToken address\n */\n function updatePrice(address vToken) external override {\n address asset = _getUnderlyingAsset(vToken);\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @notice Updates the pivot oracle price. Currently using TWAP\n * @dev This function should always be called before calling getPrice\n * @param asset asset address\n */\n function updateAssetPrice(address asset) external {\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @dev Gets token config by asset address\n * @param asset asset address\n * @return tokenConfig Config for the asset\n */\n function getTokenConfig(address asset) external view returns (TokenConfig memory) {\n return tokenConfigs[asset];\n }\n\n /**\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n * - Check if the oracle is paused globally\n * - Validate price from main oracle against pivot oracle\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\n * - Validate price from main oracle against fallback oracle if the second validation failed\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\n * main oracle price is returned.\n * @param vToken vToken address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n\n address asset = _getUnderlyingAsset(vToken);\n return _getPrice(asset);\n }\n\n /**\n * @notice Gets price of the asset\n * @param asset asset address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getPrice(address asset) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n return _getPrice(asset);\n }\n\n /**\n * @notice Sets/resets single token configs.\n * @dev main oracle **must not** be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress is thrown if asset address is null\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n * @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(\n tokenConfig.asset,\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n );\n }\n\n /**\n * @notice Gets oracle and enabled status by asset address\n * @param asset asset address\n * @param role Oracle role\n * @return oracle Oracle address based on role\n * @return enabled Enabled flag of the oracle based on token config\n */\n function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {\n oracle = tokenConfigs[asset].oracles[uint256(role)];\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n }\n\n function _getPrice(address asset) internal view returns (uint256) {\n uint256 pivotPrice = INVALID_PRICE;\n\n // Get pivot oracle price, Invalid price if not available or error\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracleEnabled && pivotOracle != address(0)) {\n try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {\n pivotPrice = pricePivot;\n } catch {}\n }\n\n // Compare main price and pivot price, return main price and if validation was successful\n // note: In case pivot oracle is not available but main price is available and\n // validation is successful, the main oracle price is returned.\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n asset,\n pivotPrice,\n pivotOracleEnabled && pivotOracle != address(0)\n );\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n // Compare fallback and pivot if main oracle comparision fails with pivot\n // Return fallback price when fallback price is validated successfully with pivot oracle\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n // Lastly compare main price and fallback price\n if (\n mainPrice != INVALID_PRICE &&\n fallbackPrice != INVALID_PRICE &&\n boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)\n ) {\n return mainPrice;\n }\n\n revert(\"invalid resilient oracle price\");\n }\n\n /**\n * @notice Gets a price for the provided asset\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\n * able to fetch a correct price\n * @param asset asset address\n * @param pivotPrice Pivot oracle price\n * @param pivotEnabled If pivot oracle is not empty and enabled\n * @return price USD price in scaled decimals\n * e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n * @return pivotValidated Boolean representing if the validation of main oracle price\n * and pivot oracle price were successful\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n * address is null\n */\n function _getMainOraclePrice(\n address asset,\n uint256 pivotPrice,\n bool pivotEnabled\n ) internal view returns (uint256, bool) {\n (address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);\n if (mainOracleEnabled && mainOracle != address(0)) {\n try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {\n if (!pivotEnabled) {\n return (mainOraclePrice, true);\n }\n if (pivotPrice == INVALID_PRICE) {\n return (mainOraclePrice, false);\n }\n return (\n mainOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function won't revert when the price is 0 because getPrice checks if price is > 0\n * @param asset asset address\n * @return price USD price in 18 decimals\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\n * and pivot oracle price were successfull\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n * address is null\n */\n function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {\n (address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);\n if (fallbackEnabled && fallbackOracle != address(0)) {\n try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {\n if (pivotPrice == INVALID_PRICE) {\n return (fallbackOraclePrice, false);\n }\n return (\n fallbackOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view notNullAddress(vToken) returns (address asset) {\n if (vToken == nativeMarket) {\n asset = NATIVE_TOKEN_ADDR;\n } else if (vToken == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" }, diff --git a/deployments/sepolia/solcInputs/61a63fbc062c2591c6768138f59373e1.json b/deployments/sepolia/solcInputs/61a63fbc062c2591c6768138f59373e1.json index a0168fae..53225c4b 100644 --- a/deployments/sepolia/solcInputs/61a63fbc062c2591c6768138f59373e1.json +++ b/deployments/sepolia/solcInputs/61a63fbc062c2591c6768138f59373e1.json @@ -115,15 +115,9 @@ "contracts/oracles/mocks/MockPythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { IPyth } from \"../PythOracle.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockPythOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice the actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize(address underlyingPythOracle_) public initializer {\n __Ownable_init();\n if (underlyingPythOracle_ == address(0)) revert(\"pyth oracle cannot be zero address\");\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" }, - "contracts/oracles/mocks/MockTwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockTwapOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice vBNB address\n address public vBNB;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize(address vBNB_) public initializer {\n __Ownable_init();\n if (vBNB_ == address(0)) revert(\"vBNB can't be zero address\");\n vBNB = vBNB_;\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" - }, "contracts/oracles/PythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"../interfaces/PythInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title PythOracle\n * @author Venus\n * @notice PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores\n * the updated prices from external sources\n */\ncontract PythOracle is AccessControlledV8, OracleInterface {\n // To calculate 10 ** n(which is a signed type)\n using SignedMath for int256;\n\n // To cast int64/int8 types from Pyth to unsigned types\n using SafeCast for int256;\n\n struct TokenConfig {\n bytes32 pythId;\n address asset;\n uint64 maxStalePeriod;\n }\n\n /// @notice Exponent scale (decimal precision) of prices\n uint256 public constant EXP_SCALE = 1e18;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice The actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n /// @notice Token configs by asset address\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when setting a new pyth oracle address\n event PythOracleSet(address indexed oldPythOracle, address indexed newPythOracle);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed asset, bytes32 indexed pythId, uint64 indexed maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract and sets required contracts\n * @param underlyingPythOracle_ Address of the Pyth oracle\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(\n address underlyingPythOracle_,\n address accessControlManager_\n ) external initializer notNullAddress(underlyingPythOracle_) {\n __AccessControlled_init(accessControlManager_);\n\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n emit PythOracleSet(address(0), underlyingPythOracle_);\n }\n\n /**\n * @notice Batch set token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the underlying Pyth oracle contract address\n * @param underlyingPythOracle_ Pyth oracle contract address\n * @custom:access Only Governance\n * @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero\n * @custom:event Emits PythOracleSet event with address of Pyth oracle.\n */\n function setUnderlyingPythOracle(\n IPyth underlyingPythOracle_\n ) external notNullAddress(address(underlyingPythOracle_)) {\n _checkAccessAllowed(\"setUnderlyingPythOracle(address)\");\n IPyth oldUnderlyingPythOracle = underlyingPythOracle;\n underlyingPythOracle = underlyingPythOracle_;\n emit PythOracleSet(address(oldUnderlyingPythOracle), address(underlyingPythOracle_));\n }\n\n /**\n * @notice Set single token config. `maxStalePeriod` cannot be 0 and `asset` cannot be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if max stale period is zero\n * @custom:error NotNullAddress error is thrown if asset address is null\n */\n function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n if (tokenConfig.maxStalePeriod == 0) revert(\"max stale period cannot be 0\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);\n }\n\n /**\n * @notice Gets the price of a asset from the pyth oracle\n * @param asset Address of the asset\n * @return Price in USD\n */\n function getPrice(address asset) public view returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n return _getPriceInternal(asset, decimals);\n }\n\n function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256) {\n TokenConfig storage tokenConfig = tokenConfigs[asset];\n if (tokenConfig.asset == address(0)) revert(\"asset doesn't exist\");\n\n // if the price is expired after it's compared against `maxStalePeriod`, the following call will revert\n PythStructs.Price memory priceInfo = underlyingPythOracle.getPriceNoOlderThan(\n tokenConfig.pythId,\n tokenConfig.maxStalePeriod\n );\n\n uint256 price = int256(priceInfo.price).toUint256();\n\n if (price == 0) revert(\"invalid pyth oracle price\");\n\n // the price returned from Pyth is price ** 10^expo, which is the real dollar price of the assets\n // we need to multiply it by 1e18 to make the price 18 decimals\n if (priceInfo.expo > 0) {\n return price * EXP_SCALE * (10 ** int256(priceInfo.expo).toUint256()) * (10 ** (18 - decimals));\n } else {\n return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));\n }\n }\n}\n" }, - "contracts/oracles/TwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../libraries/PancakeLibrary.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title TwapOracle\n * @author Venus\n * @notice This oracle fetches price of assets from PancakeSwap.\n */\ncontract TwapOracle is AccessControlledV8, TwapInterface {\n using FixedPoint for *;\n\n struct Observation {\n uint256 timestamp;\n uint256 acc;\n }\n\n struct TokenConfig {\n /// @notice Asset address, which can't be zero address and can be used for existance check\n address asset;\n /// @notice Decimals of asset represented as 1e{decimals}\n uint256 baseUnit;\n /// @notice The address of Pancake pair\n address pancakePool;\n /// @notice Whether the token is paired with WBNB\n bool isBnbBased;\n /// @notice A flag identifies whether the Pancake pair is reversed\n /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not.\n bool isReversedPool;\n /// @notice The minimum window in seconds required between TWAP updates\n uint256 anchorPeriod;\n }\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice WBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WBNB;\n\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\n uint256 public constant BNB_BASE_UNIT = 1e18;\n uint256 public constant BUSD_BASE_UNIT = 1e18;\n\n /// @notice Configs by token\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Stored price by token\n mapping(address => uint256) public prices;\n\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\n mapping(address => Observation[]) public observations;\n\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\n mapping(address => uint256) public windowStart;\n\n /// @notice Emit this event when TWAP window is updated\n event TwapWindowUpdated(\n address indexed asset,\n uint256 oldTimestamp,\n uint256 oldAcc,\n uint256 newTimestamp,\n uint256 newAcc\n );\n\n /// @notice Emit this event when TWAP price is updated\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\n\n /// @notice Emit this event when new token configs are added\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param wBnbAddress The address of the WBNB\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address wBnbAddress) notNullAddress(wBnbAddress) {\n WBNB = wBnbAddress;\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Adds multiple token configs at the same time\n * @param configs Config array\n * @custom:error Zero length error thrown, if length of the config array is 0\n */\n function setTokenConfigs(TokenConfig[] memory configs) external {\n if (configs.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = configs.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(configs[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Get the TWAP price for the given asset\n * @param asset asset address\n * @return price asset price in USD\n * @custom:error Missing error is thrown if the token config does not exist\n * @custom:error Range error is thrown if TWAP price is not greater than zero\n */\n function getPrice(address asset) external view override returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n asset = WBNB;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n uint256 price = prices[asset];\n\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\n if (price == 0) revert(\"TWAP price must be positive\");\n return (price * (10 ** (18 - decimals)));\n }\n\n /**\n * @notice Adds a single token config\n * @param config token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if anchor period is not greater than zero\n * @custom:error Range error is thrown if base unit is not greater than zero\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\n * @custom:error NotNullAddress error is thrown if address of asset is null\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\n * @custom:event Emits TokenConfigAdded event if new token config are added with\n * asset address, PancakePool address, anchor period address\n */\n function setTokenConfig(\n TokenConfig memory config\n ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n if (config.anchorPeriod == 0) revert(\"anchor period must be positive\");\n if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals())\n revert(\"base unit decimals must be same as asset decimals\");\n\n uint256 cumulativePrice = currentCumulativePrice(config);\n\n // Initialize observation data\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\n tokenConfigs[config.asset] = config;\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\n }\n\n /**\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return anchorPrice anchor price of the asset\n * @custom:error Missing error is thrown if token config does not exist\n */\n function updateTwap(address asset) public returns (uint256) {\n if (asset == BNB_ADDR) {\n asset = WBNB;\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\n if (tokenConfigs[WBNB].asset == address(0)) revert(\"WBNB not exist\");\n _updateTwapInternal(tokenConfigs[WBNB]);\n }\n return _updateTwapInternal(tokenConfigs[asset]);\n }\n\n /**\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\n * @return cumulative price of target token regardless of pair order\n */\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\n if (config.isReversedPool) {\n return price1;\n } else {\n return price0;\n }\n }\n\n /**\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return price Asset price in USD, with 18 decimals\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\n * AnchorPrice, old observation timestamp and current timestamp\n */\n function _updateTwapInternal(TokenConfig memory config) private returns (uint256) {\n // pokeWindowValues already handled reversed pool cases,\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\n\n if (block.timestamp == oldTimestamp) return prices[config.asset];\n\n // This should be impossible, but better safe than sorry\n if (block.timestamp < oldTimestamp) revert(\"now must come after before\");\n\n uint256 timeElapsed;\n unchecked {\n timeElapsed = block.timestamp - oldTimestamp;\n }\n\n // Calculate Pancake *twap**\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\n );\n // *twap** price with 1e18 decimal mantissa\n uint256 priceAverageMantissa = priceAverage.decode112with18();\n\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\n // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18)\n uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT;\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\n\n // if this token is paired with BNB, convert its price to USD\n if (config.isBnbBased) {\n uint256 bnbPrice = prices[WBNB];\n if (bnbPrice == 0) revert(\"bnb price is invalid\");\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT;\n }\n\n if (anchorPriceMantissa == 0) revert(\"twap price cannot be 0\");\n\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\n\n // save anchor price, which is 1e18 decimals\n prices[config.asset] = anchorPriceMantissa;\n\n return anchorPriceMantissa;\n }\n\n /**\n * @notice Appends current observation and pick an observation with a timestamp equal\n * or just greater than the window start timestamp. If one is not available,\n * then pick the last availableobservation. The window start index is updated in both the cases.\n * Only the current observation is saved, prior observations are deleted during this operation.\n * @return Tuple of cumulative price, old observation and timestamp\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\n * new observation timestamp, current timestamp, new observation price and cumulative price\n */\n function pokeWindowValues(\n TokenConfig memory config\n ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\n uint256 cumulativePrice = currentCumulativePrice(config);\n uint256 currentTimestamp = block.timestamp;\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\n Observation[] memory storedObservations = observations[config.asset];\n\n uint256 storedObservationsLength = storedObservations.length;\n for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) {\n if (\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\n (windowStartIndex == storedObservationsLength - 1)\n ) {\n startCumulativePrice = storedObservations[windowStartIndex].acc;\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\n windowStart[config.asset] = windowStartIndex;\n break;\n } else {\n delete observations[config.asset][windowStartIndex];\n }\n\n unchecked {\n ++windowStartIndex;\n }\n }\n\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\n emit TwapWindowUpdated(\n config.asset,\n startCumulativeTimestamp,\n startCumulativePrice,\n block.timestamp,\n cumulativePrice\n );\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\n }\n}\n" - }, "contracts/ResilientOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ResilientOracle\n * @author Venus\n * @notice The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets.\n * \n * DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly\n * reported prices. If only one oracle is used, this creates a single point of failure and opens a vector\n * for attacking the protocol.\n * \n * The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect\n * the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle\n * and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.\n * \n * For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per \n * vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot \n * oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. \n * \n * To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every\n * market. The upper bound ratio represents the deviation between reported price (the price that’s being\n * validated) and the anchor price (the price we are validating against) above which the reported price will\n * be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below\n * which the reported price will be invalidated. So for oracle price to be considered valid the below statement\n * should be true:\n\n```\nanchorRatio = anchorPrice/reporterPrice\nisValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio\n```\n\n * In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending\n * on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may\n * use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. \n * \n * For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the\n * oracle to be stagnant and treat it like it's disabled.\n */\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n /**\n * @dev Oracle roles:\n * **main**: The most trustworthy price source\n * **pivot**: Price oracle used as a loose sanity checker\n * **fallback**: The backup source when main oracle price is invalidated\n */\n enum OracleRole {\n MAIN,\n PIVOT,\n FALLBACK\n }\n\n struct TokenConfig {\n /// @notice asset address\n address asset;\n /// @notice `oracles` stores the oracles based on their role in the following order:\n /// [main, pivot, fallback],\n /// It can be indexed with the corresponding enum OracleRole value\n address[3] oracles;\n /// @notice `enableFlagsForOracles` stores the enabled state\n /// for each oracle in the same order as `oracles`\n bool[3] enableFlagsForOracles;\n }\n\n uint256 public constant INVALID_PRICE = 0;\n\n /// @notice Native market address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable nativeMarket;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for Native token on each chain.This is the underlying for vBNB (on bsc)\n /// and can serve as any underlying asset of a market that supports native tokens\n address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Bound validator contract address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n BoundValidatorInterface public immutable boundValidator;\n\n mapping(address => TokenConfig) private tokenConfigs;\n\n event TokenConfigAdded(\n address indexed asset,\n address indexed mainOracle,\n address indexed pivotOracle,\n address fallbackOracle\n );\n\n /// Event emitted when an oracle is set\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n /// Event emitted when an oracle is enabled or disabled\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /**\n * @notice Checks whether token config exists by checking whether asset is null address\n * @dev address can't be null, so it's suitable to be used to check the validity of the config\n * @param asset asset address\n */\n modifier checkTokenConfigExistence(address asset) {\n if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @dev nativeMarketAddress can be address(0) if on the chain we do not support native market\n /// (e.g vETH on ethereum would not be supported, only vWETH)\n /// @param nativeMarketAddress The address of a native market (for bsc it would be vBNB address)\n /// @param vaiAddress The address of the VAI token (if there is VAI on the deployed chain).\n /// Set to address(0) of VAI is not existent.\n /// @param _boundValidator Address of the bound validator contract\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address nativeMarketAddress,\n address vaiAddress,\n BoundValidatorInterface _boundValidator\n ) notNullAddress(address(_boundValidator)) {\n nativeMarket = nativeMarketAddress;\n vai = vaiAddress;\n boundValidator = _boundValidator;\n\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract admin and sets the BoundValidator contract address\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n }\n\n /**\n * @notice Pauses oracle\n * @custom:access Only Governance\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n _pause();\n }\n\n /**\n * @notice Unpauses oracle\n * @custom:access Only Governance\n */\n function unpause() external {\n _checkAccessAllowed(\"unpause()\");\n _unpause();\n }\n\n /**\n * @notice Batch sets token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Throws a length error if the length of the token configs array is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Sets oracle for a given asset and role.\n * @dev Supplied asset **must** exist and main oracle may not be null\n * @param asset Asset address\n * @param oracle Oracle address\n * @param role Oracle role\n * @custom:access Only Governance\n * @custom:error Null address error if main-role oracle address is null\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n */\n function setOracle(\n address asset,\n address oracle,\n OracleRole role\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\n emit OracleSet(asset, oracle, uint256(role));\n }\n\n /**\n * @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\n * @dev Configuration for the asset **must** already exist and the asset cannot be 0 address\n * @param asset Asset address\n * @param role Oracle role\n * @param enable Enabled boolean of the oracle\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n */\n function enableOracle(\n address asset,\n OracleRole role,\n bool enable\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n emit OracleEnabled(asset, uint256(role), enable);\n }\n\n /**\n * @notice Updates the TWAP pivot oracle price.\n * @dev This function should always be called before calling getUnderlyingPrice\n * @param vToken vToken address\n */\n function updatePrice(address vToken) external override {\n address asset = _getUnderlyingAsset(vToken);\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @notice Updates the pivot oracle price. Currently using TWAP\n * @dev This function should always be called before calling getPrice\n * @param asset asset address\n */\n function updateAssetPrice(address asset) external {\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @dev Gets token config by asset address\n * @param asset asset address\n * @return tokenConfig Config for the asset\n */\n function getTokenConfig(address asset) external view returns (TokenConfig memory) {\n return tokenConfigs[asset];\n }\n\n /**\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n * - Check if the oracle is paused globally\n * - Validate price from main oracle against pivot oracle\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\n * - Validate price from main oracle against fallback oracle if the second validation failed\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\n * main oracle price is returned.\n * @param vToken vToken address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n\n address asset = _getUnderlyingAsset(vToken);\n return _getPrice(asset);\n }\n\n /**\n * @notice Gets price of the asset\n * @param asset asset address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getPrice(address asset) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n return _getPrice(asset);\n }\n\n /**\n * @notice Sets/resets single token configs.\n * @dev main oracle **must not** be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress is thrown if asset address is null\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n * @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(\n tokenConfig.asset,\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n );\n }\n\n /**\n * @notice Gets oracle and enabled status by asset address\n * @param asset asset address\n * @param role Oracle role\n * @return oracle Oracle address based on role\n * @return enabled Enabled flag of the oracle based on token config\n */\n function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {\n oracle = tokenConfigs[asset].oracles[uint256(role)];\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n }\n\n function _getPrice(address asset) internal view returns (uint256) {\n uint256 pivotPrice = INVALID_PRICE;\n\n // Get pivot oracle price, Invalid price if not available or error\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracleEnabled && pivotOracle != address(0)) {\n try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {\n pivotPrice = pricePivot;\n } catch {}\n }\n\n // Compare main price and pivot price, return main price and if validation was successful\n // note: In case pivot oracle is not available but main price is available and\n // validation is successful, the main oracle price is returned.\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n asset,\n pivotPrice,\n pivotOracleEnabled && pivotOracle != address(0)\n );\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n // Compare fallback and pivot if main oracle comparision fails with pivot\n // Return fallback price when fallback price is validated successfully with pivot oracle\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n // Lastly compare main price and fallback price\n if (\n mainPrice != INVALID_PRICE &&\n fallbackPrice != INVALID_PRICE &&\n boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)\n ) {\n return mainPrice;\n }\n\n revert(\"invalid resilient oracle price\");\n }\n\n /**\n * @notice Gets a price for the provided asset\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\n * able to fetch a correct price\n * @param asset asset address\n * @param pivotPrice Pivot oracle price\n * @param pivotEnabled If pivot oracle is not empty and enabled\n * @return price USD price in scaled decimals\n * e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n * @return pivotValidated Boolean representing if the validation of main oracle price\n * and pivot oracle price were successful\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n * address is null\n */\n function _getMainOraclePrice(\n address asset,\n uint256 pivotPrice,\n bool pivotEnabled\n ) internal view returns (uint256, bool) {\n (address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);\n if (mainOracleEnabled && mainOracle != address(0)) {\n try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {\n if (!pivotEnabled) {\n return (mainOraclePrice, true);\n }\n if (pivotPrice == INVALID_PRICE) {\n return (mainOraclePrice, false);\n }\n return (\n mainOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function won't revert when the price is 0 because getPrice checks if price is > 0\n * @param asset asset address\n * @return price USD price in 18 decimals\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\n * and pivot oracle price were successfull\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n * address is null\n */\n function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {\n (address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);\n if (fallbackEnabled && fallbackOracle != address(0)) {\n try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {\n if (pivotPrice == INVALID_PRICE) {\n return (fallbackOraclePrice, false);\n }\n return (\n fallbackOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view notNullAddress(vToken) returns (address asset) {\n if (vToken == nativeMarket) {\n asset = NATIVE_TOKEN_ADDR;\n } else if (vToken == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" }, diff --git a/deployments/sepolia/solcInputs/f5d4d6aee7a4e630f36ae4eef8377cf3.json b/deployments/sepolia/solcInputs/f5d4d6aee7a4e630f36ae4eef8377cf3.json index 8a451987..db26b9db 100644 --- a/deployments/sepolia/solcInputs/f5d4d6aee7a4e630f36ae4eef8377cf3.json +++ b/deployments/sepolia/solcInputs/f5d4d6aee7a4e630f36ae4eef8377cf3.json @@ -106,15 +106,9 @@ "contracts/oracles/mocks/MockPythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { IPyth } from \"../PythOracle.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockPythOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice the actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize(address underlyingPythOracle_) public initializer {\n __Ownable_init();\n if (underlyingPythOracle_ == address(0)) revert(\"pyth oracle cannot be zero address\");\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" }, - "contracts/oracles/mocks/MockTwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\n\ncontract MockTwapOracle is OwnableUpgradeable {\n mapping(address => uint256) public assetPrices;\n\n /// @notice vBNB address\n address public vBNB;\n\n //set price in 6 decimal precision\n constructor() {}\n\n function initialize(address vBNB_) public initializer {\n __Ownable_init();\n if (vBNB_ == address(0)) revert(\"vBNB can't be zero address\");\n vBNB = vBNB_;\n }\n\n function setPrice(address asset, uint256 price) external {\n assetPrices[asset] = price;\n }\n\n //https://compound.finance/docs/prices\n function getPrice(address token) public view returns (uint256) {\n return assetPrices[token];\n }\n}\n" - }, "contracts/oracles/PythOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"../interfaces/PythInterface.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title PythOracle\n * @author Venus\n * @notice PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores\n * the updated prices from external sources\n */\ncontract PythOracle is AccessControlledV8, OracleInterface {\n // To calculate 10 ** n(which is a signed type)\n using SignedMath for int256;\n\n // To cast int64/int8 types from Pyth to unsigned types\n using SafeCast for int256;\n\n struct TokenConfig {\n bytes32 pythId;\n address asset;\n uint64 maxStalePeriod;\n }\n\n /// @notice Exponent scale (decimal precision) of prices\n uint256 public constant EXP_SCALE = 1e18;\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice The actual pyth oracle address fetch & store the prices\n IPyth public underlyingPythOracle;\n\n /// @notice Token configs by asset address\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Emit when setting a new pyth oracle address\n event PythOracleSet(address indexed oldPythOracle, address indexed newPythOracle);\n\n /// @notice Emit when a token config is added\n event TokenConfigAdded(address indexed asset, bytes32 indexed pythId, uint64 indexed maxStalePeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract and sets required contracts\n * @param underlyingPythOracle_ Address of the Pyth oracle\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(\n address underlyingPythOracle_,\n address accessControlManager_\n ) external initializer notNullAddress(underlyingPythOracle_) {\n __AccessControlled_init(accessControlManager_);\n\n underlyingPythOracle = IPyth(underlyingPythOracle_);\n emit PythOracleSet(address(0), underlyingPythOracle_);\n }\n\n /**\n * @notice Batch set token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Zero length error is thrown if length of the array in parameter is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the underlying Pyth oracle contract address\n * @param underlyingPythOracle_ Pyth oracle contract address\n * @custom:access Only Governance\n * @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero\n * @custom:event Emits PythOracleSet event with address of Pyth oracle.\n */\n function setUnderlyingPythOracle(\n IPyth underlyingPythOracle_\n ) external notNullAddress(address(underlyingPythOracle_)) {\n _checkAccessAllowed(\"setUnderlyingPythOracle(address)\");\n IPyth oldUnderlyingPythOracle = underlyingPythOracle;\n underlyingPythOracle = underlyingPythOracle_;\n emit PythOracleSet(address(oldUnderlyingPythOracle), address(underlyingPythOracle_));\n }\n\n /**\n * @notice Set single token config. `maxStalePeriod` cannot be 0 and `asset` cannot be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if max stale period is zero\n * @custom:error NotNullAddress error is thrown if asset address is null\n */\n function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n if (tokenConfig.maxStalePeriod == 0) revert(\"max stale period cannot be 0\");\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);\n }\n\n /**\n * @notice Gets the price of a asset from the pyth oracle\n * @param asset Address of the asset\n * @return Price in USD\n */\n function getPrice(address asset) public view returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n return _getPriceInternal(asset, decimals);\n }\n\n function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256) {\n TokenConfig storage tokenConfig = tokenConfigs[asset];\n if (tokenConfig.asset == address(0)) revert(\"asset doesn't exist\");\n\n // if the price is expired after it's compared against `maxStalePeriod`, the following call will revert\n PythStructs.Price memory priceInfo = underlyingPythOracle.getPriceNoOlderThan(\n tokenConfig.pythId,\n tokenConfig.maxStalePeriod\n );\n\n uint256 price = int256(priceInfo.price).toUint256();\n\n if (price == 0) revert(\"invalid pyth oracle price\");\n\n // the price returned from Pyth is price ** 10^expo, which is the real dollar price of the assets\n // we need to multiply it by 1e18 to make the price 18 decimals\n if (priceInfo.expo > 0) {\n return price * EXP_SCALE * (10 ** int256(priceInfo.expo).toUint256()) * (10 ** (18 - decimals));\n } else {\n return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));\n }\n }\n}\n" }, - "contracts/oracles/TwapOracle.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../libraries/PancakeLibrary.sol\";\nimport \"../interfaces/OracleInterface.sol\";\nimport \"../interfaces/VBep20Interface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title TwapOracle\n * @author Venus\n * @notice This oracle fetches price of assets from PancakeSwap.\n */\ncontract TwapOracle is AccessControlledV8, TwapInterface {\n using FixedPoint for *;\n\n struct Observation {\n uint256 timestamp;\n uint256 acc;\n }\n\n struct TokenConfig {\n /// @notice Asset address, which can't be zero address and can be used for existance check\n address asset;\n /// @notice Decimals of asset represented as 1e{decimals}\n uint256 baseUnit;\n /// @notice The address of Pancake pair\n address pancakePool;\n /// @notice Whether the token is paired with WBNB\n bool isBnbBased;\n /// @notice A flag identifies whether the Pancake pair is reversed\n /// e.g. XVS-WBNB is reversed, while WBNB-XVS is not.\n bool isReversedPool;\n /// @notice The minimum window in seconds required between TWAP updates\n uint256 anchorPeriod;\n }\n\n /// @notice Set this as asset address for BNB. This is the underlying for vBNB\n address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice WBNB address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WBNB;\n\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\n uint256 public constant BNB_BASE_UNIT = 1e18;\n uint256 public constant BUSD_BASE_UNIT = 1e18;\n\n /// @notice Configs by token\n mapping(address => TokenConfig) public tokenConfigs;\n\n /// @notice Stored price by token\n mapping(address => uint256) public prices;\n\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\n mapping(address => Observation[]) public observations;\n\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\n mapping(address => uint256) public windowStart;\n\n /// @notice Emit this event when TWAP window is updated\n event TwapWindowUpdated(\n address indexed asset,\n uint256 oldTimestamp,\n uint256 oldAcc,\n uint256 newTimestamp,\n uint256 newAcc\n );\n\n /// @notice Emit this event when TWAP price is updated\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\n\n /// @notice Emit this event when new token configs are added\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\n\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param wBnbAddress The address of the WBNB\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address wBnbAddress) notNullAddress(wBnbAddress) {\n WBNB = wBnbAddress;\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the owner of the contract\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n }\n\n /**\n * @notice Adds multiple token configs at the same time\n * @param configs Config array\n * @custom:error Zero length error thrown, if length of the config array is 0\n */\n function setTokenConfigs(TokenConfig[] memory configs) external {\n if (configs.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = configs.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(configs[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Get the TWAP price for the given asset\n * @param asset asset address\n * @return price asset price in USD\n * @custom:error Missing error is thrown if the token config does not exist\n * @custom:error Range error is thrown if TWAP price is not greater than zero\n */\n function getPrice(address asset) external view override returns (uint256) {\n uint256 decimals;\n\n if (asset == BNB_ADDR) {\n decimals = 18;\n asset = WBNB;\n } else {\n IERC20Metadata token = IERC20Metadata(asset);\n decimals = token.decimals();\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n uint256 price = prices[asset];\n\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\n if (price == 0) revert(\"TWAP price must be positive\");\n return (price * (10 ** (18 - decimals)));\n }\n\n /**\n * @notice Adds a single token config\n * @param config token config struct\n * @custom:access Only Governance\n * @custom:error Range error is thrown if anchor period is not greater than zero\n * @custom:error Range error is thrown if base unit is not greater than zero\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\n * @custom:error NotNullAddress error is thrown if address of asset is null\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\n * @custom:event Emits TokenConfigAdded event if new token config are added with\n * asset address, PancakePool address, anchor period address\n */\n function setTokenConfig(\n TokenConfig memory config\n ) public notNullAddress(config.asset) notNullAddress(config.pancakePool) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n if (config.anchorPeriod == 0) revert(\"anchor period must be positive\");\n if (config.baseUnit != 10 ** IERC20Metadata(config.asset).decimals())\n revert(\"base unit decimals must be same as asset decimals\");\n\n uint256 cumulativePrice = currentCumulativePrice(config);\n\n // Initialize observation data\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\n tokenConfigs[config.asset] = config;\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\n }\n\n /**\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return anchorPrice anchor price of the asset\n * @custom:error Missing error is thrown if token config does not exist\n */\n function updateTwap(address asset) public returns (uint256) {\n if (asset == BNB_ADDR) {\n asset = WBNB;\n }\n\n if (tokenConfigs[asset].asset == address(0)) revert(\"asset not exist\");\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\n if (tokenConfigs[WBNB].asset == address(0)) revert(\"WBNB not exist\");\n _updateTwapInternal(tokenConfigs[WBNB]);\n }\n return _updateTwapInternal(tokenConfigs[asset]);\n }\n\n /**\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\n * @return cumulative price of target token regardless of pair order\n */\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\n if (config.isReversedPool) {\n return price1;\n } else {\n return price0;\n }\n }\n\n /**\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\n * @return price Asset price in USD, with 18 decimals\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\n * AnchorPrice, old observation timestamp and current timestamp\n */\n function _updateTwapInternal(TokenConfig memory config) private returns (uint256) {\n // pokeWindowValues already handled reversed pool cases,\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\n\n if (block.timestamp == oldTimestamp) return prices[config.asset];\n\n // This should be impossible, but better safe than sorry\n if (block.timestamp < oldTimestamp) revert(\"now must come after before\");\n\n uint256 timeElapsed;\n unchecked {\n timeElapsed = block.timestamp - oldTimestamp;\n }\n\n // Calculate Pancake *twap**\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\n );\n // *twap** price with 1e18 decimal mantissa\n uint256 priceAverageMantissa = priceAverage.decode112with18();\n\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\n // tokenBaseUnit / (BNB_BASE_UNIT or BUSD_BASE_UNIT, which is 1e18)\n uint256 pairedTokenBaseUnit = config.isBnbBased ? BNB_BASE_UNIT : BUSD_BASE_UNIT;\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\n\n // if this token is paired with BNB, convert its price to USD\n if (config.isBnbBased) {\n uint256 bnbPrice = prices[WBNB];\n if (bnbPrice == 0) revert(\"bnb price is invalid\");\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / BNB_BASE_UNIT;\n }\n\n if (anchorPriceMantissa == 0) revert(\"twap price cannot be 0\");\n\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\n\n // save anchor price, which is 1e18 decimals\n prices[config.asset] = anchorPriceMantissa;\n\n return anchorPriceMantissa;\n }\n\n /**\n * @notice Appends current observation and pick an observation with a timestamp equal\n * or just greater than the window start timestamp. If one is not available,\n * then pick the last availableobservation. The window start index is updated in both the cases.\n * Only the current observation is saved, prior observations are deleted during this operation.\n * @return Tuple of cumulative price, old observation and timestamp\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\n * new observation timestamp, current timestamp, new observation price and cumulative price\n */\n function pokeWindowValues(\n TokenConfig memory config\n ) private returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\n uint256 cumulativePrice = currentCumulativePrice(config);\n uint256 currentTimestamp = block.timestamp;\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\n Observation[] memory storedObservations = observations[config.asset];\n\n uint256 storedObservationsLength = storedObservations.length;\n for (uint256 windowStartIndex = windowStart[config.asset]; windowStartIndex < storedObservationsLength; ) {\n if (\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\n (windowStartIndex == storedObservationsLength - 1)\n ) {\n startCumulativePrice = storedObservations[windowStartIndex].acc;\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\n windowStart[config.asset] = windowStartIndex;\n break;\n } else {\n delete observations[config.asset][windowStartIndex];\n }\n\n unchecked {\n ++windowStartIndex;\n }\n }\n\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\n emit TwapWindowUpdated(\n config.asset,\n startCumulativeTimestamp,\n startCumulativePrice,\n block.timestamp,\n cumulativePrice\n );\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\n }\n}\n" - }, "contracts/ResilientOracle.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ResilientOracle\n * @author Venus\n * @notice The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets.\n * \n * DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly\n * reported prices. If only one oracle is used, this creates a single point of failure and opens a vector\n * for attacking the protocol.\n * \n * The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect\n * the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle\n * and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.\n * \n * For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per \n * vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot \n * oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. \n * \n * To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every\n * market. The upper bound ratio represents the deviation between reported price (the price that’s being\n * validated) and the anchor price (the price we are validating against) above which the reported price will\n * be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below\n * which the reported price will be invalidated. So for oracle price to be considered valid the below statement\n * should be true:\n\n```\nanchorRatio = anchorPrice/reporterPrice\nisValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio\n```\n\n * In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending\n * on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may\n * use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. \n * \n * For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the\n * oracle to be stagnant and treat it like it's disabled.\n */\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n /**\n * @dev Oracle roles:\n * **main**: The most trustworthy price source\n * **pivot**: Price oracle used as a loose sanity checker\n * **fallback**: The backup source when main oracle price is invalidated\n */\n enum OracleRole {\n MAIN,\n PIVOT,\n FALLBACK\n }\n\n struct TokenConfig {\n /// @notice asset address\n address asset;\n /// @notice `oracles` stores the oracles based on their role in the following order:\n /// [main, pivot, fallback],\n /// It can be indexed with the corresponding enum OracleRole value\n address[3] oracles;\n /// @notice `enableFlagsForOracles` stores the enabled state\n /// for each oracle in the same order as `oracles`\n bool[3] enableFlagsForOracles;\n }\n\n uint256 public constant INVALID_PRICE = 0;\n\n /// @notice Native market address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable nativeMarket;\n\n /// @notice VAI address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vai;\n\n /// @notice Set this as asset address for Native token on each chain.This is the underlying for vBNB (on bsc)\n /// and can serve as any underlying asset of a market that supports native tokens\n address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n /// @notice Bound validator contract address\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n BoundValidatorInterface public immutable boundValidator;\n\n mapping(address => TokenConfig) private tokenConfigs;\n\n event TokenConfigAdded(\n address indexed asset,\n address indexed mainOracle,\n address indexed pivotOracle,\n address fallbackOracle\n );\n\n /// Event emitted when an oracle is set\n event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n /// Event emitted when an oracle is enabled or disabled\n event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n /**\n * @notice Checks whether an address is null or not\n */\n modifier notNullAddress(address someone) {\n if (someone == address(0)) revert(\"can't be zero address\");\n _;\n }\n\n /**\n * @notice Checks whether token config exists by checking whether asset is null address\n * @dev address can't be null, so it's suitable to be used to check the validity of the config\n * @param asset asset address\n */\n modifier checkTokenConfigExistence(address asset) {\n if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n _;\n }\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @dev nativeMarketAddress can be address(0) if on the chain we do not support native market\n /// (e.g vETH on ethereum would not be supported, only vWETH)\n /// @param nativeMarketAddress The address of a native market (for bsc it would be vBNB address)\n /// @param vaiAddress The address of the VAI token (if there is VAI on the deployed chain).\n /// Set to address(0) of VAI is not existent.\n /// @param _boundValidator Address of the bound validator contract\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address nativeMarketAddress,\n address vaiAddress,\n BoundValidatorInterface _boundValidator\n ) notNullAddress(address(_boundValidator)) {\n nativeMarket = nativeMarketAddress;\n vai = vaiAddress;\n boundValidator = _boundValidator;\n\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract admin and sets the BoundValidator contract address\n * @param accessControlManager_ Address of the access control manager contract\n */\n function initialize(address accessControlManager_) external initializer {\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n }\n\n /**\n * @notice Pauses oracle\n * @custom:access Only Governance\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n _pause();\n }\n\n /**\n * @notice Unpauses oracle\n * @custom:access Only Governance\n */\n function unpause() external {\n _checkAccessAllowed(\"unpause()\");\n _unpause();\n }\n\n /**\n * @notice Batch sets token configs\n * @param tokenConfigs_ Token config array\n * @custom:access Only Governance\n * @custom:error Throws a length error if the length of the token configs array is 0\n */\n function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n uint256 numTokenConfigs = tokenConfigs_.length;\n for (uint256 i; i < numTokenConfigs; ) {\n setTokenConfig(tokenConfigs_[i]);\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Sets oracle for a given asset and role.\n * @dev Supplied asset **must** exist and main oracle may not be null\n * @param asset Asset address\n * @param oracle Oracle address\n * @param role Oracle role\n * @custom:access Only Governance\n * @custom:error Null address error if main-role oracle address is null\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n */\n function setOracle(\n address asset,\n address oracle,\n OracleRole role\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n tokenConfigs[asset].oracles[uint256(role)] = oracle;\n emit OracleSet(asset, oracle, uint256(role));\n }\n\n /**\n * @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\n * @dev Configuration for the asset **must** already exist and the asset cannot be 0 address\n * @param asset Asset address\n * @param role Oracle role\n * @param enable Enabled boolean of the oracle\n * @custom:access Only Governance\n * @custom:error NotNullAddress error is thrown if asset address is null\n * @custom:error TokenConfigExistance error is thrown if token config is not set\n */\n function enableOracle(\n address asset,\n OracleRole role,\n bool enable\n ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n emit OracleEnabled(asset, uint256(role), enable);\n }\n\n /**\n * @notice Updates the TWAP pivot oracle price.\n * @dev This function should always be called before calling getUnderlyingPrice\n * @param vToken vToken address\n */\n function updatePrice(address vToken) external override {\n address asset = _getUnderlyingAsset(vToken);\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @notice Updates the pivot oracle price. Currently using TWAP\n * @dev This function should always be called before calling getPrice\n * @param asset asset address\n */\n function updateAssetPrice(address asset) external {\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracle != address(0) && pivotOracleEnabled) {\n //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n }\n }\n\n /**\n * @dev Gets token config by asset address\n * @param asset asset address\n * @return tokenConfig Config for the asset\n */\n function getTokenConfig(address asset) external view returns (TokenConfig memory) {\n return tokenConfigs[asset];\n }\n\n /**\n * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n * - Check if the oracle is paused globally\n * - Validate price from main oracle against pivot oracle\n * - Validate price from fallback oracle against pivot oracle if the first validation failed\n * - Validate price from main oracle against fallback oracle if the second validation failed\n * In the case that the pivot oracle is not available but main price is available and validation is successful,\n * main oracle price is returned.\n * @param vToken vToken address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n\n address asset = _getUnderlyingAsset(vToken);\n return _getPrice(asset);\n }\n\n /**\n * @notice Gets price of the asset\n * @param asset asset address\n * @return price USD price in scaled decimal places.\n * @custom:error Paused error is thrown when resilent oracle is paused\n * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n */\n function getPrice(address asset) external view override returns (uint256) {\n if (paused()) revert(\"resilient oracle is paused\");\n return _getPrice(asset);\n }\n\n /**\n * @notice Sets/resets single token configs.\n * @dev main oracle **must not** be a null address\n * @param tokenConfig Token config struct\n * @custom:access Only Governance\n * @custom:error NotNullAddress is thrown if asset address is null\n * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n * @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\n */\n function setTokenConfig(\n TokenConfig memory tokenConfig\n ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n tokenConfigs[tokenConfig.asset] = tokenConfig;\n emit TokenConfigAdded(\n tokenConfig.asset,\n tokenConfig.oracles[uint256(OracleRole.MAIN)],\n tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n );\n }\n\n /**\n * @notice Gets oracle and enabled status by asset address\n * @param asset asset address\n * @param role Oracle role\n * @return oracle Oracle address based on role\n * @return enabled Enabled flag of the oracle based on token config\n */\n function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {\n oracle = tokenConfigs[asset].oracles[uint256(role)];\n enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n }\n\n function _getPrice(address asset) internal view returns (uint256) {\n uint256 pivotPrice = INVALID_PRICE;\n\n // Get pivot oracle price, Invalid price if not available or error\n (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n if (pivotOracleEnabled && pivotOracle != address(0)) {\n try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {\n pivotPrice = pricePivot;\n } catch {}\n }\n\n // Compare main price and pivot price, return main price and if validation was successful\n // note: In case pivot oracle is not available but main price is available and\n // validation is successful, the main oracle price is returned.\n (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n asset,\n pivotPrice,\n pivotOracleEnabled && pivotOracle != address(0)\n );\n if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n // Compare fallback and pivot if main oracle comparision fails with pivot\n // Return fallback price when fallback price is validated successfully with pivot oracle\n (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);\n if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n // Lastly compare main price and fallback price\n if (\n mainPrice != INVALID_PRICE &&\n fallbackPrice != INVALID_PRICE &&\n boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)\n ) {\n return mainPrice;\n }\n\n revert(\"invalid resilient oracle price\");\n }\n\n /**\n * @notice Gets a price for the provided asset\n * @dev This function won't revert when price is 0, because the fallback oracle may still be\n * able to fetch a correct price\n * @param asset asset address\n * @param pivotPrice Pivot oracle price\n * @param pivotEnabled If pivot oracle is not empty and enabled\n * @return price USD price in scaled decimals\n * e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n * @return pivotValidated Boolean representing if the validation of main oracle price\n * and pivot oracle price were successful\n * @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n * address is null\n */\n function _getMainOraclePrice(\n address asset,\n uint256 pivotPrice,\n bool pivotEnabled\n ) internal view returns (uint256, bool) {\n (address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);\n if (mainOracleEnabled && mainOracle != address(0)) {\n try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {\n if (!pivotEnabled) {\n return (mainOraclePrice, true);\n }\n if (pivotPrice == INVALID_PRICE) {\n return (mainOraclePrice, false);\n }\n return (\n mainOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function won't revert when the price is 0 because getPrice checks if price is > 0\n * @param asset asset address\n * @return price USD price in 18 decimals\n * @return pivotValidated Boolean representing if the validation of fallback oracle price\n * and pivot oracle price were successfull\n * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset\n * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n * address is null\n */\n function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {\n (address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);\n if (fallbackEnabled && fallbackOracle != address(0)) {\n try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {\n if (pivotPrice == INVALID_PRICE) {\n return (fallbackOraclePrice, false);\n }\n return (\n fallbackOraclePrice,\n boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)\n );\n } catch {\n return (INVALID_PRICE, false);\n }\n }\n\n return (INVALID_PRICE, false);\n }\n\n /**\n * @dev This function returns the underlying asset of a vToken\n * @param vToken vToken address\n * @return asset underlying asset address\n */\n function _getUnderlyingAsset(address vToken) private view notNullAddress(vToken) returns (address asset) {\n if (vToken == nativeMarket) {\n asset = NATIVE_TOKEN_ADDR;\n } else if (vToken == vai) {\n asset = vai;\n } else {\n asset = VBep20Interface(vToken).underlying();\n }\n }\n}\n" }, diff --git a/helpers/deploymentConfig.ts b/helpers/deploymentConfig.ts index 787f4459..5ba7d754 100644 --- a/helpers/deploymentConfig.ts +++ b/helpers/deploymentConfig.ts @@ -1,6 +1,7 @@ import bscmainnetGovernanceDeployments from "@venusprotocol/governance-contracts/deployments/bscmainnet.json"; import bsctestnetGovernanceDeployments from "@venusprotocol/governance-contracts/deployments/bsctestnet.json"; import ethereumGovernanceDeployments from "@venusprotocol/governance-contracts/deployments/ethereum.json"; +import opbnbmainnetGovernanceDeployments from "@venusprotocol/governance-contracts/deployments/opbnbmainnet.json"; import opbnbtestnetGovernanceDeployments from "@venusprotocol/governance-contracts/deployments/opbnbtestnet.json"; import sepoliaGovernanceDeployments from "@venusprotocol/governance-contracts/deployments/sepolia.json"; import mainnetDeployments from "@venusprotocol/venus-protocol/deployments/bscmainnet.json"; @@ -107,6 +108,15 @@ export const ADDRESSES: PreconfiguredAddresses = { acm: opbnbtestnetGovernanceDeployments.contracts.AccessControlManager.address, timelock: "0xb15f6EfEbC276A3b9805df81b5FB3D50C2A62BDf", // opBNB Multisig }, + opbnbmainnet: { + vBNBAddress: ethers.constants.AddressZero, + WBNBAddress: ethers.constants.AddressZero, + VAIAddress: ethers.constants.AddressZero, + sidRegistryAddress: ethers.constants.AddressZero, + feedRegistryAddress: "0x72d55658242377AF22907b6E7350148288f88033", + acm: opbnbmainnetGovernanceDeployments.contracts.AccessControlManager.address, + timelock: "0xC46796a21a3A9FAB6546aF3434F2eBfFd0604207", // opBNB Multisig + }, }; export const chainlinkFeed: Config = { @@ -176,6 +186,7 @@ export const chainlinkFeed: Config = { XVS: "0xa2a8507DEb233ceE4F5594044C259DD0582339CC", CRV: "0xCd627aA160A6fA45Eb793D19Ef54f5062F20f33f", crvUSD: "0xEEf0C605546958c1f899b6fB336C20671f9cD49F", + stETH: "0xCfE54B5cD566aB89272946F602D76Ea879CAb4a8", }, }; @@ -613,7 +624,7 @@ export const assets: Assets = { }, { token: "WETH", - address: "0x700868CAbb60e90d77B6588ce072d9859ec8E281", + address: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", oracle: "chainlink", price: "2080000000000000000000", }, @@ -661,6 +672,12 @@ export const assets: Assets = { oracle: "chainlink", stalePeriod: STALE_PERIOD_100M, }, + { + token: "stETH", + address: "0xae7ab96520de3a18e5e111b5eaab095312d7fe84", + oracle: "chainlink", + stalePeriod: STALE_PERIOD_100M, + }, { token: "USDC", address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", @@ -724,6 +741,38 @@ export const assets: Assets = { price: "7000000000000000000", }, ], + opbnbmainnet: [ + { + token: "BTCB", + address: "0x7c6b91d9be155a6db01f749217d76ff02a7227f2", + oracle: "binance", + }, + { + token: "ETH", + address: "0xe7798f023fc62146e8aa1b36da45fb70855a77ea", + oracle: "binance", + }, + { + token: "USDT", + address: "0x9e5aac1ba1a2e6aed6b32689dfcf62a509ca96f3", + oracle: "binance", + }, + { + token: "WBNB", + address: "0x4200000000000000000000000000000000000006", + oracle: "binance", + }, + { + token: "XVS", + address: "0x3E2e61F1c075881F3fB8dd568043d8c221fd5c61", + oracle: "binance", + }, + { + token: "FDUSD", + address: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", + oracle: "binance", + }, + ], }; export const getOraclesData = async (): Promise => { diff --git a/package.json b/package.json index db9c21e4..b35661d4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@venusprotocol/oracle", "description": "Venus Protocol Price Oracle", - "version": "1.9.0", + "version": "1.10.0-dev.8", "author": "Venus", "engines": { "node": ">=18.x.x" diff --git a/test/PivotTwapOracle.ts b/test/PivotTwapOracle.ts deleted file mode 100755 index 4ef9a81b..00000000 --- a/test/PivotTwapOracle.ts +++ /dev/null @@ -1,626 +0,0 @@ -import { smock } from "@defi-wonderland/smock"; -import { increaseTo } from "@nomicfoundation/hardhat-network-helpers/dist/src/helpers/time/increaseTo"; -import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { expect } from "chai"; -import { BigNumber } from "ethers"; -import { ethers, upgrades } from "hardhat"; - -import { AccessControlManager, BoundValidator } from "../typechain-types"; -import { TwapOracle } from "../typechain-types/contracts/oracles/TwapOracle"; -import { addr0000 } from "./utils/data"; -import { makePairWithTokens } from "./utils/makePair"; -import { makeToken } from "./utils/makeToken"; -import { getTime, increaseTime } from "./utils/time"; - -const EXP_SCALE = BigNumber.from(10).pow(18); -const Q112 = BigNumber.from(2).pow(112); -const RATIO = Q112.div(EXP_SCALE); - -// helper functions -async function checkObservations( - twapOracleContract: TwapOracle, - token: string, - time: number, - acc: BigNumber, - index: number, -) { - // check observations - const newObservation = await twapOracleContract.observations(token, index); - expect(newObservation.timestamp).be.closeTo(BigNumber.from(time), 1); - expect(newObservation.acc).be.closeTo(acc, 100); -} - -describe("Twap Oracle unit tests", () => { - beforeEach(async function () { - const signers: SignerWithAddress[] = await ethers.getSigners(); - const admin = signers[0]; - this.signers = signers; - this.admin = admin; - this.vai = signers[5]; // Not your usual vToken - this.wBnb = await makeToken("Wrapped BNB", "WBNB", 18); - this.bnbAddr = "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"; - - const twapOracle = await ethers.getContractFactory("TwapOracle", admin); - const fakeAccessControlManager = await smock.fake("AccessControlManagerScenario"); - fakeAccessControlManager.isAllowedToCall.returns(true); - - const twapInstance = await upgrades.deployProxy(twapOracle, [fakeAccessControlManager.address], { - constructorArgs: [this.wBnb.address], - }); - this.twapOracle = twapInstance; - - const boundValidator = await ethers.getContractFactory("BoundValidator", admin); - const boundValidatorInstance = await upgrades.deployProxy( - boundValidator, - [fakeAccessControlManager.address], - { - constructorArgs: [], - }, - ); - this.boundValidator = boundValidatorInstance; - - const token1 = await makeToken("TOKEN1", "TOKEN1"); - const tokenBusd = await makeToken("BUSD1", "BUSD1", 18); - const simplePair = await makePairWithTokens(token1.address, tokenBusd.address); - this.simplePair = simplePair; - - // set up bnb based pair for later test - const token3 = await makeToken("TOKEN3", "TOKEN3", 18); - const BEP20HarnessFactory = await ethers.getContractFactory("BEP20Harness"); - const tokenWbnb = BEP20HarnessFactory.attach(await this.twapOracle.WBNB()); - const bnbBasedPair = await makePairWithTokens(token3.address, tokenWbnb.address); - this.bnbBasedPair = bnbBasedPair; - - const bnbPair = await makePairWithTokens(tokenBusd.address, tokenWbnb.address); - this.bnbPair = bnbPair; - this.token1 = token1; - }); - - describe("token config", () => { - describe("add single token config", () => { - it("should revert on calling updateTwap without setting token configs", async function () { - await expect(this.twapOracle.updateTwap(this.bnbAddr)).to.be.revertedWith("asset not exist"); - }); - - it("vToken can\"t be zero & pool address can't be zero & anchorPeriod can't be 0", async function () { - const config = { - asset: addr0000, - baseUnit: BigNumber.from(0), - pancakePool: addr0000, - isBnbBased: false, - isReversedPool: false, - anchorPeriod: 0, - }; - await expect(this.twapOracle.setTokenConfig(config)).to.be.revertedWith("can't be zero address"); - - config.asset = this.wBnb.address; - await expect(this.twapOracle.setTokenConfig(config)).to.be.revertedWith("can't be zero address"); - - config.pancakePool = this.simplePair.address; - await expect(this.twapOracle.setTokenConfig(config)).to.be.revertedWith("anchor period must be positive"); - - config.anchorPeriod = 100; - await expect(this.twapOracle.setTokenConfig(config)).to.be.revertedWith( - "base unit decimals must be same as asset decimals", - ); - config.baseUnit = EXP_SCALE; - - // nothing happen - await this.twapOracle.setTokenConfig(config); - }); - - it("reset token config", async function () { - const token = await makeToken("Token", "Token"); - - const config1 = { - asset: this.wBnb.address, - baseUnit: EXP_SCALE, - pancakePool: this.simplePair.address, - isBnbBased: true, - isReversedPool: false, - anchorPeriod: 10, - }; - const config2 = { - asset: await token.address, - baseUnit: EXP_SCALE, - pancakePool: this.simplePair.address, - isBnbBased: false, - isReversedPool: true, - anchorPeriod: 100, - }; - await this.twapOracle.setTokenConfig(config1); - expect((await this.twapOracle.tokenConfigs(this.wBnb.address)).anchorPeriod).to.equal(10); - await this.twapOracle.setTokenConfig(config2); - expect((await this.twapOracle.tokenConfigs(await token.address)).anchorPeriod).to.equal(100); - }); - - it("token config added successfully & events check", async function () { - const config = { - asset: this.wBnb.address, - baseUnit: EXP_SCALE, - pancakePool: this.simplePair.address, - isBnbBased: false, - isReversedPool: false, - anchorPeriod: 888, - }; - const result = await this.twapOracle.setTokenConfig(config); - await expect(result) - .to.emit(this.twapOracle, "TokenConfigAdded") - .withArgs(await this.wBnb.address, this.simplePair.address, 888); - - // starting accumulative price - const ts = await getTime(); - const acc = Q112.mul(ts); - await checkObservations(this.twapOracle, await this.wBnb.address, ts, acc, 0); - }); - }); - - describe("batch add token configs", () => { - it("length check", async function () { - await expect(this.twapOracle.setTokenConfigs([])).to.be.revertedWith("length can't be 0"); - }); - - it("token config added successfully & data check", async function () { - const config = { - asset: this.wBnb.address, - baseUnit: EXP_SCALE, - pancakePool: this.simplePair.address, - isBnbBased: false, - isReversedPool: false, - anchorPeriod: 888, - }; - await this.twapOracle.setTokenConfigs([config]); - const savedConfig = await this.twapOracle.tokenConfigs(this.wBnb.address); - expect(savedConfig.anchorPeriod).to.equal(888); - expect(savedConfig.asset).to.equal(this.wBnb.address); - expect(savedConfig.pancakePool).to.equal(this.simplePair.address); - expect(savedConfig.baseUnit).to.equal(EXP_SCALE); - }); - }); - }); - - describe("update twap", () => { - beforeEach(async function () { - const token0 = await makeToken("ETH", "ETH"); - const token1 = await makeToken("MATIC", "MATIC"); - - // this. simplePair = await makePairWithTokens(token0.address, token1.address); - - this.tokenConfig = { - asset: await token0.address, - baseUnit: EXP_SCALE, - pancakePool: this.simplePair.address, - isBnbBased: false, - isReversedPool: false, - anchorPeriod: 900, // 15min - }; - this.token0 = token0; - this.token1 = token1; - await this.twapOracle.setTokenConfig(this.tokenConfig); - }); - - it("revert if get underlying price of not existing token", async function () { - await expect(this.twapOracle.getPrice(this.token1.address)).to.be.revertedWith("asset not exist"); - }); - - it("revert if get underlying price of token has not been updated", async function () { - await expect(this.twapOracle.getPrice(this.token0.address)).to.be.revertedWith("TWAP price must be positive"); - }); - - it("twap update after multiple observations", async function () { - const ts = await getTime(); - const acc = Q112.mul(ts); - const price = 1; - await checkObservations(this.twapOracle, await this.token0.address, ts, acc, 0); // - await increaseTime(100); - await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - - await increaseTime(801); - const result = await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - // window changed - const timeDelta = 801 + 100 + 1 + 1; - await checkObservations( - this.twapOracle, - await this.token0.address, - ts + timeDelta, - acc.add(Q112.mul(timeDelta).mul(price)), - 2, - ); - await expect(result) - .to.emit(this.twapOracle, "TwapWindowUpdated") - .withArgs( - await this.token0.address, - ts + 101, - acc.add(Q112.mul(101)), - ts + timeDelta, - acc.add(Q112.mul(timeDelta)), - ); - }); - - it("should delete observation which does not fall in current window and add latest observation", async function () { - const ts = await getTime(); - const acc = Q112.mul(ts); - await checkObservations(this.twapOracle, await this.token0.address, ts, acc, 0); - await increaseTime(100); - await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - await increaseTime(801); - await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - // window changed - const firstObservation = await this.twapOracle.observations(this.token0.address, 0); - expect(firstObservation.acc).to.be.equal(0); - const lastObservation = await this.twapOracle.observations(this.token0.address, 2); - expect(lastObservation.timestamp).be.closeTo(BigNumber.from(ts + 903), 1); - }); - - it("should pick last available observation if none observations are in window and also delete privious one", async function () { - const ts = await getTime(); - const acc = Q112.mul(ts); - await checkObservations(this.twapOracle, await this.token0.address, ts, acc, 0); - await increaseTime(901); - // window changed - const firstObservation = await this.twapOracle.observations(this.token0.address, 0); - expect(firstObservation.timestamp).to.be.equal(ts); - - const result1 = await this.twapOracle.updateTwap(this.token0.address); - await expect(result1) - .to.emit(this.twapOracle, "TwapWindowUpdated") - .withArgs(await this.token0.address, ts, acc, ts + 902, acc.add(Q112.mul(902))); - const windowStartIndex = await this.twapOracle.windowStart(this.token0.address); - expect(windowStartIndex).to.be.equal(0); - - const secondObservation = await this.twapOracle.observations(this.token0.address, 1); - expect(secondObservation.timestamp).to.be.equal(ts + 902); - await increaseTime(901); - // window changed - await this.twapOracle.updateTwap(this.token0.address); - const firstObservationAfter = await this.twapOracle.observations(this.token0.address, 0); - expect(firstObservationAfter.timestamp).to.be.equal(0); - }); - - it("should add latest observation after delete observations which does not fall in current window", async function () { - const ts = await getTime(); - const acc = Q112.mul(ts); - await checkObservations(this.twapOracle, await this.token0.address, ts, acc, 0); - await increaseTime(100); - await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - await increaseTime(801); - await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - // window changed - const firstObservation = await this.twapOracle.observations(this.token0.address, 0); - expect(firstObservation.acc).to.be.equal(0); - const lastObservation = await this.twapOracle.observations(this.token0.address, 2); - expect(lastObservation.timestamp).be.closeTo(BigNumber.from(ts + 903), 1); - }); - - it("should delete multiple observation and pick observation which falling under window", async function () { - const initialTs = await getTime(); - const acc = Q112.mul(initialTs); - await checkObservations(this.twapOracle, await this.token0.address, initialTs, acc, 0); - - const secondTs = initialTs + 100; - await increaseTo(secondTs); - await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - - const thirdTs = secondTs + 100; - await increaseTo(thirdTs); - await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - - const fourthTs = thirdTs + 100; - await increaseTo(fourthTs); - await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - - const fifthTs = fourthTs + 100; - await increaseTo(fifthTs); - await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - - const sixthTs = fifthTs + 600; - await increaseTo(sixthTs); - await this.twapOracle.updateTwap(this.token0.address); // timestamp + 1 - - // window changed - const firstObservation = await this.twapOracle.observations(this.token0.address, 0); - expect(firstObservation.timestamp).to.be.equal(0); - const secondObservation = await this.twapOracle.observations(this.token0.address, 1); - expect(secondObservation.timestamp).to.be.equal(secondTs + 1); - const thirdObservation = await this.twapOracle.observations(this.token0.address, 2); - expect(thirdObservation.timestamp).to.be.equal(thirdTs + 1); - const lastObservation = await this.twapOracle.observations(this.token0.address, 5); - expect(lastObservation.timestamp).to.be.equal(sixthTs + 1); - }); - it("cumulative value", async function () { - const currentTimestamp = await getTime(); - const acc = Q112.mul(currentTimestamp); - let cp = await this.twapOracle.currentCumulativePrice(this.tokenConfig); - // initial acc - expect(cp).to.equal(acc); - - await increaseTime(100); - cp = await this.twapOracle.currentCumulativePrice(this.tokenConfig); - // increase the time but don't update the pair - const acc1 = acc.add(Q112.mul(100)); - expect(cp).be.closeTo(BigNumber.from(acc1), 100); - - // update the pair to update the timestamp, and test again - await this.simplePair.update(100, 100, 100, 100); // timestamp + 1 - cp = await this.twapOracle.currentCumulativePrice(this.tokenConfig); - const acc2 = acc1.add(Q112); - expect(cp).to.equal(acc2); - - // change reserves, increase the time, and test again - await increaseTime(33); - await this.simplePair.update(200, 100, 200, 100); // timestamp + 1 - cp = await this.twapOracle.currentCumulativePrice(this.tokenConfig); - const acc3 = acc2.add( - Q112.mul(100) - .div(200) - .mul(33 + 1), - ); - expect(cp).be.closeTo(acc3, 100); - - // change reserves, increase the time, and test again - await increaseTime(66); - await this.simplePair.update(100, 400, 100, 400); // timestamp + 1 - cp = await this.twapOracle.currentCumulativePrice(this.tokenConfig); - const acc4 = acc3.add( - Q112.mul(400) - .div(100) - .mul(66 + 1), - ); - expect(cp).to.equal(acc4); - }); - - it("test reversed pair", async function () { - // choose another token - const reserves = await this.simplePair.getReserves(); - const lastPrice = await this.simplePair.price1CumulativeLast(); - - const time = await getTime(); - const spread = Q112.mul(reserves[0]).div(Q112.mul(reserves[1])); - let acc = spread.mul(Q112.mul(time - reserves[2])); - - const config = { - asset: await this.token1.address, - baseUnit: EXP_SCALE, - pancakePool: this.simplePair.address, - isBnbBased: false, - isReversedPool: true, - anchorPeriod: 900, // 15min - }; - // initial acc - let cp = await this.twapOracle.currentCumulativePrice(config); - - expect(cp).to.equal(acc.add(lastPrice)); - - await increaseTime(100); - cp = await this.twapOracle.currentCumulativePrice(config); - acc = spread.mul(Q112.mul(time - reserves[2] + 100)); - expect(cp).be.closeTo(acc.add(lastPrice), 100); - - const oldPrice = await this.simplePair.price1CumulativeLast(); - - const pairLastTime = (await this.simplePair.getReserves())[2]; - const deltaTime = (await getTime()) - pairLastTime + 1; - - // update the pair to update the timestamp, and test again - await this.simplePair.update(200, 100, 200, 100); // timestamp + 1 - - cp = await this.twapOracle.currentCumulativePrice(config); - - const newSpread = Q112.mul(200).div(Q112.mul(100)); - acc = newSpread.mul(Q112.mul(deltaTime)); - - expect(cp).to.equal(oldPrice.add(acc)); - }); - - it("twap calculation for non BNB based token", async function () { - let ts1 = await getTime(); - await this.simplePair.update(200, 100, 100, 100); - let [cp0, pairLastTime] = [ - await this.simplePair.price0CumulativeLast(), - (await this.simplePair.getReserves())[2], - ]; - - await increaseTime(1000); - - let result = await this.twapOracle.updateTwap(this.token0.address); - let ts2 = await getTime(); - let oldObservation = await this.twapOracle.observations(await this.token0.address, 0); - let newAcc = Q112.mul(100) - .div(200) - .mul(ts2 - pairLastTime) - .add(cp0); - let oldAcc = oldObservation.acc; - - let avgPrice0 = newAcc - .sub(oldAcc) - .div(RATIO) - .div(ts2 - oldObservation.timestamp.toNumber()); - - await expect(result) - .to.emit(this.twapOracle, "TwapWindowUpdated") - .withArgs(await this.token0.address, oldObservation.timestamp, oldObservation.acc, ts2, newAcc); - await expect(result) - .to.emit(this.twapOracle, "AnchorPriceUpdated") - .withArgs(await this.token0.address, avgPrice0, ts1, ts2); - - // check saved price - let price = await this.twapOracle.getPrice(this.token0.address); - expect(price).to.equal(avgPrice0); - - // ============= increase another 888, price change ============ - ts1 = await getTime(); - await this.simplePair.update(2000, 100, 200, 100); - [cp0, pairLastTime] = [await this.simplePair.price0CumulativeLast(), (await this.simplePair.getReserves())[2]]; - - await increaseTime(888); - - result = await this.twapOracle.updateTwap(this.token0.address); - ts2 = await getTime(); - oldObservation = await this.twapOracle.observations(await this.token0.address, 1); - newAcc = Q112.mul(100) - .div(2000) - .mul(ts2 - pairLastTime) - .add(cp0); - oldAcc = oldObservation.acc; - avgPrice0 = newAcc - .sub(oldAcc) - .div(RATIO) - .div(ts2 - oldObservation.timestamp.toNumber()); - - // >>> No TwapWindowUpdated event emitted <<< - - // old timestamp should be the timestamp of old observation - await expect(result) - .to.emit(this.twapOracle, "AnchorPriceUpdated") - .withArgs(await this.token0.address, avgPrice0, oldObservation.timestamp, ts2); - - // check saved price - price = await this.twapOracle.getPrice(this.token0.address); - expect(price).to.equal(avgPrice0); - - // @todo: maybe one more test - increase time no greater than anchorPeriod, nothing happen - }); - - describe("twap calculation for BNB based token", () => { - beforeEach(async function () { - // add bnb pair config - - const token0 = await makeToken("ETH1", "ETH1"); - const token1 = await makeToken("MATIC1", "MATIC1"); - this.tokenConfig = { - asset: await token0.address, - baseUnit: EXP_SCALE, - pancakePool: this.bnbBasedPair.address, - isBnbBased: true, - isReversedPool: false, - anchorPeriod: 900, // 15min - }; - // prepare busd-bnb config - this.bnbConfig = { - asset: this.wBnb.address, - baseUnit: EXP_SCALE, - pancakePool: this.bnbPair.address, - isBnbBased: false, - isReversedPool: true, - anchorPeriod: 600, // 10min - }; - this.token0 = token0; - this.token1 = token1; - await this.twapOracle.setTokenConfig(this.tokenConfig); - }); - it("if no BNB config is added, revert", async function () { - await expect(this.twapOracle.updateTwap(this.token0.address)).to.be.revertedWith("WBNB not exist"); - }); - - it("twap calculation", async function () { - await this.twapOracle.setTokenConfig(this.bnbConfig); - await this.bnbPair.update(1000, 100, 100, 100); // bnb: $10 - await this.bnbBasedPair.update(200, 100, 100, 100); // token: 0.5bnb - - // this only trigger bnb price update - await increaseTime(666); - - // update bnb based pair - let [cp0, pairLastTime] = [ - await this.bnbBasedPair.price0CumulativeLast(), - (await this.bnbBasedPair.getReserves())[2], - ]; - - await this.twapOracle.updateTwap(this.token0.address); - let oldObservation = await this.twapOracle.observations(await this.token0.address, 0); - - // get bnb price here, after token0 twap updated, during which bnb price got updated again - let bnbPrice = await this.twapOracle.getPrice(this.bnbAddr); - - let ts2 = await getTime(); - let newAcc = Q112.mul(100) - .div(200) - .mul(ts2 - pairLastTime) - .add(cp0); - let oldAcc = oldObservation.acc; - let avgPrice0InBnb = newAcc - .sub(oldAcc) - .div(RATIO) - .div(ts2 - oldObservation.timestamp.toNumber()); - let expectedPrice = avgPrice0InBnb.mul(bnbPrice).div(EXP_SCALE); - expect(expectedPrice).to.equal(await this.twapOracle.getPrice(this.token0.address)); - - // increase time and test again - await increaseTime(800); - [cp0, pairLastTime] = [ - await this.bnbBasedPair.price0CumulativeLast(), - (await this.bnbBasedPair.getReserves())[2], - ]; - - await this.twapOracle.updateTwap(this.token0.address); - - oldObservation = await this.twapOracle.observations(await this.token0.address, 1); - bnbPrice = await this.twapOracle.getPrice(this.bnbAddr); - ts2 = await getTime(); - newAcc = Q112.mul(100) - .div(200) - .mul(ts2 - pairLastTime) - .add(cp0); - oldAcc = oldObservation.acc; - avgPrice0InBnb = newAcc - .sub(oldAcc) - .div(RATIO) - .div(ts2 - oldObservation.timestamp.toNumber()); - expectedPrice = avgPrice0InBnb.mul(bnbPrice).div(EXP_SCALE); - expect(expectedPrice).to.equal(await this.twapOracle.getPrice(this.token0.address)); - }); - }); - }); - - describe("validation", () => { - it("validate price", async function () { - const token2 = await makeToken("BNB2", "BNB2"); - - const validationConfig = { - asset: await this.token1.address, - upperBoundRatio: EXP_SCALE.mul(12).div(10), - lowerBoundRatio: EXP_SCALE.mul(8).div(10), - }; - await this.boundValidator.setValidateConfigs([validationConfig]); - - // sanity check - await expect(this.boundValidator.validatePriceWithAnchorPrice(token2.address, 100, 100)).to.be.revertedWith( - "validation config not exist", - ); - - const tokenConfig = { - asset: await this.token1.address, - baseUnit: EXP_SCALE, - pancakePool: this.simplePair.address, - isBnbBased: false, - isReversedPool: true, - anchorPeriod: 900, // 15min - }; - await this.twapOracle.setTokenConfig(tokenConfig); - - // without updateTwap the price is not written and should revert - await expect(this.twapOracle.getPrice(this.token1.address)).to.be.revertedWith("TWAP price must be positive"); - - await this.twapOracle.updateTwap(this.token1.address); - - let validateResult = await this.boundValidator.validatePriceWithAnchorPrice( - this.token1.address, - EXP_SCALE, - await this.twapOracle.getPrice(this.token1.address), - ); - expect(validateResult).to.equal(true); - validateResult = await this.boundValidator.validatePriceWithAnchorPrice( - this.token1.address, - EXP_SCALE.mul(100).div(79), - await this.twapOracle.getPrice(this.token1.address), - ); - expect(validateResult).to.equal(false); - validateResult = await this.boundValidator.validatePriceWithAnchorPrice( - this.token1.address, - EXP_SCALE.mul(100).div(121), - await this.twapOracle.getPrice(this.token1.address), - ); - expect(validateResult).to.equal(false); - }); - }); -}); diff --git a/test/WstETHOracle.ts b/test/WstETHOracle.ts index 6fa961af..4644ee30 100755 --- a/test/WstETHOracle.ts +++ b/test/WstETHOracle.ts @@ -11,56 +11,79 @@ const { expect } = chai; chai.use(smock.matchers); const WSTETH = ADDRESSES.ethereum.wstETHAddress; -const WETH = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"; +const WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; const WETH_USD_PRICE = parseUnits("2500", 18); // 2500 USD for 1 WETH -const WETH_USD_PRICE_DENOMINATOR = parseUnits("1", 18); +const STETH_USD_PRICE = parseUnits("1500", 18); // 1500 USD for 1 stETH +const PRICE_DENOMINATOR = parseUnits("1", 18); const STETH_AMOUNT_FOR_ONE_WSTETH = parseUnits("1.15", 18); // 1.5 stETH for 1 wETH describe("WstETHOracle unit tests", () => { let stETHMock; let resilientOracleMock; - let wstETHOracle; + let wstETHOracleEquivalentRatio; + let wstETHOracleNonEquivalentRatio; let WsETHOracleFactory; before(async () => { // To initialize the provider we need to hit the node with any request await ethers.getSigners(); resilientOracleMock = await smock.fake("ResilientOracleInterface"); - resilientOracleMock.getPrice.returns(WETH_USD_PRICE); stETHMock = await smock.fake("IStETH"); stETHMock.getPooledEthByShares.returns(STETH_AMOUNT_FOR_ONE_WSTETH); WsETHOracleFactory = await ethers.getContractFactory("WstETHOracle"); + + resilientOracleMock.getPrice.whenCalledWith(WETH).returns(WETH_USD_PRICE); + resilientOracleMock.getPrice.whenCalledWith(stETHMock.address).returns(STETH_USD_PRICE); }); describe("deployment", () => { it("revert if wstETH address is 0", async () => { - await expect(WsETHOracleFactory.deploy(addr0000, WETH, stETHMock.address, resilientOracleMock.address)).to.be - .reverted; + await expect(WsETHOracleFactory.deploy(addr0000, WETH, stETHMock.address, resilientOracleMock.address, true)).to + .be.reverted; }); it("revert if WETH address is 0", async () => { - await expect(WsETHOracleFactory.deploy(WSTETH, addr0000, stETHMock.address, resilientOracleMock.address)).to.be - .reverted; + await expect(WsETHOracleFactory.deploy(WSTETH, addr0000, stETHMock.address, resilientOracleMock.address, true)).to + .be.reverted; }); it("revert if stETH address is 0", async () => { - await expect(WsETHOracleFactory.deploy(WSTETH, WETH, addr0000, resilientOracleMock.address)).to.be.reverted; + await expect(WsETHOracleFactory.deploy(WSTETH, WETH, addr0000, resilientOracleMock.address, true)).to.be.reverted; }); it("revert if ResilientOracle address is 0", async () => { - await expect(WsETHOracleFactory.deploy(WSTETH, WETH, stETHMock.address, addr0000)).to.be.reverted; + await expect(WsETHOracleFactory.deploy(WSTETH, WETH, stETHMock.address, addr0000, true)).to.be.reverted; }); it("should deploy contract", async () => { - wstETHOracle = await WsETHOracleFactory.deploy(WSTETH, WETH, stETHMock.address, resilientOracleMock.address); + wstETHOracleEquivalentRatio = await WsETHOracleFactory.deploy( + WSTETH, + WETH, + stETHMock.address, + resilientOracleMock.address, + true, + ); + wstETHOracleNonEquivalentRatio = await WsETHOracleFactory.deploy( + WSTETH, + WETH, + stETHMock.address, + resilientOracleMock.address, + false, + ); }); }); describe("getPrice", () => { it("revert if wstETH address is wrong", async () => { - await expect(wstETHOracle.getPrice(addr0000)).to.be.revertedWith("wrong wstETH address"); + await expect(wstETHOracleEquivalentRatio.getPrice(addr0000)).to.be.revertedWith("wrong wstETH address"); }); - it("should get correct price", async () => { - const expectedPrice = WETH_USD_PRICE.mul(STETH_AMOUNT_FOR_ONE_WSTETH).div(WETH_USD_PRICE_DENOMINATOR); - expect(await wstETHOracle.getPrice(WSTETH)).to.equal(expectedPrice); + it("should get correct price assuming 1/1 ratio", async () => { + const expectedPrice = WETH_USD_PRICE.mul(STETH_AMOUNT_FOR_ONE_WSTETH).div(PRICE_DENOMINATOR); + expect(await wstETHOracleEquivalentRatio.getPrice(WSTETH)).to.equal(expectedPrice); + expect(resilientOracleMock.getPrice.atCall(0)).to.have.been.calledWith(WETH); + }); + it("should get correct price not assuming 1/1 ratio", async () => { + const expectedPrice = STETH_USD_PRICE.mul(STETH_AMOUNT_FOR_ONE_WSTETH).div(PRICE_DENOMINATOR); + expect(await wstETHOracleNonEquivalentRatio.getPrice(WSTETH)).to.equal(expectedPrice); + expect(resilientOracleMock.getPrice.atCall(1)).to.have.been.calledWith(stETHMock.address); }); }); }); diff --git a/test/fork/core-compatibility.ts b/test/fork/core-compatibility.ts index 4825e2f8..594d96a0 100644 --- a/test/fork/core-compatibility.ts +++ b/test/fork/core-compatibility.ts @@ -25,8 +25,6 @@ import { PythOracle__factory, ResilientOracle, ResilientOracle__factory, - TwapOracle, - TwapOracle__factory, } from "../../typechain-types"; const DEFAULT_PRICE = "1000000000000000000"; // $1 @@ -40,7 +38,6 @@ interface OracleFixture { boundValidator: BoundValidator; chainlinkOracle: ChainlinkOracle | undefined; redStoneOracle: ChainlinkOracle | undefined; - twapOracle: TwapOracle | undefined; pythOracle: PythOracle | undefined; binanceOracle: BinanceOracle | undefined; } @@ -127,14 +124,6 @@ async function deployOracleFixture(): Promise { ); } - let twapOracle; - if (oraclesToDeploy.twap) { - const TwapOracleFactory: TwapOracle__factory = await ethers.getContractFactory("TwapOracle"); - twapOracle = await upgrades.deployProxy(TwapOracleFactory, [accessControlManager.address], { - constructorArgs: [networkAddresses.WBNBAddress], - }); - } - let pythOracle; if (oraclesToDeploy.pyth) { const PythOracleFactory: PythOracle__factory = await ethers.getContractFactory("PythOracle"); @@ -167,7 +156,7 @@ async function deployOracleFixture(): Promise { ); } - return { resilientOracle, boundValidator, chainlinkOracle, redStoneOracle, twapOracle, pythOracle, binanceOracle }; + return { resilientOracle, boundValidator, chainlinkOracle, redStoneOracle, pythOracle, binanceOracle }; } if (FORK) { diff --git a/test/types.ts b/test/types.ts index 10e42b0e..e68b63e2 100644 --- a/test/types.ts +++ b/test/types.ts @@ -3,7 +3,6 @@ import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signe import { BoundValidator, PythOracle } from "../typechain-types"; import { ResilientOracle } from "../typechain-types/contracts/ResilientOracle"; import { ChainlinkOracle } from "../typechain-types/contracts/oracles/ChainlinkOracle"; -import { TwapOracle } from "../typechain-types/contracts/oracles/TwapOracle"; import { MockPyth } from "../typechain-types/contracts/test/MockPyth"; import { PancakePairHarness } from "../typechain-types/contracts/test/PancakePairHarness"; @@ -14,7 +13,6 @@ declare module "mocha" { // chainlink oracle tests chainlinkOracle: ChainlinkOracle; // twap oracle tests - twapOracle: TwapOracle; simplePair: PancakePairHarness; bnbBasedPair: PancakePairHarness; bnbPair: PancakePairHarness;