Contract
0xfA3E7d864cf426381aF1A990FD2E19d56b03dF33
3
Contract Overview
Balance:
0 ETH
ETH Value:
$0.00
My Name Tag:
Not Available
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x17391342a79bcdcfd03883f7f626d5a29cae891f9d2dc409c96977959644c724 | 0x60806040 | 31062459 | 164 days 3 hrs ago | 0x24bd16b990f3a376712f4fce6c5fcb05a3db3745 | IN | Create: Converter | 0 ETH | 0.00022537 |
[ Download CSV Export ]
Latest 18 internal transactions
[ Download CSV Export ]
Contract Name:
Converter
Compiler Version
v0.7.6+commit.7338295f
Contract Source Code (Solidity)
/** *Submitted for verification at Arbiscan on 2022-10-19 */ // Sources flattened with hardhat v2.9.6 https://hardhat.org // File contracts/libraries/SafeMath.sol //SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @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 add(a, b, "SafeMath: addition overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, errorMessage); return c; } /** * @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 sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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 mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File contracts/interfaces/ERC20Interface.sol pragma solidity ^0.7.0; interface ERC20Interface { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the bep token owner. */ function getOwner() external view returns (address); /** * @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); } // File contracts/interfaces/PriceOracle.sol pragma solidity ^0.7.0; abstract contract PriceOracle { /// @notice Indicator that this is a PriceOracle contract (for inspection) bool public constant isPriceOracle = true; /** * @notice Get the underlying price of a cToken asset * @param market The cToken to get the underlying price of * @return The underlying asset price mantissa (scaled by 1e18). * Zero means the price is unavailable. */ function getUnderlyingPrice(address market) external virtual view returns (uint); } // File contracts/Converter.sol pragma solidity ^0.7.0; contract Converter { using SafeMath for uint256; function convertUsdAmountToAssetAmount( uint256 usdAmount, address assetAddress ) public view returns (uint256) { ERC20Interface token = ERC20Interface(assetAddress); uint256 tokenDecimal = uint256(token.decimals()); uint256 defaultDecimal = 18; if (defaultDecimal == tokenDecimal) { return usdAmount; } else if (defaultDecimal > tokenDecimal) { return usdAmount.div(10**(defaultDecimal.sub(tokenDecimal))); } else { return usdAmount.mul(10**(tokenDecimal.sub(defaultDecimal))); } } function convertAssetAmountToUsdAmount( uint256 assetAmount, address assetAddress ) public view returns (uint256) { ERC20Interface token = ERC20Interface(assetAddress); uint256 tokenDecimal = uint256(token.decimals()); uint256 defaultDecimal = 18; if (defaultDecimal == tokenDecimal) { return assetAmount; } else if (defaultDecimal > tokenDecimal) { return assetAmount.mul(10**(defaultDecimal.sub(tokenDecimal))); } else { return assetAmount.div(10**(tokenDecimal.sub(defaultDecimal))); } } function getUsdAmount( address market, uint256 assetAmount, address priceOracle ) public view returns (uint256 usdAmount) { uint256 usdPrice = PriceOracle(priceOracle).getUnderlyingPrice(market); require(usdPrice > 0, "upe"); usdAmount = (assetAmount.mul(usdPrice)).div(10**8); } // verified not function getAssetAmount( address market, uint256 usdAmount, address priceOracle ) public view returns (uint256 assetAmount) { uint256 usdPrice = PriceOracle(priceOracle).getUnderlyingPrice(market); require(usdPrice > 0, "usd price error"); assetAmount = (usdAmount.mul(10**8)).div(usdPrice); } }
[{"inputs":[{"internalType":"uint256","name":"assetAmount","type":"uint256"},{"internalType":"address","name":"assetAddress","type":"address"}],"name":"convertAssetAmountToUsdAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdAmount","type":"uint256"},{"internalType":"address","name":"assetAddress","type":"address"}],"name":"convertUsdAmountToAssetAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"usdAmount","type":"uint256"},{"internalType":"address","name":"priceOracle","type":"address"}],"name":"getAssetAmount","outputs":[{"internalType":"uint256","name":"assetAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"assetAmount","type":"uint256"},{"internalType":"address","name":"priceOracle","type":"address"}],"name":"getUsdAmount","outputs":[{"internalType":"uint256","name":"usdAmount","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5061067f806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806348a2508414610051578063788e10b814610099578063791f99a5146100cf5780639b4863d2146100fb575b600080fd5b6100876004803603606081101561006757600080fd5b506001600160a01b03813581169160208101359160409091013516610127565b60408051918252519081900360200190f35b610087600480360360608110156100af57600080fd5b506001600160a01b0381358116916020810135916040909101351661020a565b610087600480360360408110156100e557600080fd5b50803590602001356001600160a01b03166102d2565b6100876004803603604081101561011157600080fd5b50803590602001356001600160a01b031661039f565b600080826001600160a01b031663fc57d4df866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561017757600080fd5b505afa15801561018b573d6000803e3d6000fd5b505050506040513d60208110156101a157600080fd5b50519050806101e9576040805162461bcd60e51b815260206004820152600f60248201526e3ab9b210383934b1b29032b93937b960891b604482015290519081900360640190fd5b610201816101fb866305f5e100610448565b906104a8565b95945050505050565b600080826001600160a01b031663fc57d4df866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561025a57600080fd5b505afa15801561026e573d6000803e3d6000fd5b505050506040513d602081101561028457600080fd5b50519050806102c0576040805162461bcd60e51b815260206004820152600360248201526275706560e81b604482015290519081900360640190fd5b6102016305f5e1006101fb8684610448565b6000808290506000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561031357600080fd5b505afa158015610327573d6000803e3d6000fd5b505050506040513d602081101561033d57600080fd5b505160ff16905060128082141561035957859350505050610399565b818111156103825761037861036e82846104ea565b8790600a0a610448565b9350505050610399565b61037861038f83836104ea565b8790600a0a6104a8565b92915050565b6000808290506000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156103e057600080fd5b505afa1580156103f4573d6000803e3d6000fd5b505050506040513d602081101561040a57600080fd5b505160ff16905060128082141561042657859350505050610399565b8181111561043b5761037861038f82846104ea565b61037861036e83836104ea565b60008261045757506000610399565b8282028284828161046457fe5b04146104a15760405162461bcd60e51b81526004018080602001828103825260218152602001806106296021913960400191505060405180910390fd5b9392505050565b60006104a183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061052c565b60006104a183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506105ce565b600081836105b85760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561057d578181015183820152602001610565565b50505050905090810190601f1680156105aa5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816105c457fe5b0495945050505050565b600081848411156106205760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561057d578181015183820152602001610565565b50505090039056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220cfaf65c8e7243b8bf36dbc348569d2f5635f94e756b4c7208b3d57fc1241404264736f6c63430007060033
Deployed ByteCode Sourcemap
9301:2041:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10982:357;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;10982:357:0;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;10610:343;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;10610:343:0;;;;;;;;;;;;;;;;;:::i;9982:620::-;;;;;;;;;;;;;;;;-1:-1:-1;9982:620:0;;;;;;-1:-1:-1;;;;;9982:620:0;;:::i;9362:612::-;;;;;;;;;;;;;;;;-1:-1:-1;9362:612:0;;;;;;-1:-1:-1;;;;;9362:612:0;;:::i;10982:357::-;11117:19;11149:16;11180:11;-1:-1:-1;;;;;11168:43:0;;11212:6;11168:51;;;;;;;;;;;;;-1:-1:-1;;;;;11168:51:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;11168:51:0;;-1:-1:-1;11238:12:0;11230:40;;;;;-1:-1:-1;;;11230:40:0;;;;;;;;;;;;-1:-1:-1;;;11230:40:0;;;;;;;;;;;;;;;11295:36;11322:8;11296:20;:9;11310:5;11296:13;:20::i;:::-;11295:26;;:36::i;:::-;11281:50;10982:357;-1:-1:-1;;;;;10982:357:0:o;10610:343::-;10745:17;10775:16;10806:11;-1:-1:-1;;;;;10794:43:0;;10838:6;10794:51;;;;;;;;;;;;;-1:-1:-1;;;;;10794:51:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;10794:51:0;;-1:-1:-1;10864:12:0;10856:28;;;;;-1:-1:-1;;;10856:28:0;;;;;;;;;;;;-1:-1:-1;;;10856:28:0;;;;;;;;;;;;;;;10907:38;10939:5;10908:25;:11;10924:8;10908:15;:25::i;9982:620::-;10110:7;10130:20;10168:12;10130:51;;10192:20;10223:5;-1:-1:-1;;;;;10223:14:0;;:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;10223:16:0;10215:25;;;-1:-1:-1;10276:2:0;10293:30;;;10289:306;;;10347:11;10340:18;;;;;;;10289:306;10397:12;10380:14;:29;10376:219;;;10433:55;10454:32;:14;10473:12;10454:18;:32::i;:::-;10433:11;;10449:2;:38;10433:15;:55::i;:::-;10426:62;;;;;;;10376:219;10528:55;10549:32;:12;10566:14;10549:16;:32::i;:::-;10528:11;;10544:2;:38;10528:15;:55::i;9982:620::-;;;;;:::o;9362:612::-;9488:7;9508:20;9546:12;9508:51;;9570:20;9601:5;-1:-1:-1;;;;;9601:14:0;;:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;9601:16:0;9593:25;;;-1:-1:-1;9654:2:0;9671:30;;;9667:300;;;9725:9;9718:16;;;;;;;9667:300;9773:12;9756:14;:29;9752:215;;;9809:53;9828:32;:14;9847:12;9828:18;:32::i;9752:215::-;9902:53;9921:32;:12;9938:14;9921:16;:32::i;2635:431::-;2693:7;2922:6;2918:37;;-1:-1:-1;2946:1:0;2939:8;;2918:37;2975:5;;;2979:1;2975;:5;:1;2995:5;;;;;:10;2987:56;;;;-1:-1:-1;;;2987:56:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3059:1;2635:431;-1:-1:-1;;;2635:431:0:o;3510:126::-;3568:7;3591:39;3595:1;3598;3591:39;;;;;;;;;;;;;;;;;:3;:39::i;1821:130::-;1879:7;1902:43;1906:1;1909;1902:43;;;;;;;;;;;;;;;;;:3;:43::i;4100:323::-;4186:7;4280:12;4273:5;4265:28;;;;-1:-1:-1;;;4265:28:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4300:9;4316:1;4312;:5;;;;;;;4100:323;-1:-1:-1;;;;;4100:323:0:o;2226:178::-;2312:7;2344:12;2336:6;;;;2328:29;;;;-1:-1:-1;;;2328:29:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;2376:5:0;;;2226:178::o
Metadata Hash
cfaf65c8e7243b8bf36dbc348569d2f5635f94e756b4c7208b3d57fc12414042
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.