- Contract name:
- TaxOracle
- Optimization enabled
- true
- Compiler version
- v0.6.12+commit.27d51765
- Optimization runs
- 25000
- EVM Version
- default
- Verified at
- 2022-01-16T17:16:41.793464Z
Constructor Arguments
000000000000000000000000046cb616d7a52173e4da9eff1bfd590550aa3228000000000000000000000000e44fd7fcb2b1581822d0c862b68222998a0c299a000000000000000000000000e34973e9c89a9a1d2886379ce52d32dde296ca22
Arg [0] (address) : 0x046cb616d7a52173e4da9eff1bfd590550aa3228
Arg [1] (address) : 0xe44fd7fcb2b1581822d0c862b68222998a0c299a
Arg [2] (address) : 0xe34973e9c89a9a1d2886379ce52d32dde296ca22
Contract source code
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { 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) { 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) { // 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) { 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) { 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) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); 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) { require(b <= a, "SafeMath: subtraction overflow"); 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) { 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, reverting 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) { require(b > 0, "SafeMath: division by zero"); 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) { require(b > 0, "SafeMath: modulo by zero"); 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) { 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. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * 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) { 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) { require(b > 0, errorMessage); return a % b; } } /* * @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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @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 () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), 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 { emit OwnershipTransferred(_owner, address(0)); _owner = 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"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @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); } contract TaxOracle is Ownable { using SafeMath for uint256; IERC20 public gaur; IERC20 public weth; address public pair; constructor( address _gaur, address _weth, address _pair ) public { require(_gaur != address(0), "gaur address cannot be 0"); require(_weth != address(0), "weth address cannot be 0"); require(_pair != address(0), "pair address cannot be 0"); gaur = IERC20(_gaur); weth = IERC20(_weth); pair = _pair; } function consult(address _token, uint256 _amountIn) external view returns (uint144 amountOut) { require(_token == address(gaur), "token needs to be gaur"); uint256 gaurBalance = gaur.balanceOf(pair); uint256 wethBalance = weth.balanceOf(pair); return uint144(gaurBalance.mul(_amountIn).div(wethBalance)); } function getGaurBalance() external view returns (uint256) { return gaur.balanceOf(pair); } function getWethBalance() external view returns (uint256) { return weth.balanceOf(pair); } function getPrice() external view returns (uint256) { uint256 gaurBalance = gaur.balanceOf(pair); uint256 wethBalance = weth.balanceOf(pair); return gaurBalance.mul(1e18).div(wethBalance); } function setGaur(address _gaur) external onlyOwner returns (bool) { require(_gaur != address(0), "gaur address cannot be 0"); gaur = IERC20(_gaur); return true; } function setWeth(address _weth) external onlyOwner returns (bool) { require(_weth != address(0), "weth address cannot be 0"); weth = IERC20(_weth); return true; } function setPair(address _pair) external onlyOwner returns (bool) { require(_pair != address(0), "pair address cannot be 0"); pair = _pair; return true; } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_gaur","internalType":"address"},{"type":"address","name":"_weth","internalType":"address"},{"type":"address","name":"_pair","internalType":"address"}]},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint144","name":"amountOut","internalType":"uint144"}],"name":"consult","inputs":[{"type":"address","name":"_token","internalType":"address"},{"type":"uint256","name":"_amountIn","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"gaur","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getGaurBalance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getWethBalance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pair","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setGaur","inputs":[{"type":"address","name":"_gaur","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setPair","inputs":[{"type":"address","name":"_pair","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setWeth","inputs":[{"type":"address","name":"_weth","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"weth","inputs":[]}]
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100df5760003560e01c80638da5cb5b1161008c578063a8aa1b3111610066578063a8aa1b311461022b578063b8d1452f14610233578063d3531e6d14610266578063f2fde38b1461026e576100df565b80638da5cb5b1461021357806398d5fdca1461021b5780639dd58b5814610223576100df565b8063715018a6116100bd578063715018a6146101bc578063735b49b8146101c65780638187f516146101e0576100df565b80633ddac953146100e45780633fc8cef31461014457806346c39c2714610175575b600080fd5b61011d600480360360408110156100fa57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356102a1565b6040805171ffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61014c61049c565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101a86004803603602081101561018b57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166104b8565b604080519115158252519081900360200190f35b6101c461062c565b005b6101ce610743565b60408051918252519081900360200190f35b6101a8600480360360208110156101f657600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166107ee565b61014c610964565b6101ce610980565b6101ce610aeb565b61014c610b65565b6101a86004803603602081101561024957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610b81565b61014c610cf7565b6101c46004803603602081101561028457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610d13565b60015460009073ffffffffffffffffffffffffffffffffffffffff84811691161461032d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f746f6b656e206e6565647320746f206265206761757200000000000000000000604482015290519081900360640190fd5b600154600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9283166004820152905160009392909216916370a0823191602480820192602092909190829003018186803b1580156103a757600080fd5b505afa1580156103bb573d6000803e3d6000fd5b505050506040513d60208110156103d157600080fd5b5051600254600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9283166004820152905193945060009391909216916370a08231916024808301926020929190829003018186803b15801561044f57600080fd5b505afa158015610463573d6000803e3d6000fd5b505050506040513d602081101561047957600080fd5b505190506104918161048b8487610eb4565b90610f2e565b925050505b92915050565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b60006104c2610faf565b73ffffffffffffffffffffffffffffffffffffffff166104e0610964565b73ffffffffffffffffffffffffffffffffffffffff161461056257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff82166105e457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f6761757220616464726573732063616e6e6f7420626520300000000000000000604482015290519081900360640190fd5b506001805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116178155919050565b610634610faf565b73ffffffffffffffffffffffffffffffffffffffff16610652610964565b73ffffffffffffffffffffffffffffffffffffffff16146106d457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b600154600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9283166004820152905160009392909216916370a0823191602480820192602092909190829003018186803b1580156107bd57600080fd5b505afa1580156107d1573d6000803e3d6000fd5b505050506040513d60208110156107e757600080fd5b5051905090565b60006107f8610faf565b73ffffffffffffffffffffffffffffffffffffffff16610816610964565b73ffffffffffffffffffffffffffffffffffffffff161461089857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821661091a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f7061697220616464726573732063616e6e6f7420626520300000000000000000604482015290519081900360640190fd5b506003805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff00000000000000000000000000000000000000009091161790556001919050565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b600154600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff92831660048201529051600093849316916370a08231916024808301926020929190829003018186803b1580156109f857600080fd5b505afa158015610a0c573d6000803e3d6000fd5b505050506040513d6020811015610a2257600080fd5b5051600254600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9283166004820152905193945060009391909216916370a08231916024808301926020929190829003018186803b158015610aa057600080fd5b505afa158015610ab4573d6000803e3d6000fd5b505050506040513d6020811015610aca57600080fd5b50519050610ae48161048b84670de0b6b3a7640000610eb4565b9250505090565b600254600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9283166004820152905160009392909216916370a0823191602480820192602092909190829003018186803b1580156107bd57600080fd5b60035473ffffffffffffffffffffffffffffffffffffffff1681565b6000610b8b610faf565b73ffffffffffffffffffffffffffffffffffffffff16610ba9610964565b73ffffffffffffffffffffffffffffffffffffffff1614610c2b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216610cad57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f7765746820616464726573732063616e6e6f7420626520300000000000000000604482015290519081900360640190fd5b506002805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff00000000000000000000000000000000000000009091161790556001919050565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b610d1b610faf565b73ffffffffffffffffffffffffffffffffffffffff16610d39610964565b73ffffffffffffffffffffffffffffffffffffffff1614610dbb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116610e27576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180610fb46026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600082610ec357506000610496565b82820282848281610ed057fe5b0414610f27576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180610fda6021913960400191505060405180910390fd5b9392505050565b6000808211610f9e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381610fa757fe5b049392505050565b339056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220f3fac4a21a9c1909a49c60064169f4b7f6fee0bc347065e06068e043bd503d4164736f6c634300060c0033