More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xDe67FE89...dBdd8832e The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
AnchoredViewRelay
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../IOracleRelay.sol"; /// @title implementation of compounds' AnchoredView /// @notice using a main relay and an anchor relay, the AnchoredView /// ensures that the main relay's price is within some amount of the anchor relay price /// if not, the call reverts, effectively disabling the oracle & any actions which require it contract AnchoredViewRelay is IOracleRelay { address public _anchorAddress; IOracleRelay public _anchorRelay; address public _mainAddress; IOracleRelay public _mainRelay; uint256 public _widthNumerator; uint256 public _widthDenominator; /// @notice all values set at construction time /// @param anchor_address address of OracleRelay to use as anchor /// @param main_address address of OracleRelay to use as main /// @param widthNumerator numerator of the allowable deviation width /// @param widthDenominator denominator of the allowable deviation width constructor( address anchor_address, address main_address, uint256 widthNumerator, uint256 widthDenominator ) { _anchorAddress = anchor_address; _anchorRelay = IOracleRelay(anchor_address); _mainAddress = main_address; _mainRelay = IOracleRelay(main_address); _widthNumerator = widthNumerator; _widthDenominator = widthDenominator; } /// @notice returns current value of oracle /// @return current value of oracle /// @dev implementation in getLastSecond function currentValue() external view override returns (uint256) { return getLastSecond(); } /// @notice compares the main value (chainlink) to the anchor value (uniswap v3) /// @notice the two prices must closely match +-buffer, or it will revert function getLastSecond() private view returns (uint256) { // get the main price uint256 mainValue = _mainRelay.currentValue(); require(mainValue > 0, "invalid oracle value"); // get anchor price uint256 anchorPrice = _anchorRelay.currentValue(); require(anchorPrice > 0, "invalid anchor value"); // calculate buffer uint256 buffer = (_widthNumerator * anchorPrice) / _widthDenominator; // create upper and lower bounds uint256 upperBounds = anchorPrice + buffer; uint256 lowerBounds = anchorPrice - buffer; // ensure the anchor price is within bounds require(mainValue < upperBounds, "anchor too low"); require(mainValue > lowerBounds, "anchor too high"); // return mainValue return mainValue; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; /// @title OracleRelay Interface /// @notice Interface for interacting with OracleRelay interface IOracleRelay { // returns price with 18 decimals function currentValue() external view returns (uint256); }
{ "optimizer": { "enabled": true, "runs": 200, "details": { "orderLiterals": true, "deduplicate": true, "cse": true, "yul": true } }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"anchor_address","type":"address"},{"internalType":"address","name":"main_address","type":"address"},{"internalType":"uint256","name":"widthNumerator","type":"uint256"},{"internalType":"uint256","name":"widthDenominator","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"_anchorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_anchorRelay","outputs":[{"internalType":"contract IOracleRelay","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_mainAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_mainRelay","outputs":[{"internalType":"contract IOracleRelay","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_widthDenominator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_widthNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061007d5760003560e01c8063698996f81161005b578063698996f8146100dc57806379a38ef6146100e457806388af30c3146100ed578063ac42ff101461010057600080fd5b806335d612251461008257806339ebe916146100b25780635ec6bfe5146100c5575b600080fd5b600354610095906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b600154610095906001600160a01b031681565b6100ce60055481565b6040519081526020016100a9565b6100ce610113565b6100ce60045481565b600254610095906001600160a01b031681565b600054610095906001600160a01b031681565b600061011d610122565b905090565b600080600360009054906101000a90046001600160a01b03166001600160a01b031663698996f86040518163ffffffff1660e01b815260040160206040518083038186803b15801561017357600080fd5b505afa158015610187573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101ab9190610385565b9050600081116101f95760405162461bcd60e51b8152602060048201526014602482015273696e76616c6964206f7261636c652076616c756560601b60448201526064015b60405180910390fd5b60015460408051630d3132df60e31b815290516000926001600160a01b03169163698996f8916004808301926020929190829003018186803b15801561023e57600080fd5b505afa158015610252573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102769190610385565b9050600081116102bf5760405162461bcd60e51b8152602060048201526014602482015273696e76616c696420616e63686f722076616c756560601b60448201526064016101f0565b6000600554826004546102d291906103b4565b6102dc91906103d3565b905060006102ea82846103f5565b905060006102f8838561040d565b905081851061033a5760405162461bcd60e51b815260206004820152600e60248201526d616e63686f7220746f6f206c6f7760901b60448201526064016101f0565b80851161037b5760405162461bcd60e51b815260206004820152600f60248201526e0c2dcc6d0dee440e8dede40d0d2ced608b1b60448201526064016101f0565b5092949350505050565b60006020828403121561039757600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156103ce576103ce61039e565b500290565b6000826103f057634e487b7160e01b600052601260045260246000fd5b500490565b600082198211156104085761040861039e565b500190565b60008282101561041f5761041f61039e565b50039056fea2646970667358221220aaa61d20adc2ed0d4acb4ee2606ebbd098f5c0d65f632325aa8a6ac889d3824d64736f6c63430008090033
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.