Contract
0x29BC86Ad68bB3BD3d54841a8522e0020C1882C22
6
Contract Overview
Balance:
0 Ether
More Info
My Name Tag:
Not Available
Txn Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x07b963cfdb0ff92457651cbce5c8e552198c03383b9a7e200c49825ebe5540fc | Add Connector | 24175485 | 454 days 10 hrs ago | 0x11799622f4d98a24514011e8527b969f7488ef47 | IN | 0x29bc86ad68bb3bd3d54841a8522e0020c1882c22 | 0 Ether | 0.00007144 | |
0x69adc700b178daa23b9accc7f684a9612c7925aff79229c75712a519c7cbcc5d | Add Connector | 24175483 | 454 days 10 hrs ago | 0x11799622f4d98a24514011e8527b969f7488ef47 | IN | 0x29bc86ad68bb3bd3d54841a8522e0020c1882c22 | 0 Ether | 0.000067 | |
0x9734fa9235941784b9506a318b241b575d7ae0a5ea314dd7e0b231e92af28e5e | 0x60806040 | 24175281 | 454 days 10 hrs ago | 0x11799622f4d98a24514011e8527b969f7488ef47 | IN | Create: OffchainOracle | 0 Ether | 0.0016496 |
[ Download CSV Export ]
Contract Name:
OffchainOracle
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "./interfaces/IOracle.sol"; import "./interfaces/IWrapper.sol"; import "./MultiWrapper.sol"; contract OffchainOracle is Ownable { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; event OracleAdded(IOracle oracle); event OracleRemoved(IOracle oracle); event ConnectorAdded(IERC20 connector); event ConnectorRemoved(IERC20 connector); event MultiWrapperUpdated(MultiWrapper multiWrapper); EnumerableSet.AddressSet private _oracles; EnumerableSet.AddressSet private _connectors; MultiWrapper public multiWrapper; constructor(MultiWrapper _multiWrapper, IOracle[] memory existingOracles, IERC20[] memory existingConnectors) { multiWrapper = _multiWrapper; emit MultiWrapperUpdated(_multiWrapper); for (uint256 i = 0; i < existingOracles.length; i++) { require(_oracles.add(address(existingOracles[i])), "Oracle already added"); emit OracleAdded(existingOracles[i]); } for (uint256 i = 0; i < existingConnectors.length; i++) { require(_connectors.add(address(existingConnectors[i])), "Connector already added"); emit ConnectorAdded(existingConnectors[i]); } } function oracles() external view returns (IOracle[] memory allOracles) { allOracles = new IOracle[](_oracles.length()); for (uint256 i = 0; i < allOracles.length; i++) { allOracles[i] = IOracle(uint256(_oracles._inner._values[i])); } } function connectors() external view returns (IERC20[] memory allConnectors) { allConnectors = new IERC20[](_connectors.length()); for (uint256 i = 0; i < allConnectors.length; i++) { allConnectors[i] = IERC20(uint256(_connectors._inner._values[i])); } } function setMultiWrapper(MultiWrapper _multiWrapper) external onlyOwner { multiWrapper = _multiWrapper; emit MultiWrapperUpdated(_multiWrapper); } function addOracle(IOracle oracle) external onlyOwner { require(_oracles.add(address(oracle)), "Oracle already added"); emit OracleAdded(oracle); } function removeOracle(IOracle oracle) external onlyOwner { require(_oracles.remove(address(oracle)), "Unknown oracle"); emit OracleRemoved(oracle); } function addConnector(IERC20 connector) external onlyOwner { require(_connectors.add(address(connector)), "Connector already added"); emit ConnectorAdded(connector); } function removeConnector(IERC20 connector) external onlyOwner { require(_connectors.remove(address(connector)), "Unknown connector"); emit ConnectorRemoved(connector); } /* WARNING! Usage of the dex oracle on chain is highly discouraged! getRate function can be easily manipulated inside transaction! */ function getRate(IERC20 srcToken, IERC20 dstToken) external view returns (uint256 weightedRate) { require(srcToken != dstToken, "Tokens should not be the same"); uint256 totalWeight; (IERC20[] memory wrappedSrcTokens, uint256[] memory srcRates) = multiWrapper.getWrappedTokens(srcToken); (IERC20[] memory wrappedDstTokens, uint256[] memory dstRates) = multiWrapper.getWrappedTokens(dstToken); for (uint256 i = 0; i < _oracles._inner._values.length; i++) { for (uint256 j = 0; j < _connectors._inner._values.length; j++) { for (uint256 k1 = 0; k1 < wrappedSrcTokens.length; k1++) { for (uint256 k2 = 0; k2 < wrappedDstTokens.length; k2++) { if (wrappedSrcTokens[k1] == wrappedDstTokens[k2]) { return srcRates[k1].mul(dstRates[k2]).div(1e18); } try IOracle(uint256(_oracles._inner._values[i])).getRate(wrappedSrcTokens[k1], wrappedDstTokens[k2], IERC20(uint256(_connectors._inner._values[j]))) returns (uint256 rate, uint256 weight) { rate = rate.mul(srcRates[k1]).mul(dstRates[k2]).div(1e18).div(1e18); weight = weight.mul(weight); weightedRate = weightedRate.add(rate.mul(weight)); totalWeight = totalWeight.add(weight); } catch { continue; } } } } } weightedRate = weightedRate.div(totalWeight); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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 () { 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; } }
// SPDX-License-Identifier: MIT 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, 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; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IOracle { function getRate(IERC20 srcToken, IERC20 dstToken, IERC20 connector) external view returns (uint256 rate, uint256 weight); }
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWrapper { function wrap(IERC20 token) external view returns (IERC20 wrappedToken, uint256 rate); }
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "./interfaces/IWrapper.sol"; contract MultiWrapper is Ownable { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; event WrapperAdded(IWrapper connector); event WrapperRemoved(IWrapper connector); EnumerableSet.AddressSet private _wrappers; constructor(IWrapper[] memory existingWrappers) { for (uint256 i = 0; i < existingWrappers.length; i++) { require(_wrappers.add(address(existingWrappers[i])), "Wrapper already added"); emit WrapperAdded(existingWrappers[i]); } } function wrappers() external view returns (IWrapper[] memory allWrappers) { allWrappers = new IWrapper[](_wrappers.length()); for (uint256 i = 0; i < allWrappers.length; i++) { allWrappers[i] = IWrapper(uint256(_wrappers._inner._values[i])); } } function addWrapper(IWrapper wrapper) external onlyOwner { require(_wrappers.add(address(wrapper)), "Wrapper already added"); emit WrapperAdded(wrapper); } function removeWrapper(IWrapper wrapper) external onlyOwner { require(_wrappers.remove(address(wrapper)), "Unknown wrapper"); emit WrapperRemoved(wrapper); } function getWrappedTokens(IERC20 token) external view returns (IERC20[] memory wrappedTokens, uint256[] memory rates) { IERC20[] memory memWrappedTokens = new IERC20[](20); uint256[] memory memRates = new uint256[](20); uint256 len = 0; for (uint256 i = 0; i < _wrappers._inner._values.length; i++) { try IWrapper(uint256(_wrappers._inner._values[i])).wrap(token) returns (IERC20 wrappedToken, uint256 rate) { memWrappedTokens[len] = wrappedToken; memRates[len] = rate; len += 1; for (uint256 j = 0; j < _wrappers._inner._values.length; j++) { if (i != j) { try IWrapper(uint256(_wrappers._inner._values[j])).wrap(wrappedToken) returns (IERC20 wrappedToken2, uint256 rate2) { bool used = false; for (uint256 k = 0; k < len; k++) { if (wrappedToken2 == memWrappedTokens[k]) { used = true; break; } } if (!used) { memWrappedTokens[len] = wrappedToken2; memRates[len] = rate.mul(rate2).div(1e18); len += 1; } } catch { continue; } } } } catch { continue; } } wrappedTokens = new IERC20[](len + 1); rates = new uint256[](len + 1); for (uint256 i = 0; i < len; i++) { wrappedTokens[i] = memWrappedTokens[i]; rates[i] = memRates[i]; } wrappedTokens[len] = token; rates[len] = 1e18; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 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; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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); }
{ "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
[{"inputs":[{"internalType":"contract MultiWrapper","name":"_multiWrapper","type":"address"},{"internalType":"contract IOracle[]","name":"existingOracles","type":"address[]"},{"internalType":"contract IERC20[]","name":"existingConnectors","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"ConnectorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"ConnectorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract MultiWrapper","name":"multiWrapper","type":"address"}],"name":"MultiWrapperUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IOracle","name":"oracle","type":"address"}],"name":"OracleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IOracle","name":"oracle","type":"address"}],"name":"OracleRemoved","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":[{"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"addConnector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOracle","name":"oracle","type":"address"}],"name":"addOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"connectors","outputs":[{"internalType":"contract IERC20[]","name":"allConnectors","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"srcToken","type":"address"},{"internalType":"contract IERC20","name":"dstToken","type":"address"}],"name":"getRate","outputs":[{"internalType":"uint256","name":"weightedRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"multiWrapper","outputs":[{"internalType":"contract MultiWrapper","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracles","outputs":[{"internalType":"contract IOracle[]","name":"allOracles","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"removeConnector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOracle","name":"oracle","type":"address"}],"name":"removeOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract MultiWrapper","name":"_multiWrapper","type":"address"}],"name":"setMultiWrapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b5060405162001d9438038062001d94833981810160405260608110156200003757600080fd5b8151602083018051604051929492938301929190846401000000008211156200005f57600080fd5b9083019060208201858111156200007557600080fd5b82518660208202830111640100000000821117156200009357600080fd5b82525081516020918201928201910280838360005b83811015620000c2578181015183820152602001620000a8565b5050505090500160405260200180516040519392919084640100000000821115620000ec57600080fd5b9083019060208201858111156200010257600080fd5b82518660208202830111640100000000821117156200012057600080fd5b82525081516020918201928201910280838360005b838110156200014f57818101518382015260200162000135565b5050505090500160405250505060006200016e620003e960201b60201c565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600580546001600160a01b0385166001600160a01b0319909116811790915560408051918252517f1030152fe2062b574a830e6b9f13c65995990df31e4dc708d142533bb3ad0f529181900360200190a160005b8251811015620002f357620002458382815181106200022757fe5b60200260200101516001620003ed60201b620015871790919060201c565b62000297576040805162461bcd60e51b815260206004820152601460248201527f4f7261636c6520616c7265616479206164646564000000000000000000000000604482015290519081900360640190fd5b7e47706786c922d17b39285dc59d696bafea72c0b003d3841ae1202076f4c2e4838281518110620002c457fe5b602002602001015160405180826001600160a01b0316815260200191505060405180910390a16001016200020c565b5060005b8151811015620003df57620003308282815181106200031257fe5b60200260200101516003620003ed60201b620015871790919060201c565b62000382576040805162461bcd60e51b815260206004820152601760248201527f436f6e6e6563746f7220616c7265616479206164646564000000000000000000604482015290519081900360640190fd5b7fff88af5d962d47fd25d87755e8267a029fad5a91740c67d0dade2bdbe5268a1d828281518110620003b057fe5b602002602001015160405180826001600160a01b0316815260200191505060405180910390a1600101620002f7565b5050505062000474565b3390565b600062000404836001600160a01b0384166200040d565b90505b92915050565b60006200041b83836200045c565b620004535750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000407565b50600062000407565b60009081526001919091016020526040902054151590565b61191080620004846000396000f3fe608060405234801561001057600080fd5b50600436106100d45760003560e01c8063aa16d4c011610081578063df5dd1a51161005b578063df5dd1a514610262578063f2fde38b14610295578063fdc85fc4146102c8576100d4565b8063aa16d4c0146101f4578063b77910dc14610227578063d06265181461022f576100d4565b806365050a68116100b257806365050a68146101b3578063715018a6146101bb5780638da5cb5b146101c3576100d4565b80631a6c6a98146100d95780632857373a1461010e578063379b87ea14610166575b600080fd5b61010c600480360360208110156100ef57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166102fb565b005b610116610465565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561015257818101518382015260200161013a565b505050509050019250505060405180910390f35b6101a16004803603604081101561017c57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610519565b60408051918252519081900360200190f35b610116610c89565b61010c610d39565b6101cb610e50565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61010c6004803603602081101561020a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610e6c565b6101cb610fd6565b61010c6004803603602081101561024557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610ff2565b61010c6004803603602081101561027857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611113565b61010c600480360360208110156102ab57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661127c565b61010c600480360360208110156102de57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661141d565b6103036115b0565b73ffffffffffffffffffffffffffffffffffffffff16610321610e50565b73ffffffffffffffffffffffffffffffffffffffff16146103a357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6103ae6003826115b4565b61041957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e6b6e6f776e20636f6e6e6563746f72000000000000000000000000000000604482015290519081900360640190fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8316815290517f6825b26a0827e9c2ceca01d6289ce4a40e629dc074ec48ea4727d1afbff359f59181900360200190a150565b606061047160016115d6565b67ffffffffffffffff8111801561048757600080fd5b506040519080825280602002602001820160405280156104b1578160200160208202803683370190505b50905060005b81518110156105155760018054829081106104ce57fe5b906000526020600020015460001c8282815181106104e857fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830291909101909101526001016104b7565b5090565b60008173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156105b657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f546f6b656e732073686f756c64206e6f74206265207468652073616d65000000604482015290519081900360640190fd5b600554604080517fcb991d9400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015291516000938493849391169163cb991d94916024808201928692909190829003018186803b15801561062e57600080fd5b505afa158015610642573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604090815281101561068957600080fd5b81019080805160405193929190846401000000008211156106a957600080fd5b9083019060208201858111156106be57600080fd5b82518660208202830111640100000000821117156106db57600080fd5b82525081516020918201928201910280838360005b838110156107085781810151838201526020016106f0565b505050509050016040526020018051604051939291908464010000000082111561073157600080fd5b90830190602082018581111561074657600080fd5b825186602082028301116401000000008211171561076357600080fd5b82525081516020918201928201910280838360005b83811015610790578181015183820152602001610778565b5050505090500160405250505091509150600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663cb991d94886040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060006040518083038186803b15801561082d57600080fd5b505afa158015610841573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604090815281101561088857600080fd5b81019080805160405193929190846401000000008211156108a857600080fd5b9083019060208201858111156108bd57600080fd5b82518660208202830111640100000000821117156108da57600080fd5b82525081516020918201928201910280838360005b838110156109075781810151838201526020016108ef565b505050509050016040526020018051604051939291908464010000000082111561093057600080fd5b90830190602082018581111561094557600080fd5b825186602082028301116401000000008211171561096257600080fd5b82525081516020918201928201910280838360005b8381101561098f578181015183820152602001610977565b505050509050016040525050509150915060005b600154811015610c705760005b600354811015610c675760005b8651811015610c5e5760005b8551811015610c55578581815181106109de57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16888381518110610a0857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415610a8757610a77670de0b6b3a7640000610a71878481518110610a4757fe5b60200260200101518a8681518110610a5b57fe5b60200260200101516115e190919063ffffffff16565b90611654565b9950505050505050505050610c83565b6001805485908110610a9557fe5b906000526020600020015460001c73ffffffffffffffffffffffffffffffffffffffff166314999e79898481518110610aca57fe5b6020026020010151888481518110610ade57fe5b602002602001015160036000016000018781548110610af957fe5b906000526020600020015460001c6040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019350505050604080518083038186803b158015610b8a57600080fd5b505afa925050508015610bb657506040513d6040811015610baa57600080fd5b50805160209091015160015b610bbf57610c4d565b610c1a670de0b6b3a7640000610a71670de0b6b3a7640000610a718b8881518110610be657fe5b6020026020010151610c148f8b81518110610bfd57fe5b6020026020010151896115e190919063ffffffff16565b906115e1565b9150610c2681806115e1565b9050610c3c610c3583836115e1565b8d906116d5565b9b50610c488b826116d5565b9a5050505b6001016109c9565b506001016109bd565b506001016109b0565b506001016109a3565b50610c7b8686611654565b955050505050505b92915050565b6060610c9560036115d6565b67ffffffffffffffff81118015610cab57600080fd5b50604051908082528060200260200182016040528015610cd5578160200160208202803683370190505b50905060005b8151811015610515576003805482908110610cf257fe5b906000526020600020015460001c828281518110610d0c57fe5b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152600101610cdb565b610d416115b0565b73ffffffffffffffffffffffffffffffffffffffff16610d5f610e50565b73ffffffffffffffffffffffffffffffffffffffff1614610de157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b610e746115b0565b73ffffffffffffffffffffffffffffffffffffffff16610e92610e50565b73ffffffffffffffffffffffffffffffffffffffff1614610f1457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610f1f600382611587565b610f8a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f436f6e6e6563746f7220616c7265616479206164646564000000000000000000604482015290519081900360640190fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8316815290517fff88af5d962d47fd25d87755e8267a029fad5a91740c67d0dade2bdbe5268a1d9181900360200190a150565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b610ffa6115b0565b73ffffffffffffffffffffffffffffffffffffffff16611018610e50565b73ffffffffffffffffffffffffffffffffffffffff161461109a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6005805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f1030152fe2062b574a830e6b9f13c65995990df31e4dc708d142533bb3ad0f529181900360200190a150565b61111b6115b0565b73ffffffffffffffffffffffffffffffffffffffff16611139610e50565b73ffffffffffffffffffffffffffffffffffffffff16146111bb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6111c6600182611587565b61123157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4f7261636c6520616c7265616479206164646564000000000000000000000000604482015290519081900360640190fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8316815290517e47706786c922d17b39285dc59d696bafea72c0b003d3841ae1202076f4c2e49181900360200190a150565b6112846115b0565b73ffffffffffffffffffffffffffffffffffffffff166112a2610e50565b73ffffffffffffffffffffffffffffffffffffffff161461132457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116611390576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118946026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6114256115b0565b73ffffffffffffffffffffffffffffffffffffffff16611443610e50565b73ffffffffffffffffffffffffffffffffffffffff16146114c557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6114d06001826115b4565b61153b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f556e6b6e6f776e206f7261636c65000000000000000000000000000000000000604482015290519081900360640190fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8316815290517f9c8e7d83025bef8a04c664b2f753f64b8814bdb7e27291d7e50935f18cc3c7129181900360200190a150565b60006115a98373ffffffffffffffffffffffffffffffffffffffff8416611749565b9392505050565b3390565b60006115a98373ffffffffffffffffffffffffffffffffffffffff8416611793565b6000610c8382611877565b6000826115f057506000610c83565b828202828482816115fd57fe5b04146115a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806118ba6021913960400191505060405180910390fd5b60008082116116c457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816116cd57fe5b049392505050565b6000828201838110156115a957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000611755838361187b565b61178b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c83565b506000610c83565b6000818152600183016020526040812054801561186d5783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80830191908101906000908790839081106117e457fe5b906000526020600020015490508087600001848154811061180157fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061183157fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610c83565b6000915050610c83565b5490565b6000908152600191909101602052604090205415159056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212208dc9dd011c713aa2b04cb3dfd4a6359becd3a03efa86cd78a8f83a123d3e1df364736f6c63430007060033000000000000000000000000d41b24bba51fac0e4827b6f94c0d6ddeb183cd64000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b707d89d29c189421163515c59e42147371d685700000000000000000000000057da811a9ef9b79dbc2ea6f6dc39368a8da1cf0700000000000000000000000011431a89893025d2a48dca4eddc396f8c81171870000000000000000000000000000000000000000000000000000000000000000
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d41b24bba51fac0e4827b6f94c0d6ddeb183cd64000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b707d89d29c189421163515c59e42147371d685700000000000000000000000057da811a9ef9b79dbc2ea6f6dc39368a8da1cf0700000000000000000000000011431a89893025d2a48dca4eddc396f8c81171870000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _multiWrapper (address): 0xd41b24bba51fac0e4827b6f94c0d6ddeb183cd64
Arg [1] : existingOracles (address[]): 0xb707d89d29c189421163515c59e42147371d6857,0x57da811a9ef9b79dbc2ea6f6dc39368a8da1cf07,0x11431a89893025d2a48dca4eddc396f8c8117187
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000d41b24bba51fac0e4827b6f94c0d6ddeb183cd64
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [4] : 000000000000000000000000b707d89d29c189421163515c59e42147371d6857
Arg [5] : 00000000000000000000000057da811a9ef9b79dbc2ea6f6dc39368a8da1cf07
Arg [6] : 00000000000000000000000011431a89893025d2a48dca4eddc396f8c8117187
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000000
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.