Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x3AA569B7...F16f6f5f5 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
UnilendV2oracle
Compiler Version
v0.8.2+commit.661d1103
Optimization Enabled:
Yes with 200 runs
Other Settings:
istanbul EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity 0.8.2; // SPDX-License-Identifier: MIT import "./lib/utils/Context.sol"; import "./lib/utils/math/SafeMath.sol"; import "./lib/access/Ownable.sol"; import "./lib/token/ERC20/extensions/IERC20Metadata.sol"; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } contract UnilendV2oracle is Ownable { using SafeMath for uint256; address public WETH; mapping(address => AggregatorV3Interface) private assetsOracles; event AssetOracleUpdated(address indexed asset, address indexed source); constructor(address weth) { require(weth != address(0), "UnilendV2: ZERO ADDRESS"); WETH = weth; } function setAssetOracles(address[] calldata assets, address[] calldata sources) external onlyOwner { require(assets.length == sources.length, 'INCONSISTENT_PARAMS_LENGTH'); for (uint256 i = 0; i < assets.length; i++) { assetsOracles[assets[i]] = AggregatorV3Interface(sources[i]); emit AssetOracleUpdated(assets[i], sources[i]); } } function getLatestPrice(AggregatorV3Interface priceFeed) public view returns (int) { ( /*uint80 roundID*/, int price, /*uint startedAt*/, /*uint timeStamp*/, /*uint80 answeredInRound*/ ) = priceFeed.latestRoundData(); return price; } function getChainLinkAssetPrice(address asset) public view returns (int256 price) { AggregatorV3Interface source = assetsOracles[asset]; if(address(source) != address(0)){ price = getLatestPrice(source); } } function getAssetPrice(address token1, address token0, uint amount) public view returns (uint256 _price) { int256 price0; int256 price1; uint8 decimals0; uint8 decimals1; if(token0 == WETH && token1 != WETH){ price0 = 1 ether; price1 = getChainLinkAssetPrice(token1); decimals0 = 18; decimals1 = IERC20Metadata(token1).decimals(); } else if(token0 != WETH && token1 == WETH){ price0 = getChainLinkAssetPrice(token0); price1 = 1 ether; decimals0 = IERC20Metadata(token0).decimals(); decimals1 = 18; } else { price0 = getChainLinkAssetPrice(token0); price1 = getChainLinkAssetPrice(token1); decimals0 = IERC20Metadata(token0).decimals(); decimals1 = IERC20Metadata(token1).decimals(); } if(price0 > 0 && price1 > 0){ _price = ( (amount.mul(10**decimals1).mul(uint256(price0))).div(uint256(price1)) ).div(10**decimals0); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @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 pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount ) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev 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. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
{ "remappings": [], "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "istanbul", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"source","type":"address"}],"name":"AssetOracleUpdated","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"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token1","type":"address"},{"internalType":"address","name":"token0","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getAssetPrice","outputs":[{"internalType":"uint256","name":"_price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getChainLinkAssetPrice","outputs":[{"internalType":"int256","name":"price","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract AggregatorV3Interface","name":"priceFeed","type":"address"}],"name":"getLatestPrice","outputs":[{"internalType":"int256","name":"","type":"int256"}],"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":"assets","type":"address[]"},{"internalType":"address[]","name":"sources","type":"address[]"}],"name":"setAssetOracles","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100885760003560e01c80637bc6c34e1161005b5780637bc6c34e146100e35780638da5cb5b146100f6578063ad5c46481461011b578063f2fde38b1461012e57610088565b806316345f181461008d5780633fbff512146100b35780635b2e4dc5146100c8578063715018a6146100db575b600080fd5b6100a061009b36600461086c565b610141565b6040519081526020015b60405180910390f35b6100c66100c13660046108c8565b6101c3565b005b6100a06100d6366004610888565b6103b0565b6100c6610694565b6100a06100f136600461086c565b6106ca565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100aa565b600154610103906001600160a01b031681565b6100c661013c36600461086c565b6106ff565b600080826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561017d57600080fd5b505afa158015610191573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101b59190610931565b50919450505050505b919050565b6000546001600160a01b031633146101f65760405162461bcd60e51b81526004016101ed906109a1565b60405180910390fd5b8281146102455760405162461bcd60e51b815260206004820152601a60248201527f494e434f4e53495354454e545f504152414d535f4c454e47544800000000000060448201526064016101ed565b60005b838110156103a95782828281811061027057634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610285919061086c565b600260008787858181106102a957634e487b7160e01b600052603260045260246000fd5b90506020020160208101906102be919061086c565b6001600160a01b039081168252602082019290925260400160002080546001600160a01b0319169290911691909117905582828281811061030f57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610324919061086c565b6001600160a01b031685858381811061034d57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610362919061086c565b6001600160a01b03167f126a75207b8b11156ec1f4a0ad246f458582451fc5bee4b8a729a1a68886e13260405160405180910390a3806103a181610b2c565b915050610248565b5050505050565b60015460009081908190819081906001600160a01b0388811691161480156103e657506001546001600160a01b03898116911614155b1561047d57670de0b6b3a764000093506103ff886106ca565b925060129150876001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561043e57600080fd5b505afa158015610452573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104769190610980565b905061063c565b6001546001600160a01b038881169116148015906104a857506001546001600160a01b038981169116145b1561053f576104b6876106ca565b9350670de0b6b3a76400009250866001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156104fc57600080fd5b505afa158015610510573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105349190610980565b91506012905061063c565b610548876106ca565b9350610553886106ca565b9250866001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561058e57600080fd5b505afa1580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c69190610980565b9150876001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561060157600080fd5b505afa158015610615573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106399190610980565b90505b60008413801561064c5750600083135b156106895761068661065f83600a610a3c565b61068085818861067a61067388600a610a3c565b8d9061079a565b9061079a565b906107ad565b94505b505050509392505050565b6000546001600160a01b031633146106be5760405162461bcd60e51b81526004016101ed906109a1565b6106c860006107b9565b565b6001600160a01b0380821660009081526002602052604081205490911680156106f9576106f681610141565b91505b50919050565b6000546001600160a01b031633146107295760405162461bcd60e51b81526004016101ed906109a1565b6001600160a01b03811661078e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101ed565b610797816107b9565b50565b60006107a68284610b0d565b9392505050565b60006107a682846109d6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008083601f84011261081a578182fd5b50813567ffffffffffffffff811115610831578182fd5b602083019150836020808302850101111561084b57600080fd5b9250929050565b805169ffffffffffffffffffff811681146101be57600080fd5b60006020828403121561087d578081fd5b81356107a681610b5d565b60008060006060848603121561089c578182fd5b83356108a781610b5d565b925060208401356108b781610b5d565b929592945050506040919091013590565b600080600080604085870312156108dd578081fd5b843567ffffffffffffffff808211156108f4578283fd5b61090088838901610809565b90965094506020870135915080821115610918578283fd5b5061092587828801610809565b95989497509550505050565b600080600080600060a08688031215610948578081fd5b61095186610852565b945060208601519350604086015192506060860151915061097460808701610852565b90509295509295909350565b600060208284031215610991578081fd5b815160ff811681146107a6578182fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000826109f157634e487b7160e01b81526012600452602481fd5b500490565b80825b6001808611610a085750610a33565b818704821115610a1a57610a1a610b47565b80861615610a2757918102915b9490941c9380026109f9565b94509492505050565b60006107a660001960ff851684600082610a58575060016107a6565b81610a65575060006107a6565b8160018114610a7b5760028114610a8557610ab2565b60019150506107a6565b60ff841115610a9657610a96610b47565b6001841b915084821115610aac57610aac610b47565b506107a6565b5060208310610133831016604e8410600b8410161715610ae5575081810a83811115610ae057610ae0610b47565b6107a6565b610af284848460016109f6565b808604821115610b0457610b04610b47565b02949350505050565b6000816000190483118215151615610b2757610b27610b47565b500290565b6000600019821415610b4057610b40610b47565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461079757600080fdfea264697066735822122087a8a0509c2c7b5f2251131c7dde556dd7533220e04ea23d57803cc8a0e81cd264736f6c63430008020033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.