Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Latest 12 from a total of 12 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
Amount
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Set Price Feed F... | 30730507 | 198 days ago | IN | 0 ETH | 0.000000089671 | ||||
| Set Price Feed F... | 21709313 | 407 days ago | IN | 0 ETH | 0.000002575919 | ||||
| Set Price Feed F... | 11143069 | 651 days ago | IN | 0 ETH | 0.000004551205 | ||||
| Set Price Feed F... | 11143064 | 651 days ago | IN | 0 ETH | 0.000004383781 | ||||
| Set Price Feed F... | 11143058 | 651 days ago | IN | 0 ETH | 0.000003863333 | ||||
| Set WETH9 | 11133344 | 652 days ago | IN | 0 ETH | 0.008835921392 | ||||
| Set Price Feed F... | 11133340 | 652 days ago | IN | 0 ETH | 0.015467016727 | ||||
| Set Price Feed F... | 11133335 | 652 days ago | IN | 0 ETH | 0.014075044831 | ||||
| Set Price Feed F... | 11133245 | 652 days ago | IN | 0 ETH | 0.018868921273 | ||||
| Set Price Feed F... | 11133242 | 652 days ago | IN | 0 ETH | 0.018865973978 | ||||
| Set Price Feed F... | 11133237 | 652 days ago | IN | 0 ETH | 0.018871112522 | ||||
| Set Price Feed F... | 11133232 | 652 days ago | IN | 0 ETH | 0.018880107934 |
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x5fc2cA24...178f71451 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
MockPriceFeed
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
// external
contract MockPriceFeed {
mapping(bytes32 => uint8) public currencyKeyDecimals;
// List of currency keys for convenient iteration
bytes32[] public currencyKeys;
address public WETH9;
uint public priceForETHinUSD;
uint public defaultCollateralDecimals;
mapping(address => uint) public collateralPriceInUSD;
mapping(bytes32 => address) public collateralAddressForKey;
constructor() {
currencyKeys.push("ETH");
priceForETHinUSD = 3500 * 1e18;
}
struct RateAndUpdatedTime {
uint rate;
uint40 time;
}
function getCurrencies() external view returns (bytes32[] memory) {
return currencyKeys;
}
function getRates() external view returns (uint[] memory rates) {
rates = new uint[](currencyKeys.length);
for (uint i = 0; i < currencyKeys.length; i++) {
bytes32 currencyKey = currencyKeys[i];
rates[i] = _getRateAndUpdatedTime(currencyKey).rate;
}
}
function rateForCurrency(bytes32 currencyKey) external view returns (uint) {
return _getRateAndUpdatedTime(currencyKey).rate;
}
function transformCollateral(address _collateral, uint _collateralAmount) external view returns (uint amountInUSD) {
amountInUSD = (_collateralAmount * collateralPriceInUSD[_collateral]) / (10 ** (18 - defaultCollateralDecimals));
}
function setPriceFeedForCollateral(bytes32 _collateralKey, address _collateral, uint _priceInUSD) external {
currencyKeys.push(_collateralKey);
collateralAddressForKey[_collateralKey] = _collateral;
collateralPriceInUSD[_collateral] = _priceInUSD;
}
function setWETH9(address _WETH9) external {
WETH9 = _WETH9;
}
function setPriceForETH(uint _priceInUSD) external {
priceForETHinUSD = _priceInUSD;
}
function setDefaultCollateralDecimals(uint _decimals) external {
defaultCollateralDecimals = _decimals;
}
function _getRateAndUpdatedTime(bytes32 currencyKey) internal view returns (RateAndUpdatedTime memory) {
require(collateralAddressForKey[currencyKey] != address(0) || currencyKey == currencyKeys[0], "Invalid key");
if (currencyKey == currencyKeys[0]) {
return RateAndUpdatedTime({rate: priceForETHinUSD, time: uint40(block.timestamp)});
} else {
return
RateAndUpdatedTime({
rate: collateralPriceInUSD[collateralAddressForKey[currencyKey]],
time: uint40(block.timestamp)
});
}
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"collateralAddressForKey","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"collateralPriceInUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"currencyKeyDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"currencyKeys","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultCollateralDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrencies","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRates","outputs":[{"internalType":"uint256[]","name":"rates","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceForETHinUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"rateForCurrency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_decimals","type":"uint256"}],"name":"setDefaultCollateralDecimals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_collateralKey","type":"bytes32"},{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_priceInUSD","type":"uint256"}],"name":"setPriceFeedForCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_priceInUSD","type":"uint256"}],"name":"setPriceForETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_WETH9","type":"address"}],"name":"setWETH9","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_collateralAmount","type":"uint256"}],"name":"transformCollateral","outputs":[{"internalType":"uint256","name":"amountInUSD","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
0x608060405234801561001057600080fd5b506001805480820182556000919091526208aa8960eb1b7fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf69091015568bdbc41e0348b300000600355610861806100686000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80639accab5511610097578063ca91e18c11610066578063ca91e18c14610298578063ccc6524f146102c8578063d0bca981146102d1578063ddbdf81e146102e457600080fd5b80639accab55146102355780639ef46aa51461023d578063ac82f60814610250578063b295ad341461026357600080fd5b80634b323e7c116100d35780634b323e7c146101cc5780634e8b29ca146101df57806361c661de1461020d57806399a440f61461022257600080fd5b8063187f9311146100fa5780632720843d146101405780634aa4a4fc146101b9575b600080fd5b6101236101083660046105a0565b6006602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101b761014e3660046105d0565b600180548082019091557fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf601839055600092835260066020908152604080852080546001600160a01b039095166001600160a01b03199095168517905592845260059052912055565b005b600254610123906001600160a01b031681565b6101b76101da3660046105a0565b600455565b6101ff6101ed366004610605565b60056020526000908152604090205481565b604051908152602001610137565b6102156102ed565b6040516101379190610620565b6101ff6102303660046105a0565b610345565b610215610366565b6101ff61024b366004610664565b610420565b6101ff61025e3660046105a0565b610470565b6102866102713660046105a0565b60006020819052908152604090205460ff1681565b60405160ff9091168152602001610137565b6101b76102a6366004610605565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6101ff60035481565b6101b76102df3660046105a0565b600355565b6101ff60045481565b6060600180548060200260200160405190810160405280929190818152602001828054801561033b57602002820191906000526020600020905b815481526020019060010190808311610327575b5050505050905090565b6001818154811061035557600080fd5b600091825260209091200154905081565b60015460609067ffffffffffffffff8111156103845761038461068e565b6040519080825280602002602001820160405280156103ad578160200160208202803683370190505b50905060005b60015481101561041c576000600182815481106103d2576103d26106a4565b906000526020600020015490506103e881610482565b600001518383815181106103fe576103fe6106a4565b60209081029190910101525080610414816106d0565b9150506103b3565b5090565b6000600454601261043191906106e9565b61043c90600a6107e6565b6001600160a01b03841660009081526005602052604090205461045f90846107f2565b6104699190610809565b9392505050565b600061047b82610482565b5192915050565b60408051808201909152600080825260208201526000828152600660205260409020546001600160a01b03161515806104d8575060016000815481106104ca576104ca6106a4565b906000526020600020015482145b6105165760405162461bcd60e51b815260206004820152600b60248201526a496e76616c6964206b657960a81b604482015260640160405180910390fd5b600160008154811061052a5761052a6106a4565b9060005260206000200154820361055c57505060408051808201909152600354815264ffffffffff4216602082015290565b50604080518082018252600092835260066020908152828420546001600160a01b03168452600581529190922054825264ffffffffff42169082015290565b919050565b6000602082840312156105b257600080fd5b5035919050565b80356001600160a01b038116811461059b57600080fd5b6000806000606084860312156105e557600080fd5b833592506105f5602085016105b9565b9150604084013590509250925092565b60006020828403121561061757600080fd5b610469826105b9565b6020808252825182820181905260009190848201906040850190845b818110156106585783518352928401929184019160010161063c565b50909695505050505050565b6000806040838503121561067757600080fd5b610680836105b9565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016106e2576106e26106ba565b5060010190565b818103818111156106fc576106fc6106ba565b92915050565b600181815b8085111561073d578160001904821115610723576107236106ba565b8085161561073057918102915b93841c9390800290610707565b509250929050565b600082610754575060016106fc565b81610761575060006106fc565b816001811461077757600281146107815761079d565b60019150506106fc565b60ff841115610792576107926106ba565b50506001821b6106fc565b5060208310610133831016604e8410600b84101617156107c0575081810a6106fc565b6107ca8383610702565b80600019048211156107de576107de6106ba565b029392505050565b60006104698383610745565b80820281158282048414176106fc576106fc6106ba565b60008261082657634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220429395d5dde8b4ce491f74df0bb64409b6cb9002156fbb9eb651706125d56e0764736f6c63430008140033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80639accab5511610097578063ca91e18c11610066578063ca91e18c14610298578063ccc6524f146102c8578063d0bca981146102d1578063ddbdf81e146102e457600080fd5b80639accab55146102355780639ef46aa51461023d578063ac82f60814610250578063b295ad341461026357600080fd5b80634b323e7c116100d35780634b323e7c146101cc5780634e8b29ca146101df57806361c661de1461020d57806399a440f61461022257600080fd5b8063187f9311146100fa5780632720843d146101405780634aa4a4fc146101b9575b600080fd5b6101236101083660046105a0565b6006602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101b761014e3660046105d0565b600180548082019091557fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf601839055600092835260066020908152604080852080546001600160a01b039095166001600160a01b03199095168517905592845260059052912055565b005b600254610123906001600160a01b031681565b6101b76101da3660046105a0565b600455565b6101ff6101ed366004610605565b60056020526000908152604090205481565b604051908152602001610137565b6102156102ed565b6040516101379190610620565b6101ff6102303660046105a0565b610345565b610215610366565b6101ff61024b366004610664565b610420565b6101ff61025e3660046105a0565b610470565b6102866102713660046105a0565b60006020819052908152604090205460ff1681565b60405160ff9091168152602001610137565b6101b76102a6366004610605565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6101ff60035481565b6101b76102df3660046105a0565b600355565b6101ff60045481565b6060600180548060200260200160405190810160405280929190818152602001828054801561033b57602002820191906000526020600020905b815481526020019060010190808311610327575b5050505050905090565b6001818154811061035557600080fd5b600091825260209091200154905081565b60015460609067ffffffffffffffff8111156103845761038461068e565b6040519080825280602002602001820160405280156103ad578160200160208202803683370190505b50905060005b60015481101561041c576000600182815481106103d2576103d26106a4565b906000526020600020015490506103e881610482565b600001518383815181106103fe576103fe6106a4565b60209081029190910101525080610414816106d0565b9150506103b3565b5090565b6000600454601261043191906106e9565b61043c90600a6107e6565b6001600160a01b03841660009081526005602052604090205461045f90846107f2565b6104699190610809565b9392505050565b600061047b82610482565b5192915050565b60408051808201909152600080825260208201526000828152600660205260409020546001600160a01b03161515806104d8575060016000815481106104ca576104ca6106a4565b906000526020600020015482145b6105165760405162461bcd60e51b815260206004820152600b60248201526a496e76616c6964206b657960a81b604482015260640160405180910390fd5b600160008154811061052a5761052a6106a4565b9060005260206000200154820361055c57505060408051808201909152600354815264ffffffffff4216602082015290565b50604080518082018252600092835260066020908152828420546001600160a01b03168452600581529190922054825264ffffffffff42169082015290565b919050565b6000602082840312156105b257600080fd5b5035919050565b80356001600160a01b038116811461059b57600080fd5b6000806000606084860312156105e557600080fd5b833592506105f5602085016105b9565b9150604084013590509250925092565b60006020828403121561061757600080fd5b610469826105b9565b6020808252825182820181905260009190848201906040850190845b818110156106585783518352928401929184019160010161063c565b50909695505050505050565b6000806040838503121561067757600080fd5b610680836105b9565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016106e2576106e26106ba565b5060010190565b818103818111156106fc576106fc6106ba565b92915050565b600181815b8085111561073d578160001904821115610723576107236106ba565b8085161561073057918102915b93841c9390800290610707565b509250929050565b600082610754575060016106fc565b81610761575060006106fc565b816001811461077757600281146107815761079d565b60019150506106fc565b60ff841115610792576107926106ba565b50506001821b6106fc565b5060208310610133831016604e8410600b84101617156107c0575081810a6106fc565b6107ca8383610702565b80600019048211156107de576107de6106ba565b029392505050565b60006104698383610745565b80820281158282048414176106fc576106fc6106ba565b60008261082657634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220429395d5dde8b4ce491f74df0bb64409b6cb9002156fbb9eb651706125d56e0764736f6c63430008140033
Loading...
Loading
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.