Address Contract Partially Verified
Address
0x674bdf20A0F284D710BC40872100128e2d66Bd3f
Balance
3350.80 ETH ($6915381.04)
Nonce
1
Code Size
6145 bytes
Creator
0x4374D3d0...2768 at tx 0x1b3c0e73...7c919b
Indexed Transactions
0
Contract Bytecode
6145 bytes
0x6080604052600436106100d25760003560e01c8063c4d66de81161007f578063f18d03cc11610059578063f18d03cc146102ec578063f2fde38b14610335578063f3d790b714610375578063f70a250814610441576100d2565b8063c4d66de814610282578063d2f7265a146102c2578063e30c3978146102d7576100d2565b8063715018a6116100b0578063715018a6146101db57806375151b63146101f05780638da5cb5b14610244576100d2565b80633823f247146100d75780634e71e0c81461017e578063634de7dd14610193575b600080fd5b61017c600480360360a08110156100ed57600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101358216926040820135909216916060820135919081019060a08101608082013564010000000081111561013d57600080fd5b82018360208201111561014f57600080fd5b8035906020019184600183028401116401000000008311171561017157600080fd5b509092509050610481565b005b34801561018a57600080fd5b5061017c61069f565b34801561019f57600080fd5b5061017c600480360360408110156101b657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013515156107bb565b3480156101e757600080fd5b5061017c610967565b3480156101fc57600080fd5b506102306004803603602081101561021357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610a5c565b604080519115158252519081900360200190f35b34801561025057600080fd5b50610259610a62565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561028e57600080fd5b5061017c600480360360208110156102a557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610a7e565b3480156102ce57600080fd5b50610259610b79565b3480156102e357600080fd5b50610259610b95565b61017c6004803603608081101561030257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101358216916040820135169060600135610bb1565b34801561034157600080fd5b5061017c6004803603602081101561035857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610c6b565b6104206004803603608081101561038b57600080fd5b73ffffffffffffffffffffffffffffffffffffffff82358116926020810135909116916bffffffffffffffffffffffff60408301351691908101906080810160608201356401000000008111156103e157600080fd5b8201836020820111156103f357600080fd5b8035906020019184600183028401116401000000008311171561041557600080fd5b509092509050610de3565b604080516bffffffffffffffffffffffff9092168252519081900360200190f35b34801561044d57600080fd5b506102306004803603602081101561046457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661113b565b60025473ffffffffffffffffffffffffffffffffffffffff16331461050757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015290519081900360640190fd5b828061051257610696565b61051b8561114c565b1561054957610543845a73ffffffffffffffffffffffffffffffffffffffff89169190611166565b50610696565b61056a73ffffffffffffffffffffffffffffffffffffffff861687866111fe565b6106965760008573ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156105d757600080fd5b505afa1580156105eb573d6000803e3d6000fd5b505050506040513d602081101561060157600080fd5b5051905084811061067357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f554e455850454354454400000000000000000000000000000000000000000000604482015290519081900360640190fd5b61069473ffffffffffffffffffffffffffffffffffffffff87168883611214565b505b50505050505050565b60015473ffffffffffffffffffffffffffffffffffffffff16331461072557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015290519081900360640190fd5b6001546000805460405173ffffffffffffffffffffffffffffffffffffffff93841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a360018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b60005473ffffffffffffffffffffffffffffffffffffffff16331461084157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526003602052604090205460ff16151581151514156108dc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f494e56414c49445f56414c554500000000000000000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660008181526003602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016851515908117909155825190815291517f5ca546e2df4ecf26ee1e85b99c7fc08237e0fc2bc8df80f9f3e0fa5a7116ed819281900390910190a25050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146109ed57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b50600190565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60025473ffffffffffffffffffffffffffffffffffffffff16158015610ab9575073ffffffffffffffffffffffffffffffffffffffff811615155b610b2457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f494e56414c49445f45584348414e474500000000000000000000000000000000604482015290519081900360640190fd5b60008054337fffffffffffffffffffffffff0000000000000000000000000000000000000000918216179091556002805490911673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60025473ffffffffffffffffffffffffffffffffffffffff163314610c3757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015290519081900360640190fd5b8080610c4257610c64565b610c6473ffffffffffffffffffffffffffffffffffffffff8416868685611225565b5050505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610cf157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811615801590610d31575060005473ffffffffffffffffffffffffffffffffffffffff828116911614155b610d9c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f494e56414c49445f414444524553530000000000000000000000000000000000604482015290519081900360640190fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60025460009073ffffffffffffffffffffffffffffffffffffffff163314610e6c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015290519081900360640190fd5b6bffffffffffffffffffffffff841680610e8557611131565b6000610e908761114c565b15610f2c57856bffffffffffffffffffffffff16341015610f1257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e56414c49445f4554485f4445504f53495400000000000000000000000000604482015290519081900360640190fd5b508491506bffffffffffffffffffffffff82163403611104565b73ffffffffffffffffffffffffffffffffffffffff871660009081526003602052604081205460ff169081610f62576000610ffb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8b16916370a08231916024808301926020929190829003018186803b158015610fce57600080fd5b505afa158015610fe2573d6000803e3d6000fd5b505050506040513d6020811015610ff857600080fd5b50515b905061102d73ffffffffffffffffffffffffffffffffffffffff8a168b306bffffffffffffffffffffffff8c16611225565b60008261104857886bffffffffffffffffffffffff166110e1565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8c16916370a08231916024808301926020929190829003018186803b1580156110b457600080fd5b505afa1580156110c8573d6000803e3d6000fd5b505050506040513d60208110156110de57600080fd5b50515b905060006110ef8284611238565b90506110fa816112af565b9650349450505050505b801561112f5761112d815a73ffffffffffffffffffffffffffffffffffffffff8b169190611166565b505b505b5095945050505050565b60006111468261114c565b92915050565b73ffffffffffffffffffffffffffffffffffffffff161590565b600061118973ffffffffffffffffffffffffffffffffffffffff8516848461131a565b9050806111f757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5452414e534645525f4641494c55524500000000000000000000000000000000604482015290519081900360640190fd5b9392505050565b600061120c8484845a6113b7565b949350505050565b6112208383835a61150c565b505050565b611232848484845a611583565b50505050565b6000828211156112a957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f5355425f554e444552464c4f5700000000000000000000000000000000000000604482015290519081900360640190fd5b50900390565b60006c010000000000000000000000008210611316576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806117a66026913960400191505060405180910390fd5b5090565b600082611329575060016111f7565b600061134a8573ffffffffffffffffffffffffffffffffffffffff16611608565b60405190915073ffffffffffffffffffffffffffffffffffffffff821690849086906000818181858888f193505050503d80600081146113a6576040519150601f19603f3d011682016040523d82523d6000602084013e6113ab565b606091505b50909695505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8086166024830152604480830186905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251825160009485938a16928792869282918083835b6020831061148c57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161144f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038160008787f1925050503d80600081146114ef576040519150601f19603f3d011682016040523d82523d6000602084013e6114f4565b606091505b505090506115018161160b565b979650505050505050565b611518848484846113b7565b61123257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5452414e534645525f4641494c55524500000000000000000000000000000000604482015290519081900360640190fd5b60006115928686868686611647565b90508061160057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5452414e534645525f4641494c55524500000000000000000000000000000000604482015290519081900360640190fd5b505050505050565b90565b60008115611316573d801561162b57602081146116345760009250611640565b60019250611640565b60206000803e60005192505b5090919050565b6040805173ffffffffffffffffffffffffffffffffffffffff80871660248301528086166044830152606480830186905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001781529251825160009485938b16928792869282918083835b6020831061172457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016116e7565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038160008787f1925050503d8060008114611787576040519150601f19603f3d011682016040523d82523d6000602084013e61178c565b606091505b505090506117998161160b565b9897505050505050505056fe53616665436173743a2076616c756520646f65736e27742066697420696e2039362062697473a2646970667358221220979e966d3e3b93489b96051bd9dd18007a01182463cd93ae5ca1c1783041e36e64736f6c63430007000033
Verified Source Code Partial Match
Compiler: v0.7.0+commit.9e61f92b
EVM: istanbul
Optimization: Yes (999999 runs)
DefaultDepositContract.sol 1054 lines
// SPDX-License-Identifier: Apache-2.0 // Copyright 2017 Loopring Technology Limited. pragma solidity ^0.7.0; /// @title Ownable /// @author Brecht Devos - <[email protected]> /// @dev The Ownable contract has an owner address, and provides basic /// authorization control functions, this simplifies the implementation of /// "user permissions". contract Ownable { address public owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /// @dev The Ownable constructor sets the original `owner` of the contract /// to the sender. constructor() { owner = msg.sender; } /// @dev Throws if called by any account other than the owner. modifier onlyOwner() { require(msg.sender == owner, "UNAUTHORIZED"); _; } /// @dev Allows the current owner to transfer control of the contract to a /// new owner. /// @param newOwner The address to transfer ownership to. function transferOwnership( address newOwner ) public virtual onlyOwner { require(newOwner != address(0), "ZERO_ADDRESS"); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(owner, address(0)); owner = address(0); } } // Copyright 2017 Loopring Technology Limited. /// @title Utility Functions for uint /// @author Daniel Wang - <[email protected]> library MathUint { using MathUint for uint; function mul( uint a, uint b ) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b, "MUL_OVERFLOW"); } function sub( uint a, uint b ) internal pure returns (uint) { require(b <= a, "SUB_UNDERFLOW"); return a - b; } function add( uint a, uint b ) internal pure returns (uint c) { c = a + b; require(c >= a, "ADD_OVERFLOW"); } function add64( uint64 a, uint64 b ) internal pure returns (uint64 c) { c = a + b; require(c >= a, "ADD_OVERFLOW"); } } // Copyright 2017 Loopring Technology Limited. /// @title ERC20 Token Interface /// @dev see https://github.com/ethereum/EIPs/issues/20 /// @author Daniel Wang - <[email protected]> abstract contract ERC20 { function totalSupply() public virtual view returns (uint); function balanceOf( address who ) public virtual view returns (uint); function allowance( address owner, address spender ) public virtual view returns (uint); function transfer( address to, uint value ) public virtual returns (bool); function transferFrom( address from, address to, uint value ) public virtual returns (bool); function approve( address spender, uint value ) public virtual returns (bool); } // Copyright 2017 Loopring Technology Limited. // Copyright 2017 Loopring Technology Limited. /// @title Utility Functions for addresses /// @author Daniel Wang - <[email protected]> /// @author Brecht Devos - <[email protected]> library AddressUtil { using AddressUtil for *; function isContract( address addr ) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(addr) } return (codehash != 0x0 && codehash != 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470); } function toPayable( address addr ) internal pure returns (address payable) { return payable(addr); } // Works like address.send but with a customizable gas limit // Make sure your code is safe for reentrancy when using this function! function sendETH( address to, uint amount, uint gasLimit ) internal returns (bool success) { if (amount == 0) { return true; } address payable recipient = to.toPayable(); /* solium-disable-next-line */ (success, ) = recipient.call{value: amount, gas: gasLimit}(""); } // Works like address.transfer but with a customizable gas limit // Make sure your code is safe for reentrancy when using this function! function sendETHAndVerify( address to, uint amount, uint gasLimit ) internal returns (bool success) { success = to.sendETH(amount, gasLimit); require(success, "TRANSFER_FAILURE"); } // Works like call but is slightly more efficient when data // needs to be copied from memory to do the call. function fastCall( address to, uint gasLimit, uint value, bytes memory data ) internal returns (bool success, bytes memory returnData) { if (to != address(0)) { assembly { // Do the call success := call(gasLimit, to, value, add(data, 32), mload(data), 0, 0) // Copy the return data let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) returndatacopy(add(returnData, 32), 0, size) // Update free memory pointer mstore(0x40, add(returnData, add(32, size))) } } } // Like fastCall, but throws when the call is unsuccessful. function fastCallAndVerify( address to, uint gasLimit, uint value, bytes memory data ) internal returns (bytes memory returnData) { bool success; (success, returnData) = fastCall(to, gasLimit, value, data); if (!success) { assembly { revert(add(returnData, 32), mload(returnData)) } } } } // Copyright 2017 Loopring Technology Limited. /// @title Claimable /// @author Brecht Devos - <[email protected]> /// @dev Extension for the Ownable contract, where the ownership needs /// to be claimed. This allows the new owner to accept the transfer. contract Claimable is Ownable { address public pendingOwner; /// @dev Modifier throws if called by any account other than the pendingOwner. modifier onlyPendingOwner() { require(msg.sender == pendingOwner, "UNAUTHORIZED"); _; } /// @dev Allows the current owner to set the pendingOwner address. /// @param newOwner The address to transfer ownership to. function transferOwnership( address newOwner ) public override onlyOwner { require(newOwner != address(0) && newOwner != owner, "INVALID_ADDRESS"); pendingOwner = newOwner; } /// @dev Allows the pendingOwner address to finalize the transfer. function claimOwnership() public onlyPendingOwner { emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } // Copyright 2017 Loopring Technology Limited. /// @title ERC20 safe transfer /// @dev see https://github.com/sec-bit/badERC20Fix /// @author Brecht Devos - <[email protected]> library ERC20SafeTransfer { function safeTransferAndVerify( address token, address to, uint value ) internal { safeTransferWithGasLimitAndVerify( token, to, value, gasleft() ); } function safeTransfer( address token, address to, uint value ) internal returns (bool) { return safeTransferWithGasLimit( token, to, value, gasleft() ); } function safeTransferWithGasLimitAndVerify( address token, address to, uint value, uint gasLimit ) internal { require( safeTransferWithGasLimit(token, to, value, gasLimit), "TRANSFER_FAILURE" ); } function safeTransferWithGasLimit( address token, address to, uint value, uint gasLimit ) internal returns (bool) { // A transfer is successful when 'call' is successful and depending on the token: // - No value is returned: we assume a revert when the transfer failed (i.e. 'call' returns false) // - A single boolean is returned: this boolean needs to be true (non-zero) // bytes4(keccak256("transfer(address,uint256)")) = 0xa9059cbb bytes memory callData = abi.encodeWithSelector( bytes4(0xa9059cbb), to, value ); (bool success, ) = token.call{gas: gasLimit}(callData); return checkReturnValue(success); } function safeTransferFromAndVerify( address token, address from, address to, uint value ) internal { safeTransferFromWithGasLimitAndVerify( token, from, to, value, gasleft() ); } function safeTransferFrom( address token, address from, address to, uint value ) internal returns (bool) { return safeTransferFromWithGasLimit( token, from, to, value, gasleft() ); } function safeTransferFromWithGasLimitAndVerify( address token, address from, address to, uint value, uint gasLimit ) internal { bool result = safeTransferFromWithGasLimit( token, from, to, value, gasLimit ); require(result, "TRANSFER_FAILURE"); } function safeTransferFromWithGasLimit( address token, address from, address to, uint value, uint gasLimit ) internal returns (bool) { // A transferFrom is successful when 'call' is successful and depending on the token: // - No value is returned: we assume a revert when the transfer failed (i.e. 'call' returns false) // - A single boolean is returned: this boolean needs to be true (non-zero) // bytes4(keccak256("transferFrom(address,address,uint256)")) = 0x23b872dd bytes memory callData = abi.encodeWithSelector( bytes4(0x23b872dd), from, to, value ); (bool success, ) = token.call{gas: gasLimit}(callData); return checkReturnValue(success); } function checkReturnValue( bool success ) internal pure returns (bool) { // A transfer/transferFrom is successful when 'call' is successful and depending on the token: // - No value is returned: we assume a revert when the transfer failed (i.e. 'call' returns false) // - A single boolean is returned: this boolean needs to be true (non-zero) if (success) { assembly { switch returndatasize() // Non-standard ERC20: nothing is returned so if 'call' was successful we assume the transfer succeeded case 0 { success := 1 } // Standard ERC20: a single boolean value is returned which needs to be true case 32 { returndatacopy(0, 0, 32) success := mload(0) } // None of the above: not successful default { success := 0 } } } return success; } } // Taken from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/SafeCast.sol /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such 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. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { require(value < 2**96, "SafeCast: value doesn\'t fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { require(value < 2**40, "SafeCast: value doesn\'t fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { require(value < 2**255, "SafeCast: value doesn't fit in an int256"); return int256(value); } } // Copyright 2017 Loopring Technology Limited. /// @title IDepositContract. /// @dev Contract storing and transferring funds for an exchange. /// /// ERC1155 tokens can be supported by registering pseudo token addresses calculated /// as `address(keccak256(real_token_address, token_params))`. Then the custom /// deposit contract can look up the real token address and paramsters with the /// pseudo token address before doing the transfers. /// @author Brecht Devos - <[email protected]> interface IDepositContract { /// @dev Returns if a token is suppoprted by this contract. function isTokenSupported(address token) external view returns (bool); /// @dev Transfers tokens from a user to the exchange. This function will /// be called when a user deposits funds to the exchange. /// In a simple implementation the funds are simply stored inside the /// deposit contract directly. More advanced implementations may store the funds /// in some DeFi application to earn interest, so this function could directly /// call the necessary functions to store the funds there. /// /// This function needs to throw when an error occurred! /// /// This function can only be called by the exchange. /// /// @param from The address of the account that sends the tokens. /// @param token The address of the token to transfer (`0x0` for ETH). /// @param amount The amount of tokens to transfer. /// @param extraData Opaque data that can be used by the contract to handle the deposit /// @return amountReceived The amount to deposit to the user's account in the Merkle tree function deposit( address from, address token, uint96 amount, bytes calldata extraData ) external payable returns (uint96 amountReceived); /// @dev Transfers tokens from the exchange to a user. This function will /// be called when a withdrawal is done for a user on the exchange. /// In the simplest implementation the funds are simply stored inside the /// deposit contract directly so this simply transfers the requested tokens back /// to the user. More advanced implementations may store the funds /// in some DeFi application to earn interest so the function would /// need to get those tokens back from the DeFi application first before they /// can be transferred to the user. /// /// This function needs to throw when an error occurred! /// /// This function can only be called by the exchange. /// /// @param from The address from which 'amount' tokens are transferred. /// @param to The address to which 'amount' tokens are transferred. /// @param token The address of the token to transfer (`0x0` for ETH). /// @param amount The amount of tokens transferred. /// @param extraData Opaque data that can be used by the contract to handle the withdrawal function withdraw( address from, address to, address token, uint amount, bytes calldata extraData ) external payable; /// @dev Transfers tokens (ETH not supported) for a user using the allowance set /// for the exchange. This way the approval can be used for all functionality (and /// extended functionality) of the exchange. /// Should NOT be used to deposit/withdraw user funds, `deposit`/`withdraw` /// should be used for that as they will contain specialised logic for those operations. /// This function can be called by the exchange to transfer onchain funds of users /// necessary for Agent functionality. /// /// This function needs to throw when an error occurred! /// /// This function can only be called by the exchange. /// /// @param from The address of the account that sends the tokens. /// @param to The address to which 'amount' tokens are transferred. /// @param token The address of the token to transfer (ETH is and cannot be suppported). /// @param amount The amount of tokens transferred. function transfer( address from, address to, address token, uint amount ) external payable; /// @dev Checks if the given address is used for depositing ETH or not. /// Is used while depositing to send the correct ETH amount to the deposit contract. /// /// Note that 0x0 is always registered for deposting ETH when the exchange is created! /// This function allows additional addresses to be used for depositing ETH, the deposit /// contract can implement different behaviour based on the address value. /// /// @param addr The address to check /// @return True if the address is used for depositing ETH, else false. function isETH(address addr) external view returns (bool); } /// @title DefaultDepositContract /// @dev Default implementation of IDepositContract that just stores /// all funds without doing anything with them. /// /// Should be able to work with proxy contracts so the contract /// can be updated easily (but with great caution and transparency!) /// when necessary. /// /// @author Brecht Devos - <[email protected]> contract DefaultDepositContract is IDepositContract, Claimable { using AddressUtil for address; using ERC20SafeTransfer for address; using MathUint for uint; using SafeCast for uint; address public exchange; mapping (address => bool) needCheckBalance; modifier onlyExchange() { require(msg.sender == exchange, "UNAUTHORIZED"); _; } modifier ifNotZero(uint amount) { if (amount == 0) return; else _; } event CheckBalance( address indexed token, bool checkBalance ); function initialize( address _exchange ) external { require( exchange == address(0) && _exchange != address(0), "INVALID_EXCHANGE" ); owner = msg.sender; exchange = _exchange; } function setCheckBalance( address token, bool checkBalance ) external onlyOwner { require(needCheckBalance[token] != checkBalance, "INVALID_VALUE"); needCheckBalance[token] = checkBalance; emit CheckBalance(token, checkBalance); } function isTokenSupported(address /*token*/) external override pure returns (bool) { return true; } function deposit( address from, address token, uint96 amount, bytes calldata /*extraData*/ ) external override payable onlyExchange ifNotZero(amount) returns (uint96 amountReceived) { uint ethToReturn = 0; if (isETHInternal(token)) { require(msg.value >= amount, "INVALID_ETH_DEPOSIT"); amountReceived = amount; ethToReturn = msg.value - amount; } else { bool checkBalance = needCheckBalance[token]; uint balanceBefore = checkBalance ? ERC20(token).balanceOf(address(this)) : 0; token.safeTransferFromAndVerify(from, address(this), uint(amount)); uint balanceAfter = checkBalance ? ERC20(token).balanceOf(address(this)) : amount; uint diff = balanceAfter.sub(balanceBefore); amountReceived = diff.toUint96(); ethToReturn = msg.value; } if (ethToReturn > 0) { from.sendETHAndVerify(ethToReturn, gasleft()); } } function withdraw( address /*from*/, address to, address token, uint amount, bytes calldata /*extraData*/ ) external override payable onlyExchange ifNotZero(amount) { if (isETHInternal(token)) { to.sendETHAndVerify(amount, gasleft()); } else { if (!token.safeTransfer(to, amount)){ uint amountPaid = ERC20(token).balanceOf(address(this)); require(amountPaid < amount, "UNEXPECTED"); token.safeTransferAndVerify(to, amountPaid); } } } function transfer( address from, address to, address token, uint amount ) external override payable onlyExchange ifNotZero(amount) { token.safeTransferFromAndVerify(from, to, amount); } function isETH(address addr) external override pure returns (bool) { return isETHInternal(addr); } // -- Internal -- function isETHInternal(address addr) internal pure returns (bool) { return addr == address(0); } }
Read Contract
exchange 0xd2f7265a → address
isETH 0xf70a2508 → bool
isTokenSupported 0x75151b63 → bool
owner 0x8da5cb5b → address
pendingOwner 0xe30c3978 → address
Write Contract 8 functions
These functions modify contract state and require a wallet transaction to execute.
claimOwnership 0x4e71e0c8
No parameters
deposit 0xf3d790b7
address from
address token
uint96 amount
bytes
returns: uint96
initialize 0xc4d66de8
address _exchange
renounceOwnership 0x715018a6
No parameters
setCheckBalance 0x634de7dd
address token
bool checkBalance
transfer 0xf18d03cc
address from
address to
address token
uint256 amount
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3823f247
address
address to
address token
uint256 amount
bytes
Token Balances (8)
View Transfers →Recent Transactions
No transactions found for this address