Overview
S Balance
0 S
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
BeefyOracleOverride
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { BeefyOracleHelper, BeefyOracleErrors } from "./BeefyOracleHelper.sol"; /// @title Beefy Oracle Override /// @author Beefy /// @notice On-chain oracle override for use with hard to get on chain price feeds library BeefyOracleOverride { /// @notice Return 0 /// @return price Retrieved price from the Chainlink feed /// @return success Successful price fetch or not function getPrice(bytes calldata) external pure returns (uint256 price, bool success) { return (BeefyOracleHelper.scaleAmount(uint256(1000000000000000000000000), uint8(8)), true); } /// @notice Data validation function validateData(bytes calldata) external view {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Beefy Oracle Errors /// @author Beefy, @kexley /// @notice Error list for Beefy Oracles contract BeefyOracleErrors { /// @dev No response from the Chainlink feed error NoAnswer(); /// @dev No price for base token /// @param token Base token error NoBasePrice(address token); /// @dev Token is not present in the pair /// @param token Input token /// @param pair Pair token error TokenNotInPair(address token, address pair); /// @dev Array length is not correct error ArrayLength(); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IERC20MetadataUpgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; import { IBeefyOracle } from "../../interfaces/oracle/IBeefyOracle.sol"; import { BeefyOracleErrors } from "./BeefyOracleErrors.sol"; /// @title Beefy Oracle Helper /// @author Beefy, @kexley /// @notice Helper functions for Beefy oracles library BeefyOracleHelper { /// @dev Calculate the price of the output token in 18 decimals given the base token price /// and the amount out received from swapping 1 unit of the base token /// @param _oracle Central Beefy oracle which stores the base token price /// @param _token Address of token to calculate the price of /// @param _baseToken Address of the base token used in the price chain /// @param _amountOut Amount received from swapping 1 unit of base token into the target token /// @return price Price of the target token in 18 decimals function priceFromBaseToken( address _oracle, address _token, address _baseToken, uint256 _amountOut ) internal returns (uint256 price) { (uint256 basePrice,) = IBeefyOracle(_oracle).getFreshPrice(_baseToken); uint8 decimals = IERC20MetadataUpgradeable(_token).decimals(); _amountOut = scaleAmount(_amountOut, decimals); price = basePrice * 1 ether / _amountOut; } /// @dev Scale an input amount to 18 decimals /// @param _amount Amount to be scaled up or down /// @param _decimals Decimals that the amount is already in /// @return scaledAmount New scaled amount in 18 decimals function scaleAmount( uint256 _amount, uint8 _decimals ) internal pure returns (uint256 scaledAmount) { scaledAmount = _decimals == 18 ? _amount : _amount * 10 ** 18 / 10 ** _decimals; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IBeefyOracle { function getPrice(address token) external view returns (uint256 price); function getPrice(address[] calldata tokens) external view returns (uint256[] memory prices); function getFreshPrice(address token) external returns (uint256 price, bool success); function getFreshPrice(address[] calldata tokens) external returns (uint256[] memory prices, bool[] memory successes); }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"validateData","outputs":[],"stateMutability":"view","type":"function"}]
Contract Creation Code
6102d661003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100405760003560e01c80636b4dd15814610045578063a6ffa36c14610071575b600080fd5b6100586100533660046100ea565b610085565b6040805192835290151560208301520160405180910390f35b61008361007f3660046100ea565b5050565b005b60008061009d69d3c21bcecceda100000060086100a8565b946001945092505050565b60008160ff166012146100e1576100c082600a610258565b6100d284670de0b6b3a7640000610267565b6100dc919061027e565b6100e3565b825b9392505050565b600080602083850312156100fd57600080fd5b823567ffffffffffffffff8082111561011557600080fd5b818501915085601f83011261012957600080fd5b81358181111561013857600080fd5b86602082850101111561014a57600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156101ad5781600019048211156101935761019361015c565b808516156101a057918102915b93841c9390800290610177565b509250929050565b6000826101c457506001610252565b816101d157506000610252565b81600181146101e757600281146101f15761020d565b6001915050610252565b60ff8411156102025761020261015c565b50506001821b610252565b5060208310610133831016604e8410600b8410161715610230575081810a610252565b61023a8383610172565b806000190482111561024e5761024e61015c565b0290505b92915050565b60006100e360ff8416836101b5565b80820281158282048414176102525761025261015c565b60008261029b57634e487b7160e01b600052601260045260246000fd5b50049056fea26469706673582212202bdff16ecb1468bdb57b0c54442a1f38990b869be18c0a0e6b2ceb7c497d809964736f6c63430008170033
Deployed Bytecode
0x732bdf7be3e24e20a973f68baf886b25600e4ec47b30146080604052600436106100405760003560e01c80636b4dd15814610045578063a6ffa36c14610071575b600080fd5b6100586100533660046100ea565b610085565b6040805192835290151560208301520160405180910390f35b61008361007f3660046100ea565b5050565b005b60008061009d69d3c21bcecceda100000060086100a8565b946001945092505050565b60008160ff166012146100e1576100c082600a610258565b6100d284670de0b6b3a7640000610267565b6100dc919061027e565b6100e3565b825b9392505050565b600080602083850312156100fd57600080fd5b823567ffffffffffffffff8082111561011557600080fd5b818501915085601f83011261012957600080fd5b81358181111561013857600080fd5b86602082850101111561014a57600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156101ad5781600019048211156101935761019361015c565b808516156101a057918102915b93841c9390800290610177565b509250929050565b6000826101c457506001610252565b816101d157506000610252565b81600181146101e757600281146101f15761020d565b6001915050610252565b60ff8411156102025761020261015c565b50506001821b610252565b5060208310610133831016604e8410600b8410161715610230575081810a610252565b61023a8383610172565b806000190482111561024e5761024e61015c565b0290505b92915050565b60006100e360ff8416836101b5565b80820281158282048414176102525761025261015c565b60008261029b57634e487b7160e01b600052601260045260246000fd5b50049056fea26469706673582212202bdff16ecb1468bdb57b0c54442a1f38990b869be18c0a0e6b2ceb7c497d809964736f6c63430008170033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.