Transaction Hash:
Block:
17081447 at Apr-19-2023 03:11:11 PM +UTC
Transaction Fee:
0.0102513562902676 ETH
$22.09
Gas Used:
113,200 Gas / 90.559684543 Gwei
Emitted Events:
| 286 |
VerseToken.Transfer( from=[Sender] 0xef677cd5c16f9268a6c32046f41b2a2e0531b112, to=SwapsPair, value=1000000000000000000000000 )
|
| 287 |
WETH9.Transfer( src=SwapsPair, dst=[Receiver] SwapsRouter, wad=515796415687530318 )
|
| 288 |
SwapsPair.Sync( reserve0=1357294742013622296730691515, reserve1=701676997539087280003 )
|
| 289 |
SwapsPair.Swap( sender=[Receiver] SwapsRouter, amount0In=1000000000000000000000000, amount1In=0, amount0Out=0, amount1Out=515796415687530318, to=[Receiver] SwapsRouter )
|
| 290 |
WETH9.Withdrawal( src=[Receiver] SwapsRouter, wad=515796415687530318 )
|
Account State Difference:
| Address | Before | After | State Difference | ||
|---|---|---|---|---|---|
| 0x249cA826...765350a18 | |||||
|
0x388C818C...7ccB19297
Miner
| (Lido: Execution Layer Rewards Vault) | 53.373515841169400224 Eth | 53.373528728864880224 Eth | 0.00001288769548 | |
| 0x845C0179...17a480F3e | |||||
| 0xC02aaA39...83C756Cc2 | 3,774,656.608054273041231843 Eth | 3,774,656.092257857353701525 Eth | 0.515796415687530318 | ||
| 0xef677cd5...e0531b112 |
0.02838019920825531 Eth
Nonce: 95
|
0.533925258605518028 Eth
Nonce: 96
| 0.505545059397262718 |
Execution Trace
SwapsRouter.swapExactTokensForETH( _amountIn=1000000000000000000000000, _amountOutMin=510638451530655015, _path=[0x249cA82617eC3DfB2589c4c17ab7EC9765350a18, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2], _to=0xef677cd5c16f9268a6C32046F41b2A2e0531b112, _deadline=1681917957 ) => ( amounts=[1000000000000000000000000, 515796415687530318] )
SwapsPair.STATICCALL( )
-
0x7290367aa694703220516a35e68e3d339ee7d193.DELEGATECALL( )
-
-
VerseToken.transferFrom( _from=0xef677cd5c16f9268a6C32046F41b2A2e0531b112, _to=0x845C0179060362f071FF5C7f1D2703617a480F3e, _value=1000000000000000000000000 ) => ( True )
SwapsPair.swap( _amount0Out=0, _amount1Out=515796415687530318, _to=0xB4B0ea46Fe0E9e8EAB4aFb765b527739F2718671, _data=0x )
0x7290367aa694703220516a35e68e3d339ee7d193.022c0d9f( )
-
WETH9.transfer( dst=0xB4B0ea46Fe0E9e8EAB4aFb765b527739F2718671, wad=515796415687530318 ) => ( True )
-
VerseToken.balanceOf( 0x845C0179060362f071FF5C7f1D2703617a480F3e ) => ( 1357294742013622296730691515 )
-
WETH9.balanceOf( 0x845C0179060362f071FF5C7f1D2703617a480F3e ) => ( 701676997539087280003 )
-
WETH9.withdraw( wad=515796415687530318 )
- ETH 0.515796415687530318
SwapsRouter.CALL( )
- ETH 0.515796415687530318
- ETH 0.515796415687530318
0xef677cd5c16f9268a6c32046f41b2a2e0531b112.CALL( )
File 1 of 4: SwapsRouter
File 2 of 4: SwapsPair
File 3 of 4: VerseToken
File 4 of 4: WETH9
{"IERC20.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ninterface IERC20 {\n\n function balanceOf(\n address _owner\n )\n external\n view\n returns (uint256);\n}\n"},"ISwapsCallee.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ninterface ISwapsCallee {\n\n function swapsCall(\n address _sender,\n uint256 _amount0,\n uint256 _amount1,\n bytes calldata _data\n )\n external;\n}\n"},"ISwapsERC20.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ninterface ISwapsERC20 {\n\n function name()\n external\n pure\n returns (string memory);\n\n function symbol()\n external\n pure\n returns (string memory);\n\n function decimals()\n external\n pure\n returns (uint8);\n\n function totalSupply()\n external\n view\n returns (uint256);\n\n function balanceOf(\n address _owner\n )\n external\n view\n returns (uint256);\n\n function allowance(\n address _owner,\n address _spender\n )\n external\n view\n returns (uint256);\n\n function approve(\n address _spender,\n uint256 _value\n )\n external\n returns (bool);\n\n function transfer(\n address _to,\n uint256 _value\n )\n external\n returns (bool);\n\n function transferFrom(\n address _from,\n address _to,\n uint256 _value\n )\n external\n returns (bool);\n\n function DOMAIN_SEPARATOR()\n external\n view\n returns (bytes32);\n\n function PERMIT_TYPEHASH()\n external\n pure\n returns (bytes32);\n\n function nonces(\n address _owner\n )\n external\n view\n returns (uint256);\n\n function permit(\n address _owner,\n address _spender,\n uint256 _value,\n uint256 _deadline,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\n external;\n}\n"},"ISwapsFactory.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ninterface ISwapsFactory {\n\n function feeTo()\n external\n view\n returns (address);\n\n function feeToSetter()\n external\n view\n returns (address);\n\n function getPair(\n address _tokenA,\n address _tokenB\n )\n external\n view\n returns (address pair);\n\n function allPairs(uint256)\n external\n view\n returns (address pair);\n\n function allPairsLength()\n external\n view\n returns (uint256);\n\n function createPair(\n address _tokenA,\n address _tokenB\n )\n external\n returns (address pair);\n\n function setFeeTo(\n address\n )\n external;\n\n function setFeeToSetter(\n address\n )\n external;\n\n function cloneTarget()\n external\n view\n returns (address target);\n}\n"},"ISwapsPair.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\nimport \"./ISwapsERC20.sol\";\n\ninterface ISwapsPair is ISwapsERC20 {\n\n function MINIMUM_LIQUIDITY()\n external\n pure\n returns (uint256);\n\n function factory()\n external\n view\n returns (address);\n\n function token0()\n external\n view\n returns (address);\n\n function token1()\n external\n view\n returns (address);\n\n function getReserves()\n external\n view\n returns (\n uint112 reserve0,\n uint112 reserve1,\n uint32 blockTimestampLast\n );\n\n function price0CumulativeLast()\n external\n view\n returns (uint256);\n\n function price1CumulativeLast()\n external\n view\n returns (uint256);\n\n function kLast()\n external\n view\n returns (uint256);\n\n function mint(\n address _to\n )\n external\n returns (uint256 liquidity);\n\n function burn(\n address _to\n )\n external\n returns (\n uint256 amount0,\n uint256 amount1\n );\n\n function swap(\n uint256 _amount0Out,\n uint256 _amount1Out,\n address _to,\n bytes calldata _data\n )\n external;\n\n function skim()\n external;\n\n function initialize(\n address,\n address\n )\n external;\n}\n"},"IWETH.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ninterface IWETH {\n\n function deposit()\n external\n payable;\n\n function transfer(\n address _to,\n uint256 _value\n )\n external\n returns (bool);\n\n function withdraw(\n uint256\n )\n external;\n}\n"},"SwapsERC20.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ncontract SwapsERC20 {\n\n string public constant name = \"Verse Exchange\";\n string public constant symbol = \"VERSE-X\";\n uint8 public constant decimals = 18;\n\n address constant ZERO_ADDRESS = address(0);\n uint256 constant UINT256_MAX = type(uint256).max;\n\n uint256 public totalSupply;\n\n mapping(address =\u003e uint256) public balanceOf;\n mapping(address =\u003e mapping(address =\u003e uint256)) public allowance;\n mapping(address =\u003e uint256) public nonces;\n\n bytes32 public immutable DOMAIN_SEPARATOR;\n bytes32 public constant PERMIT_TYPEHASH = keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n );\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n event Transfer(\n address indexed from,\n address indexed to,\n uint256 value\n );\n\n constructor() {\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(bytes(\"1\")),\n block.chainid,\n address(this)\n )\n );\n }\n\n function _mint(\n address _to,\n uint256 _value\n )\n internal\n {\n totalSupply =\n totalSupply + _value;\n\n unchecked {\n balanceOf[_to] =\n balanceOf[_to] + _value;\n }\n\n emit Transfer(\n ZERO_ADDRESS,\n _to,\n _value\n );\n }\n\n function _burn(\n address _from,\n uint256 _value\n )\n internal\n {\n unchecked {\n totalSupply =\n totalSupply - _value;\n }\n\n balanceOf[_from] =\n balanceOf[_from] - _value;\n\n emit Transfer(\n _from,\n ZERO_ADDRESS,\n _value\n );\n }\n\n function _approve(\n address _owner,\n address _spender,\n uint256 _value\n )\n private\n {\n allowance[_owner][_spender] = _value;\n\n emit Approval(\n _owner,\n _spender,\n _value\n );\n }\n\n function _transfer(\n address _from,\n address _to,\n uint256 _value\n )\n private\n {\n balanceOf[_from] =\n balanceOf[_from] - _value;\n\n unchecked {\n balanceOf[_to] =\n balanceOf[_to] + _value;\n }\n\n emit Transfer(\n _from,\n _to,\n _value\n );\n }\n\n function approve(\n address _spender,\n uint256 _value\n )\n external\n returns (bool)\n {\n _approve(\n msg.sender,\n _spender,\n _value\n );\n\n return true;\n }\n\n function transfer(\n address _to,\n uint256 _value\n )\n external\n returns (bool)\n {\n _transfer(\n msg.sender,\n _to,\n _value\n );\n\n return true;\n }\n\n function transferFrom(\n address _from,\n address _to,\n uint256 _value\n )\n external\n returns (bool)\n {\n if (allowance[_from][msg.sender] != UINT256_MAX) {\n allowance[_from][msg.sender] -= _value;\n }\n\n _transfer(\n _from,\n _to,\n _value\n );\n\n return true;\n }\n\n function permit(\n address _owner,\n address _spender,\n uint256 _value,\n uint256 _deadline,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\n external\n {\n require(\n _deadline \u003e= block.timestamp,\n \"SwapsERC20: PERMIT_CALL_EXPIRED\"\n );\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(\n abi.encode(\n PERMIT_TYPEHASH,\n _owner,\n _spender,\n _value,\n nonces[_owner]++,\n _deadline\n )\n )\n )\n );\n\n if (uint256(_s) \u003e 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n revert(\"SwapsERC20: INVALID_SIGNATURE\");\n }\n\n address recoveredAddress = ecrecover(\n digest,\n _v,\n _r,\n _s\n );\n\n require(\n recoveredAddress != ZERO_ADDRESS \u0026\u0026\n recoveredAddress == _owner,\n \"SwapsERC20: INVALID_SIGNATURE\"\n );\n\n _approve(\n _owner,\n _spender,\n _value\n );\n }\n}\n"},"SwapsFactory.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\nimport \"./ISwapsPair.sol\";\nimport \"./SwapsPair.sol\";\n\ncontract SwapsFactory {\n\n address public feeTo;\n address public feeToSetter;\n address public immutable cloneTarget;\n address constant ZERO_ADDRESS = address(0);\n\n address[] public allPairs;\n\n mapping(address =\u003e mapping(address =\u003e address)) public getPair;\n\n event PairCreated(\n address indexed token0,\n address indexed token1,\n address pair,\n uint256\n );\n\n constructor(\n address _feeToSetter\n ) {\n if (_feeToSetter == ZERO_ADDRESS) {\n revert(\"SwapsFactory: INVALID_INPUT\");\n }\n\n feeToSetter = _feeToSetter;\n feeTo = _feeToSetter;\n\n bytes32 salt;\n address pair;\n\n bytes memory bytecode = type(SwapsPair).creationCode;\n\n assembly {\n pair := create2(\n 0,\n add(bytecode, 32),\n mload(bytecode),\n salt\n )\n }\n\n cloneTarget = pair;\n }\n\n function allPairsLength()\n external\n view\n returns (uint256)\n {\n return allPairs.length;\n }\n\n function createPair(\n address _tokenA,\n address _tokenB\n )\n external\n returns (address pair)\n {\n require(\n _tokenA != _tokenB,\n \"SwapsFactory: IDENTICAL\"\n );\n\n (address token0, address token1) = _tokenA \u003c _tokenB\n ? (_tokenA, _tokenB)\n : (_tokenB, _tokenA);\n\n require(\n token0 != ZERO_ADDRESS,\n \"SwapsFactory: ZERO_ADDRESS\"\n );\n\n require(\n getPair[token0][token1] == ZERO_ADDRESS,\n \"SwapsFactory: PAIR_ALREADY_EXISTS\"\n );\n\n bytes32 salt = keccak256(\n abi.encodePacked(\n token0,\n token1\n )\n );\n\n bytes20 targetBytes = bytes20(\n cloneTarget\n );\n\n assembly {\n\n let clone := mload(0x40)\n\n mstore(\n clone,\n 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000\n )\n\n mstore(\n add(clone, 0x14),\n targetBytes\n )\n\n mstore(\n add(clone, 0x28),\n 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n )\n\n pair := create2(0, clone, 0x37, salt)\n }\n\n ISwapsPair(pair).initialize(\n token0,\n token1\n );\n\n getPair[token0][token1] = pair;\n getPair[token1][token0] = pair;\n\n allPairs.push(pair);\n\n emit PairCreated(\n token0,\n token1,\n pair,\n allPairs.length\n );\n }\n\n function setFeeTo(\n address _feeTo\n )\n external\n {\n require(\n msg.sender == feeToSetter,\n \"SwapsFactory: FORBIDDEN\"\n );\n\n require(\n _feeTo != ZERO_ADDRESS,\n \u0027SwapsFactory: ZERO_ADDRESS\u0027\n );\n\n feeTo = _feeTo;\n }\n\n function setFeeToSetter(\n address _feeToSetter\n )\n external\n {\n require(\n msg.sender == feeToSetter,\n \"SwapsFactory: FORBIDDEN\"\n );\n\n require(\n _feeToSetter != ZERO_ADDRESS,\n \u0027SwapsFactory: ZERO_ADDRESS\u0027\n );\n\n feeToSetter = _feeToSetter;\n }\n}\n\ncontract FactoryCodeCheck {\n\n function factoryCodeHash()\n external\n pure\n returns (bytes32)\n {\n return keccak256(\n type(SwapsFactory).creationCode\n );\n }\n\n function pairCodeHash()\n external\n pure\n returns (bytes32)\n {\n return keccak256(\n type(SwapsPair).creationCode\n );\n }\n}\n"},"SwapsHelper.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ncontract SwapsHelper {\n\n uint256 constant UINT256_MAX = type(uint256).max;\n address constant ZERO_ADDRESS = address(0);\n\n function sortTokens(\n address _tokenA,\n address _tokenB\n )\n internal\n pure\n returns (\n address token0,\n address token1\n )\n {\n require(\n _tokenA != _tokenB,\n \"SwapsHelper: IDENTICAL_ADDRESSES\"\n );\n\n (token0, token1) = _tokenA \u003c _tokenB\n ? (_tokenA, _tokenB)\n : (_tokenB, _tokenA);\n\n require(\n token0 != ZERO_ADDRESS,\n \"SwapsHelper: ZERO_ADDRESS\"\n );\n }\n\n function quote(\n uint256 _amountA,\n uint256 _reserveA,\n uint256 _reserveB\n )\n public\n pure\n returns (uint256 amountB)\n {\n require(\n _amountA \u003e 0,\n \"SwapsHelper: INSUFFICIENT_AMOUNT\"\n );\n\n require(\n _reserveA \u003e 0 \u0026\u0026 _reserveB \u003e 0,\n \"SwapsHelper: INSUFFICIENT_LIQUIDITY\"\n );\n\n amountB = _amountA\n * _reserveB\n / _reserveA;\n }\n\n function getAmountOut(\n uint256 _amountIn,\n uint256 _reserveIn,\n uint256 _reserveOut\n )\n public\n pure\n returns (uint256 amountOut)\n {\n require(\n _amountIn \u003e 0,\n \"SwapsHelper: INSUFFICIENT_INPUT_AMOUNT\"\n );\n\n require(\n _reserveIn \u003e 0 \u0026\u0026 _reserveOut \u003e 0,\n \"SwapsHelper: INSUFFICIENT_LIQUIDITY\"\n );\n\n uint256 amountInWithFee = _amountIn * 997;\n uint256 numerator = amountInWithFee * _reserveOut;\n uint256 denominator = _reserveIn * 1000 + amountInWithFee;\n\n amountOut = numerator / denominator;\n }\n\n function getAmountIn(\n uint256 _amountOut,\n uint256 _reserveIn,\n uint256 _reserveOut\n )\n public\n pure\n returns (uint256 amountIn)\n {\n require(\n _amountOut \u003e 0,\n \"SwapsHelper: INSUFFICIENT_OUTPUT_AMOUNT\"\n );\n\n require(\n _reserveIn \u003e 0 \u0026\u0026\n _reserveOut \u003e 0,\n \"SwapsHelper: INSUFFICIENT_LIQUIDITY\"\n );\n\n uint256 numerator = _reserveIn * _amountOut * 1000;\n uint256 denominator = (_reserveOut - _amountOut) * 997;\n\n amountIn = numerator / denominator + 1;\n }\n\n\n bytes4 constant TRANSFER = bytes4(\n keccak256(\n bytes(\n \"transfer(address,uint256)\"\n )\n )\n );\n\n bytes4 constant TRANSFER_FROM = bytes4(\n keccak256(\n bytes(\n \"transferFrom(address,address,uint256)\"\n )\n )\n );\n\n function _safeTransfer(\n address _token,\n address _to,\n uint256 _value\n )\n internal\n {\n (bool success, bytes memory data) = _token.call(\n abi.encodeWithSelector(\n TRANSFER,\n _to,\n _value\n )\n );\n\n require(\n success \u0026\u0026 (\n data.length == 0 || abi.decode(\n data, (bool)\n )\n ),\n \"SwapsHelper: TRANSFER_FAILED\"\n );\n }\n\n function _safeTransferFrom(\n address _token,\n address _from,\n address _to,\n uint256 _value\n )\n internal\n {\n (bool success, bytes memory data) = _token.call(\n abi.encodeWithSelector(\n TRANSFER_FROM,\n _from,\n _to,\n _value\n )\n );\n\n require(\n success \u0026\u0026 (\n data.length == 0 || abi.decode(\n data, (bool)\n )\n ),\n \"SwapsHelper: TRANSFER_FROM_FAILED\"\n );\n }\n\n function _safeTransferETH(\n address to,\n uint256 value\n )\n internal\n {\n (bool success,) = to.call{\n value: value\n }(new bytes(0));\n\n require(\n success,\n \"SwapsHelper: ETH_TRANSFER_FAILED\"\n );\n }\n\n function _pairFor(\n address _factory,\n address _tokenA,\n address _tokenB,\n address _implementation\n )\n internal\n pure\n returns (address predicted)\n {\n (address token0, address token1) = _tokenA \u003c _tokenB\n ? (_tokenA, _tokenB)\n : (_tokenB, _tokenA);\n\n bytes32 salt = keccak256(\n abi.encodePacked(\n token0,\n token1\n )\n );\n\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(ptr, 0x14), shl(0x60, _implementation))\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)\n mstore(add(ptr, 0x38), shl(0x60, _factory))\n mstore(add(ptr, 0x4c), salt)\n mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))\n predicted := keccak256(add(ptr, 0x37), 0x55)\n }\n }\n}\n"},"SwapsPair.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\nimport \"./IERC20.sol\";\nimport \"./ISwapsFactory.sol\";\nimport \"./ISwapsCallee.sol\";\nimport \"./SwapsERC20.sol\";\n\ncontract SwapsPair is SwapsERC20 {\n\n uint224 constant Q112 = 2 ** 112;\n uint112 constant UINT112_MAX = type(uint112).max;\n uint256 public constant MINIMUM_LIQUIDITY = 10 ** 3;\n\n bytes4 private constant SELECTOR = bytes4(\n keccak256(bytes(\u0027transfer(address,uint256)\u0027))\n );\n\n address public factory;\n address public token0;\n address public token1;\n\n uint112 private reserve0;\n uint112 private reserve1;\n uint32 private blockTimestampLast;\n\n uint256 public price0CumulativeLast;\n uint256 public price1CumulativeLast;\n\n uint256 public kLast;\n uint256 private unlocked;\n\n modifier lock() {\n require(\n unlocked == 1,\n \"SwapsPair: LOCKED\"\n );\n unlocked = 0;\n _;\n unlocked = 1;\n }\n\n event Mint(\n address indexed sender,\n uint256 amount0,\n uint256 amount1\n );\n\n event Burn(\n address indexed sender,\n uint256 amount0,\n uint256 amount1,\n address indexed to\n );\n\n event Swap(\n address indexed sender,\n uint256 amount0In,\n uint256 amount1In,\n uint256 amount0Out,\n uint256 amount1Out,\n address indexed to\n );\n\n event Sync(\n uint112 reserve0,\n uint112 reserve1\n );\n\n function initialize(\n address _token0,\n address _token1\n )\n external\n {\n require(\n factory == ZERO_ADDRESS,\n \"SwapsPair: ALREADY_INITIALIZED\"\n );\n\n token0 = _token0;\n token1 = _token1;\n factory = msg.sender;\n unlocked = 1;\n }\n\n function getReserves()\n public\n view\n returns (\n uint112,\n uint112,\n uint32\n )\n {\n return (\n reserve0,\n reserve1,\n blockTimestampLast\n );\n }\n\n function _update(\n uint256 _balance0,\n uint256 _balance1,\n uint112 _reserve0,\n uint112 _reserve1\n )\n private\n {\n require(\n _balance0 \u003c= UINT112_MAX \u0026\u0026\n _balance1 \u003c= UINT112_MAX,\n \"SwapsPair: OVERFLOW\"\n );\n\n uint32 blockTimestamp = uint32(block.timestamp % 2 ** 32);\n\n unchecked {\n uint32 timeElapsed = blockTimestamp - blockTimestampLast;\n if (timeElapsed \u003e 0 \u0026\u0026 _reserve0 != 0 \u0026\u0026 _reserve1 != 0) {\n price0CumulativeLast += uint256(uqdiv(encode(_reserve1), _reserve0)) * timeElapsed;\n price1CumulativeLast += uint256(uqdiv(encode(_reserve0), _reserve1)) * timeElapsed;\n }\n }\n\n reserve0 = uint112(_balance0);\n reserve1 = uint112(_balance1);\n\n blockTimestampLast = blockTimestamp;\n\n emit Sync(\n reserve0,\n reserve1\n );\n }\n\n function _mintFee(\n uint112 _reserve0,\n uint112 _reserve1,\n uint256 _kLast\n )\n private\n {\n if (_kLast == 0) return;\n\n uint256 rootK = sqrt(uint256(_reserve0) * _reserve1);\n uint256 rootKLast = sqrt(_kLast);\n\n if (rootK \u003e rootKLast) {\n\n uint256 liquidity = totalSupply\n * (rootK - rootKLast)\n / (rootK * 5 + rootKLast);\n\n if (liquidity == 0) return;\n\n _mint(\n ISwapsFactory(factory).feeTo(),\n liquidity\n );\n }\n }\n\n function mint(\n address _to\n )\n external\n lock\n returns (uint256 liquidity)\n {\n (\n uint112 _reserve0,\n uint112 _reserve1,\n\n ) = getReserves();\n\n uint256 balance0 = IERC20(token0).balanceOf(address(this));\n uint256 balance1 = IERC20(token1).balanceOf(address(this));\n\n uint256 amount0 = balance0 - _reserve0;\n uint256 amount1 = balance1 - _reserve1;\n\n _mintFee(\n _reserve0,\n _reserve1,\n kLast\n );\n\n uint256 _totalSupply = totalSupply;\n\n if (_totalSupply == 0) {\n\n liquidity = sqrt(\n amount0 * amount1\n ) - MINIMUM_LIQUIDITY;\n\n _mint(\n ZERO_ADDRESS,\n MINIMUM_LIQUIDITY\n );\n\n } else {\n\n liquidity = min(\n amount0 * _totalSupply / _reserve0,\n amount1 * _totalSupply / _reserve1\n );\n }\n\n require(\n liquidity \u003e 0,\n \"INSUFFICIENT_LIQUIDITY_MINTED\"\n );\n\n _mint(\n _to,\n liquidity\n );\n\n _update(\n balance0,\n balance1,\n _reserve0,\n _reserve1\n );\n\n kLast = uint256(reserve0) * reserve1;\n\n emit Mint(\n msg.sender,\n amount0,\n amount1\n );\n }\n\n function burn(\n address _to\n )\n external\n lock\n returns (\n uint256 amount0,\n uint256 amount1\n )\n {\n (\n uint112 _reserve0,\n uint112 _reserve1,\n\n ) = getReserves();\n\n address _token0 = token0;\n address _token1 = token1;\n\n uint256 balance0 = IERC20(_token0).balanceOf(address(this));\n uint256 balance1 = IERC20(_token1).balanceOf(address(this));\n\n uint256 liquidity = balanceOf[address(this)];\n\n _mintFee(\n _reserve0,\n _reserve1,\n kLast\n );\n\n uint256 _totalSupply = totalSupply;\n\n amount0 = liquidity * balance0 / _totalSupply;\n amount1 = liquidity * balance1 / _totalSupply;\n\n require(\n amount0 \u003e 0 \u0026\u0026\n amount1 \u003e 0,\n \"INSUFFICIENT_LIQUIDITY_BURNED\"\n );\n\n _burn(\n address(this),\n liquidity\n );\n\n _safeTransfer(\n _token0,\n _to,\n amount0\n );\n\n _safeTransfer(\n _token1,\n _to,\n amount1\n );\n\n balance0 = IERC20(_token0).balanceOf(address(this));\n balance1 = IERC20(_token1).balanceOf(address(this));\n\n _update(\n balance0,\n balance1,\n _reserve0,\n _reserve1\n );\n\n kLast = uint256(reserve0) * reserve1;\n\n emit Burn(\n msg.sender,\n amount0,\n amount1,\n _to\n );\n }\n\n function swap(\n uint256 _amount0Out,\n uint256 _amount1Out,\n address _to,\n bytes calldata _data\n )\n external\n lock\n {\n require(\n _amount0Out \u003e 0 ||\n _amount1Out \u003e 0,\n \"INSUFFICIENT_OUTPUT_AMOUNT\"\n );\n\n (\n uint112 _reserve0,\n uint112 _reserve1,\n\n ) = getReserves();\n\n require(\n _amount0Out \u003c _reserve0 \u0026\u0026\n _amount1Out \u003c _reserve1,\n \"INSUFFICIENT_LIQUIDITY\"\n );\n\n uint256 balance0;\n uint256 balance1;\n\n {\n address _token0 = token0;\n address _token1 = token1;\n\n if (_amount0Out \u003e 0) _safeTransfer(_token0, _to, _amount0Out);\n if (_amount1Out \u003e 0) _safeTransfer(_token1, _to, _amount1Out);\n\n if (_data.length \u003e 0) ISwapsCallee(_to).swapsCall(\n msg.sender,\n _amount0Out,\n _amount1Out,\n _data\n );\n\n balance0 = IERC20(_token0).balanceOf(address(this));\n balance1 = IERC20(_token1).balanceOf(address(this));\n }\n\n uint256 _amount0In =\n balance0 \u003e _reserve0 - _amount0Out ?\n balance0 - (_reserve0 - _amount0Out) : 0;\n\n uint256 _amount1In =\n balance1 \u003e _reserve1 - _amount1Out ?\n balance1 - (_reserve1 - _amount1Out) : 0;\n\n require(\n _amount0In \u003e 0 ||\n _amount1In \u003e 0,\n \"INSUFFICIENT_INPUT_AMOUNT\"\n );\n\n {\n uint256 balance0Adjusted = balance0 * 1000 - (_amount0In * 3);\n uint256 balance1Adjusted = balance1 * 1000 - (_amount1In * 3);\n\n require(\n balance0Adjusted * balance1Adjusted \u003e=\n uint256(_reserve0)\n * _reserve1\n * (1000 ** 2)\n );\n }\n\n _update(\n balance0,\n balance1,\n _reserve0,\n _reserve1\n );\n\n emit Swap(\n msg.sender,\n _amount0In,\n _amount1In,\n _amount0Out,\n _amount1Out,\n _to\n );\n }\n\n function skim()\n external\n lock\n {\n address _token0 = token0;\n address _token1 = token1;\n address _feesTo = ISwapsFactory(factory).feeTo();\n\n _safeTransfer(\n _token0,\n _feesTo,\n IERC20(_token0).balanceOf(address(this)) - reserve0\n );\n\n _safeTransfer(\n _token1,\n _feesTo,\n IERC20(_token1).balanceOf(address(this)) - reserve1\n );\n }\n\n function sync()\n external\n lock\n {\n _update(\n IERC20(token0).balanceOf(address(this)),\n IERC20(token1).balanceOf(address(this)),\n reserve0,\n reserve1\n );\n }\n\n function encode(\n uint112 _y\n )\n pure\n internal\n returns (uint224 z)\n {\n unchecked {\n z = uint224(_y) * Q112;\n }\n }\n\n function uqdiv(\n uint224 _x,\n uint112 _y\n )\n pure\n internal\n returns (uint224 z)\n {\n unchecked {\n z = _x / uint224(_y);\n }\n }\n\n function min(\n uint256 _x,\n uint256 _y\n )\n internal\n pure\n returns (uint256 z)\n {\n z = _x \u003c _y ? _x : _y;\n }\n\n function sqrt(\n uint256 _y\n )\n internal\n pure\n returns (uint256 z)\n {\n unchecked {\n if (_y \u003e 3) {\n z = _y;\n uint256 x = _y / 2 + 1;\n while (x \u003c z) {\n z = x;\n x = (_y / x + x) / 2;\n }\n } else if (_y != 0) {\n z = 1;\n }\n }\n }\n\n function _safeTransfer(\n address _token,\n address _to,\n uint256 _value\n )\n internal\n {\n (bool success, bytes memory data) = _token.call(\n abi.encodeWithSelector(\n SELECTOR,\n _to,\n _value\n )\n );\n\n require(\n success \u0026\u0026 (\n data.length == 0 || abi.decode(\n data, (bool)\n )\n ),\n \"SwapsPair: TRANSFER_FAILED\"\n );\n }\n}\n"},"SwapsRouter.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\nimport \"./IWETH.sol\";\nimport \"./IERC20.sol\";\nimport \"./ISwapsFactory.sol\";\nimport \"./ISwapsPair.sol\";\nimport \"./SwapsHelper.sol\";\n\ncontract SwapsRouter is SwapsHelper {\n\n address public immutable FACTORY;\n address public immutable WETH;\n address public immutable PAIR;\n\n modifier ensure(\n uint256 _deadline\n ) {\n require(\n _deadline \u003e= block.timestamp,\n \"SwapsRouter: DEADLINE_EXPIRED\"\n );\n _;\n }\n\n constructor(\n address _factory,\n address _WETH\n ) {\n FACTORY = _factory;\n WETH = _WETH;\n PAIR = ISwapsFactory(_factory).cloneTarget();\n }\n\n receive()\n external\n payable\n {\n require(\n msg.sender == WETH,\n \"SwapsRouter: INVALID_SENDER\"\n );\n }\n\n function _addLiquidity(\n address _tokenA,\n address _tokenB,\n uint256 _amountADesired,\n uint256 _amountBDesired,\n uint256 _amountAMin,\n uint256 _amountBMin\n )\n internal\n returns (uint256, uint256)\n {\n if (ISwapsFactory(FACTORY).getPair(_tokenA, _tokenB) == ZERO_ADDRESS) {\n ISwapsFactory(FACTORY).createPair(\n _tokenA,\n _tokenB\n );\n }\n\n (\n uint256 reserveA,\n uint256 reserveB\n\n ) = getReserves(\n FACTORY,\n _tokenA,\n _tokenB\n );\n\n if (reserveA == 0 \u0026\u0026 reserveB == 0) {\n return (\n _amountADesired,\n _amountBDesired\n );\n }\n\n uint256 amountBOptimal = quote(\n _amountADesired,\n reserveA,\n reserveB\n );\n\n if (amountBOptimal \u003c= _amountBDesired) {\n\n require(\n amountBOptimal \u003e= _amountBMin,\n \"SwapsRouter: INSUFFICIENT_B_AMOUNT\"\n );\n\n return (\n _amountADesired,\n amountBOptimal\n );\n }\n\n uint256 amountAOptimal = quote(\n _amountBDesired,\n reserveB,\n reserveA\n );\n\n require(\n amountAOptimal \u003c= _amountADesired,\n \"SwapsRouter: INVALID_DESIRED_AMOUNT\"\n );\n\n require(\n amountAOptimal \u003e= _amountAMin,\n \"SwapsRouter: INSUFFICIENT_A_AMOUNT\"\n );\n\n return (\n amountAOptimal,\n _amountBDesired\n );\n }\n\n function addLiquidity(\n address _tokenA,\n address _tokenB,\n uint256 _amountADesired,\n uint256 _amountBDesired,\n uint256 _amountAMin,\n uint256 _amountBMin,\n address _to,\n uint256 _deadline\n )\n external\n ensure(_deadline)\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n )\n {\n (amountA, amountB) = _addLiquidity(\n _tokenA,\n _tokenB,\n _amountADesired,\n _amountBDesired,\n _amountAMin,\n _amountBMin\n );\n\n address pair = _pairFor(\n FACTORY,\n _tokenA,\n _tokenB,\n PAIR\n );\n\n _safeTransferFrom(\n _tokenA,\n msg.sender,\n pair,\n amountA\n );\n\n _safeTransferFrom(\n _tokenB,\n msg.sender,\n pair,\n amountB\n );\n\n liquidity = ISwapsPair(pair).mint(_to);\n }\n\n function addLiquidityETH(\n address _token,\n uint256 _amountTokenDesired,\n uint256 _amountTokenMin,\n uint256 _amountETHMin,\n address _to,\n uint256 _deadline\n )\n external\n payable\n ensure(_deadline)\n returns (\n uint256 amountToken,\n uint256 amountETH,\n uint256 liquidity\n )\n {\n (amountToken, amountETH) = _addLiquidity(\n _token,\n WETH,\n _amountTokenDesired,\n msg.value,\n _amountTokenMin,\n _amountETHMin\n );\n\n address pair = _pairFor(\n FACTORY,\n _token,\n WETH,\n PAIR\n );\n\n _safeTransferFrom(\n _token,\n msg.sender,\n pair,\n amountToken\n );\n\n IWETH(WETH).deposit{\n value: amountETH\n }();\n\n require(\n IWETH(WETH).transfer(\n pair,\n amountETH\n ),\n \"SwapsRouter: TRANSFER_FAIL\"\n );\n\n liquidity = ISwapsPair(pair).mint(_to);\n\n if (msg.value \u003e amountETH) {\n unchecked {\n _safeTransferETH(\n msg.sender,\n msg.value - amountETH\n );\n }\n }\n }\n\n function removeLiquidity(\n address _tokenA,\n address _tokenB,\n uint256 _liquidity,\n uint256 _amountAMin,\n uint256 _amountBMin,\n address _to,\n uint256 _deadline\n )\n public\n ensure(_deadline)\n returns (\n uint256 amountA,\n uint256 amountB\n )\n {\n address pair = _pairFor(\n FACTORY,\n _tokenA,\n _tokenB,\n PAIR\n );\n\n _safeTransferFrom(\n pair,\n msg.sender,\n pair,\n _liquidity\n );\n\n (\n uint256 amount0,\n uint256 amount1\n\n ) = ISwapsPair(pair).burn(_to);\n\n (address token0,) = sortTokens(\n _tokenA,\n _tokenB\n );\n\n (amountA, amountB) = _tokenA == token0\n ? (amount0, amount1)\n : (amount1, amount0);\n\n require(\n amountA \u003e= _amountAMin,\n \"SwapsRouter: INSUFFICIENT_A_AMOUNT\"\n );\n\n require(\n amountB \u003e= _amountBMin,\n \"SwapsRouter: INSUFFICIENT_B_AMOUNT\"\n );\n }\n\n function removeLiquidityETH(\n address _token,\n uint256 _liquidity,\n uint256 _amountTokenMin,\n uint256 _amountETHMin,\n address _to,\n uint256 _deadline\n )\n public\n ensure(_deadline)\n returns (\n uint256 amountToken,\n uint256 amountETH\n )\n {\n (amountToken, amountETH) = removeLiquidity(\n _token,\n WETH,\n _liquidity,\n _amountTokenMin,\n _amountETHMin,\n address(this),\n _deadline\n );\n\n _safeTransfer(\n _token,\n _to,\n amountToken\n );\n\n IWETH(WETH).withdraw(\n amountETH\n );\n\n _safeTransferETH(\n _to,\n amountETH\n );\n }\n\n function removeLiquidityWithPermit(\n address _tokenA,\n address _tokenB,\n uint256 _liquidity,\n uint256 _amountAMin,\n uint256 _amountBMin,\n address _to,\n uint256 _deadline,\n bool _approveMax,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\n external\n returns (uint256, uint256)\n {\n address pair = _pairFor(\n FACTORY,\n _tokenA,\n _tokenB,\n PAIR\n );\n\n uint256 value = _approveMax\n ? UINT256_MAX\n : _liquidity;\n\n ISwapsPair(pair).permit(\n msg.sender,\n address(this),\n value,\n _deadline,\n _v,\n _r,\n _s\n );\n\n return removeLiquidity(\n _tokenA,\n _tokenB,\n _liquidity,\n _amountAMin,\n _amountBMin,\n _to,\n _deadline\n );\n }\n\n function removeLiquidityETHWithPermit(\n address _token,\n uint256 _liquidity,\n uint256 _amountTokenMin,\n uint256 _amountETHMin,\n address _to,\n uint256 _deadline,\n bool _approveMax,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\n external\n returns (uint256, uint256)\n {\n address pair = _pairFor(\n FACTORY,\n _token,\n WETH,\n PAIR\n );\n\n uint256 value = _approveMax\n ? UINT256_MAX\n : _liquidity;\n\n ISwapsPair(pair).permit(\n msg.sender,\n address(this),\n value,\n _deadline,\n _v,\n _r,\n _s\n );\n\n return removeLiquidityETH(\n _token,\n _liquidity,\n _amountTokenMin,\n _amountETHMin,\n _to,\n _deadline\n );\n }\n\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address _token,\n uint256 _liquidity,\n uint256 _amountTokenMin,\n uint256 _amountETHMin,\n address _to,\n uint256 _deadline\n )\n public\n ensure(_deadline)\n returns (uint256 amountETH)\n {\n (, amountETH) = removeLiquidity(\n _token,\n WETH,\n _liquidity,\n _amountTokenMin,\n _amountETHMin,\n address(this),\n _deadline\n );\n\n _safeTransfer(\n _token,\n _to,\n IERC20(_token).balanceOf(address(this))\n );\n\n IWETH(WETH).withdraw(\n amountETH\n );\n\n _safeTransferETH(\n _to,\n amountETH\n );\n }\n\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address _token,\n uint256 _liquidity,\n uint256 _amountTokenMin,\n uint256 _amountETHMin,\n address _to,\n uint256 _deadline,\n bool _approveMax,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\n external\n returns (uint256 amountETH)\n {\n address pair = _pairFor(\n FACTORY,\n _token,\n WETH,\n PAIR\n );\n\n uint256 value = _approveMax\n ? UINT256_MAX\n : _liquidity;\n\n ISwapsPair(pair).permit(\n msg.sender,\n address(this),\n value,\n _deadline,\n _v,\n _r,\n _s\n );\n\n amountETH = removeLiquidityETHSupportingFeeOnTransferTokens(\n _token,\n _liquidity,\n _amountTokenMin,\n _amountETHMin,\n _to,\n _deadline\n );\n }\n\n function _swap(\n uint256[] memory _amounts,\n address[] memory _path,\n address _to\n )\n internal\n {\n for (uint256 i; i \u003c _path.length - 1; i++) {\n\n (address input, address output) = (\n _path[i],\n _path[i + 1]\n );\n\n (address token0,) = sortTokens(\n input,\n output\n );\n\n uint256 amountOut = _amounts[i + 1];\n\n (uint256 amount0Out, uint256 amount1Out) = input == token0\n ? (uint(0), amountOut)\n : (amountOut, uint(0));\n\n address to = i \u003c _path.length - 2\n ? _pairFor(FACTORY, output, _path[i + 2], PAIR)\n : _to;\n\n ISwapsPair(\n _pairFor(\n FACTORY,\n input,\n output,\n PAIR\n )\n ).swap(\n amount0Out,\n amount1Out,\n to,\n new bytes(0)\n );\n }\n }\n\n function swapExactTokensForTokens(\n uint256 _amountIn,\n uint256 _amountOutMin,\n address[] calldata _path,\n address _to,\n uint256 _deadline\n )\n external\n ensure(_deadline)\n returns (uint256[] memory amounts)\n {\n amounts = _getAmountsOut(\n FACTORY,\n _amountIn,\n _path\n );\n\n require(\n amounts[amounts.length - 1] \u003e= _amountOutMin,\n \"SwapsRouter: INSUFFICIENT_OUTPUT_AMOUNT\"\n );\n\n _safeTransferFrom(\n _path[0],\n msg.sender,\n _pairFor(\n FACTORY,\n _path[0],\n _path[1],\n PAIR\n ),\n amounts[0]\n );\n\n _swap(\n amounts,\n _path,\n _to\n );\n }\n\n function swapTokensForExactTokens(\n uint256 _amountOut,\n uint256 _amountInMax,\n address[] calldata _path,\n address _to,\n uint256 _deadline\n )\n external\n ensure(_deadline)\n returns (uint256[] memory amounts)\n {\n amounts = _getAmountsIn(\n FACTORY,\n _amountOut,\n _path\n );\n\n require(\n amounts[0] \u003c= _amountInMax,\n \"SwapsRouter: EXCESSIVE_INPUT_AMOUNT\"\n );\n\n _safeTransferFrom(\n _path[0],\n msg.sender,\n _pairFor(\n FACTORY,\n _path[0],\n _path[1],\n PAIR\n ),\n amounts[0]\n );\n\n _swap(\n amounts,\n _path,\n _to\n );\n }\n\n function swapExactETHForTokens(\n uint256 _amountOutMin,\n address[] calldata _path,\n address _to,\n uint256 _deadline\n )\n external\n payable\n ensure(_deadline)\n returns (uint256[] memory amounts)\n {\n require(\n _path[0] == WETH,\n \"SwapsRouter: INVALID_PATH\"\n );\n\n amounts = _getAmountsOut(\n FACTORY,\n msg.value,\n _path\n );\n\n require(\n amounts[amounts.length - 1] \u003e= _amountOutMin,\n \"SwapsRouter: INSUFFICIENT_OUTPUT_AMOUNT\"\n );\n\n IWETH(WETH).deposit{\n value: amounts[0]\n }();\n\n require(\n IWETH(WETH).transfer(\n _pairFor(\n FACTORY,\n _path[0],\n _path[1],\n PAIR\n ),\n amounts[0]\n ),\n \"SwapsRouter: TRANSFER_FAIL\"\n );\n\n _swap(\n amounts,\n _path,\n _to\n );\n }\n\n function swapTokensForExactETH(\n uint256 _amountOut,\n uint256 _amountInMax,\n address[] calldata _path,\n address _to,\n uint256 _deadline\n )\n external\n ensure(_deadline)\n returns (uint256[] memory amounts)\n {\n require(\n _path[_path.length - 1] == WETH,\n \"SwapsRouter: INVALID_PATH\"\n );\n\n amounts = _getAmountsIn(\n FACTORY,\n _amountOut,\n _path\n );\n\n require(\n amounts[0] \u003c= _amountInMax,\n \"SwapsRouter: EXCESSIVE_INPUT_AMOUNT\"\n );\n\n _safeTransferFrom(\n _path[0],\n msg.sender,\n _pairFor(\n FACTORY,\n _path[0],\n _path[1],\n PAIR\n ),\n amounts[0]\n );\n\n _swap(\n amounts,\n _path,\n address(this)\n );\n\n IWETH(WETH).withdraw(\n amounts[amounts.length - 1]\n );\n\n _safeTransferETH(\n _to,\n amounts[amounts.length - 1]\n );\n }\n\n function swapExactTokensForETH(\n uint256 _amountIn,\n uint256 _amountOutMin,\n address[] calldata _path,\n address _to,\n uint256 _deadline\n )\n external\n ensure(_deadline)\n returns (uint256[] memory amounts)\n {\n require(\n _path[_path.length - 1] == WETH,\n \"SwapsRouter: INVALID_PATH\"\n );\n\n amounts = _getAmountsOut(\n FACTORY,\n _amountIn,\n _path\n );\n\n require(\n amounts[amounts.length - 1] \u003e= _amountOutMin,\n \"SwapsRouter: INSUFFICIENT_OUTPUT_AMOUNT\"\n );\n\n _safeTransferFrom(\n _path[0],\n msg.sender,\n _pairFor(\n FACTORY,\n _path[0],\n _path[1],\n PAIR\n ),\n amounts[0]\n );\n\n _swap(\n amounts,\n _path,\n address(this)\n );\n\n IWETH(WETH).withdraw(\n amounts[amounts.length - 1]\n );\n\n _safeTransferETH(\n _to,\n amounts[amounts.length - 1]\n );\n }\n\n function swapETHForExactTokens(\n uint256 _amountOut,\n address[] calldata _path,\n address _to,\n uint256 _deadline\n )\n external\n payable\n ensure(_deadline)\n returns (uint256[] memory amounts)\n {\n require(\n _path[0] == WETH,\n \"SwapsRouter: INVALID_PATH\"\n );\n\n amounts = _getAmountsIn(\n FACTORY,\n _amountOut,\n _path\n );\n\n require(\n amounts[0] \u003c= msg.value,\n \"SwapsRouter: EXCESSIVE_INPUT_AMOUNT\"\n );\n\n IWETH(WETH).deposit{\n value: amounts[0]\n }();\n\n require(\n IWETH(WETH).transfer(\n _pairFor(\n FACTORY,\n _path[0],\n _path[1],\n PAIR\n ),\n amounts[0]\n ),\n \"SwapsRouter: TRANSFER_FAIL\"\n );\n\n _swap(\n amounts,\n _path,\n _to\n );\n\n if (msg.value \u003e amounts[0]) {\n unchecked {\n _safeTransferETH(\n msg.sender,\n msg.value - amounts[0]\n );\n }\n }\n }\n\n function _swapSupportingFeeOnTransferTokens(\n address[] memory _path,\n address _to\n )\n internal\n {\n for (uint256 i; i \u003c _path.length - 1; i++) {\n\n (address input, address output) = (\n _path[i],\n _path[i + 1]\n );\n\n (address token0,) = sortTokens(\n input,\n output\n );\n\n ISwapsPair pair = ISwapsPair(\n _pairFor(\n FACTORY,\n input,\n output,\n PAIR\n )\n );\n\n uint256 amountInput;\n uint256 amountOutput;\n\n {\n\n (\n uint256 reserve0,\n uint256 reserve1,\n\n ) = pair.getReserves();\n\n (uint256 reserveInput, uint256 reserveOutput) = input == token0\n ? (reserve0, reserve1)\n : (reserve1, reserve0);\n\n amountInput = IERC20(input).balanceOf(address(pair)) - reserveInput;\n amountOutput = getAmountOut(\n amountInput,\n reserveInput,\n reserveOutput\n );\n\n }\n\n (uint256 amount0Out, uint256 amount1Out) = input == token0\n ? (uint(0), amountOutput)\n : (amountOutput, uint(0));\n\n address to = i \u003c _path.length - 2\n ? _pairFor(FACTORY, output, _path[i + 2], PAIR)\n : _to;\n\n pair.swap(\n amount0Out,\n amount1Out,\n to,\n new bytes(0)\n );\n }\n }\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 _amountIn,\n uint256 _amountOutMin,\n address[] calldata _path,\n address _to,\n uint256 _deadline\n )\n external\n ensure(_deadline)\n {\n _safeTransferFrom(\n _path[0],\n msg.sender,\n _pairFor(\n FACTORY,\n _path[0],\n _path[1],\n PAIR\n ),\n _amountIn\n );\n\n uint256 balanceBefore = IERC20(_path[_path.length - 1]).balanceOf(_to);\n\n _swapSupportingFeeOnTransferTokens(\n _path,\n _to\n );\n\n require(\n IERC20(_path[_path.length - 1]).balanceOf(_to) - balanceBefore \u003e= _amountOutMin,\n \"SwapsRouter: INSUFFICIENT_OUTPUT_AMOUNT\"\n );\n }\n\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 _amountOutMin,\n address[] calldata _path,\n address _to,\n uint256 _deadline\n )\n external\n payable\n ensure(_deadline)\n {\n require(\n _path[0] == WETH,\n \"SwapsRouter: INVALID_PATH\"\n );\n\n uint256 amountIn = msg.value;\n\n IWETH(WETH).deposit{\n value: amountIn\n }();\n\n require(\n IWETH(WETH).transfer(\n _pairFor(\n FACTORY,\n _path[0],\n _path[1],\n PAIR\n ),\n amountIn\n ),\n \"SwapsRouter: TRANSFER_FAIL\"\n );\n\n uint256 balanceBefore = IERC20(_path[_path.length - 1]).balanceOf(_to);\n\n _swapSupportingFeeOnTransferTokens(\n _path,\n _to\n );\n\n require(\n IERC20(_path[_path.length - 1]).balanceOf(_to) - balanceBefore \u003e= _amountOutMin,\n \"SwapsRouter: INSUFFICIENT_OUTPUT_AMOUNT\"\n );\n }\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 _amountIn,\n uint256 _amountOutMin,\n address[] calldata _path,\n address _to,\n uint256 _deadline\n )\n external\n ensure(_deadline)\n {\n require(\n _path[_path.length - 1] == WETH,\n \"SwapsRouter: INVALID_PATH\"\n );\n\n _safeTransferFrom(\n _path[0],\n msg.sender,\n _pairFor(\n FACTORY,\n _path[0],\n _path[1],\n PAIR\n ),\n _amountIn\n );\n\n _swapSupportingFeeOnTransferTokens(\n _path,\n address(this)\n );\n\n uint256 amountOut = IERC20(WETH).balanceOf(\n address(this)\n );\n\n require(\n amountOut \u003e= _amountOutMin,\n \"SwapsRouter: INSUFFICIENT_OUTPUT_AMOUNT\"\n );\n\n IWETH(WETH).withdraw(\n amountOut\n );\n\n _safeTransferETH(\n _to,\n amountOut\n );\n }\n\n function pairFor(\n address _factory,\n address _tokenA,\n address _tokenB\n )\n external\n view\n returns (address predicted)\n {\n predicted = _pairFor(\n _factory,\n _tokenA,\n _tokenB,\n PAIR\n );\n }\n\n function getAmountsOut(\n uint256 _amountIn,\n address[] memory _path\n )\n external\n view\n returns (uint256[] memory amounts)\n {\n return _getAmountsOut(\n FACTORY,\n _amountIn,\n _path\n );\n }\n\n function getAmountsIn(\n uint256 _amountOut,\n address[] memory _path\n )\n external\n view\n returns (uint256[] memory amounts)\n {\n return _getAmountsIn(\n FACTORY,\n _amountOut,\n _path\n );\n }\n\n function getReserves(\n address _factory,\n address _tokenA,\n address _tokenB\n )\n internal\n view\n returns (\n uint256 reserveA,\n uint256 reserveB\n )\n {\n (address token0,) = sortTokens(\n _tokenA,\n _tokenB\n );\n\n (\n uint256 reserve0,\n uint256 reserve1,\n\n ) = ISwapsPair(\n _pairFor(\n _factory,\n _tokenA,\n _tokenB,\n PAIR\n )\n ).getReserves();\n\n (reserveA, reserveB) = _tokenA == token0\n ? (reserve0, reserve1)\n : (reserve1, reserve0);\n }\n\n function _getAmountsOut(\n address _factory,\n uint256 _amountIn,\n address[] memory _path\n )\n internal\n view\n returns (uint256[] memory amounts)\n {\n require(\n _path.length \u003e= 2,\n \"SwapsRouter: INVALID_PATH\"\n );\n\n amounts = new uint256[](\n _path.length\n );\n\n amounts[0] = _amountIn;\n\n for (uint256 i; i \u003c _path.length - 1; i++) {\n\n (\n uint256 reserveIn,\n uint256 reserveOut\n\n ) = getReserves(\n _factory,\n _path[i],\n _path[i + 1]\n );\n\n amounts[i + 1] = getAmountOut(\n amounts[i],\n reserveIn,\n reserveOut\n );\n }\n }\n\n function _getAmountsIn(\n address _factory,\n uint256 _amountOut,\n address[] memory _path\n )\n internal\n view\n returns (uint256[] memory amounts)\n {\n require(\n _path.length \u003e= 2,\n \"SwapsRouter: INVALID_PATH\"\n );\n\n amounts = new uint256[](\n _path.length\n );\n\n amounts[amounts.length - 1] = _amountOut;\n\n for (uint256 i = _path.length - 1; i \u003e 0; i--) {\n\n (\n uint256 reserveIn,\n uint256 reserveOut\n\n ) = getReserves(\n _factory,\n _path[i - 1],\n _path[i]\n );\n\n amounts[i - 1] = getAmountIn(\n amounts[i],\n reserveIn,\n reserveOut\n );\n }\n }\n}\n\ncontract RouterCodeCheck {\n\n function routerCodeHash()\n external\n pure\n returns (bytes32)\n {\n return keccak256(\n type(SwapsRouter).creationCode\n );\n }\n}\n"}}File 2 of 4: SwapsPair
{"IERC20.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ninterface IERC20 {\n\n function balanceOf(\n address _owner\n )\n external\n view\n returns (uint256);\n}\n"},"ISwapsCallee.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ninterface ISwapsCallee {\n\n function swapsCall(\n address _sender,\n uint256 _amount0,\n uint256 _amount1,\n bytes calldata _data\n )\n external;\n}\n"},"ISwapsFactory.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ninterface ISwapsFactory {\n\n function feeTo()\n external\n view\n returns (address);\n\n function feeToSetter()\n external\n view\n returns (address);\n\n function getPair(\n address _tokenA,\n address _tokenB\n )\n external\n view\n returns (address pair);\n\n function allPairs(uint256)\n external\n view\n returns (address pair);\n\n function allPairsLength()\n external\n view\n returns (uint256);\n\n function createPair(\n address _tokenA,\n address _tokenB\n )\n external\n returns (address pair);\n\n function setFeeTo(\n address\n )\n external;\n\n function setFeeToSetter(\n address\n )\n external;\n\n function cloneTarget()\n external\n view\n returns (address target);\n}\n"},"SwapsERC20.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ncontract SwapsERC20 {\n\n string public constant name = \"Verse Exchange\";\n string public constant symbol = \"VERSE-X\";\n uint8 public constant decimals = 18;\n\n address constant ZERO_ADDRESS = address(0);\n uint256 constant UINT256_MAX = type(uint256).max;\n\n uint256 public totalSupply;\n\n mapping(address =\u003e uint256) public balanceOf;\n mapping(address =\u003e mapping(address =\u003e uint256)) public allowance;\n mapping(address =\u003e uint256) public nonces;\n\n bytes32 public immutable DOMAIN_SEPARATOR;\n bytes32 public constant PERMIT_TYPEHASH = keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n );\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n event Transfer(\n address indexed from,\n address indexed to,\n uint256 value\n );\n\n constructor() {\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(bytes(\"1\")),\n block.chainid,\n address(this)\n )\n );\n }\n\n function _mint(\n address _to,\n uint256 _value\n )\n internal\n {\n totalSupply =\n totalSupply + _value;\n\n unchecked {\n balanceOf[_to] =\n balanceOf[_to] + _value;\n }\n\n emit Transfer(\n ZERO_ADDRESS,\n _to,\n _value\n );\n }\n\n function _burn(\n address _from,\n uint256 _value\n )\n internal\n {\n unchecked {\n totalSupply =\n totalSupply - _value;\n }\n\n balanceOf[_from] =\n balanceOf[_from] - _value;\n\n emit Transfer(\n _from,\n ZERO_ADDRESS,\n _value\n );\n }\n\n function _approve(\n address _owner,\n address _spender,\n uint256 _value\n )\n private\n {\n allowance[_owner][_spender] = _value;\n\n emit Approval(\n _owner,\n _spender,\n _value\n );\n }\n\n function _transfer(\n address _from,\n address _to,\n uint256 _value\n )\n private\n {\n balanceOf[_from] =\n balanceOf[_from] - _value;\n\n unchecked {\n balanceOf[_to] =\n balanceOf[_to] + _value;\n }\n\n emit Transfer(\n _from,\n _to,\n _value\n );\n }\n\n function approve(\n address _spender,\n uint256 _value\n )\n external\n returns (bool)\n {\n _approve(\n msg.sender,\n _spender,\n _value\n );\n\n return true;\n }\n\n function transfer(\n address _to,\n uint256 _value\n )\n external\n returns (bool)\n {\n _transfer(\n msg.sender,\n _to,\n _value\n );\n\n return true;\n }\n\n function transferFrom(\n address _from,\n address _to,\n uint256 _value\n )\n external\n returns (bool)\n {\n if (allowance[_from][msg.sender] != UINT256_MAX) {\n allowance[_from][msg.sender] -= _value;\n }\n\n _transfer(\n _from,\n _to,\n _value\n );\n\n return true;\n }\n\n function permit(\n address _owner,\n address _spender,\n uint256 _value,\n uint256 _deadline,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\n external\n {\n require(\n _deadline \u003e= block.timestamp,\n \"SwapsERC20: PERMIT_CALL_EXPIRED\"\n );\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(\n abi.encode(\n PERMIT_TYPEHASH,\n _owner,\n _spender,\n _value,\n nonces[_owner]++,\n _deadline\n )\n )\n )\n );\n\n if (uint256(_s) \u003e 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n revert(\"SwapsERC20: INVALID_SIGNATURE\");\n }\n\n address recoveredAddress = ecrecover(\n digest,\n _v,\n _r,\n _s\n );\n\n require(\n recoveredAddress != ZERO_ADDRESS \u0026\u0026\n recoveredAddress == _owner,\n \"SwapsERC20: INVALID_SIGNATURE\"\n );\n\n _approve(\n _owner,\n _spender,\n _value\n );\n }\n}\n"},"SwapsPair.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\nimport \"./IERC20.sol\";\nimport \"./ISwapsFactory.sol\";\nimport \"./ISwapsCallee.sol\";\nimport \"./SwapsERC20.sol\";\n\ncontract SwapsPair is SwapsERC20 {\n\n uint224 constant Q112 = 2 ** 112;\n uint112 constant UINT112_MAX = type(uint112).max;\n uint256 public constant MINIMUM_LIQUIDITY = 10 ** 3;\n\n bytes4 private constant SELECTOR = bytes4(\n keccak256(bytes(\u0027transfer(address,uint256)\u0027))\n );\n\n address public factory;\n address public token0;\n address public token1;\n\n uint112 private reserve0;\n uint112 private reserve1;\n uint32 private blockTimestampLast;\n\n uint256 public price0CumulativeLast;\n uint256 public price1CumulativeLast;\n\n uint256 public kLast;\n uint256 private unlocked;\n\n modifier lock() {\n require(\n unlocked == 1,\n \"SwapsPair: LOCKED\"\n );\n unlocked = 0;\n _;\n unlocked = 1;\n }\n\n event Mint(\n address indexed sender,\n uint256 amount0,\n uint256 amount1\n );\n\n event Burn(\n address indexed sender,\n uint256 amount0,\n uint256 amount1,\n address indexed to\n );\n\n event Swap(\n address indexed sender,\n uint256 amount0In,\n uint256 amount1In,\n uint256 amount0Out,\n uint256 amount1Out,\n address indexed to\n );\n\n event Sync(\n uint112 reserve0,\n uint112 reserve1\n );\n\n function initialize(\n address _token0,\n address _token1\n )\n external\n {\n require(\n factory == ZERO_ADDRESS,\n \"SwapsPair: ALREADY_INITIALIZED\"\n );\n\n token0 = _token0;\n token1 = _token1;\n factory = msg.sender;\n unlocked = 1;\n }\n\n function getReserves()\n public\n view\n returns (\n uint112,\n uint112,\n uint32\n )\n {\n return (\n reserve0,\n reserve1,\n blockTimestampLast\n );\n }\n\n function _update(\n uint256 _balance0,\n uint256 _balance1,\n uint112 _reserve0,\n uint112 _reserve1\n )\n private\n {\n require(\n _balance0 \u003c= UINT112_MAX \u0026\u0026\n _balance1 \u003c= UINT112_MAX,\n \"SwapsPair: OVERFLOW\"\n );\n\n uint32 blockTimestamp = uint32(block.timestamp % 2 ** 32);\n\n unchecked {\n uint32 timeElapsed = blockTimestamp - blockTimestampLast;\n if (timeElapsed \u003e 0 \u0026\u0026 _reserve0 != 0 \u0026\u0026 _reserve1 != 0) {\n price0CumulativeLast += uint256(uqdiv(encode(_reserve1), _reserve0)) * timeElapsed;\n price1CumulativeLast += uint256(uqdiv(encode(_reserve0), _reserve1)) * timeElapsed;\n }\n }\n\n reserve0 = uint112(_balance0);\n reserve1 = uint112(_balance1);\n\n blockTimestampLast = blockTimestamp;\n\n emit Sync(\n reserve0,\n reserve1\n );\n }\n\n function _mintFee(\n uint112 _reserve0,\n uint112 _reserve1,\n uint256 _kLast\n )\n private\n {\n if (_kLast == 0) return;\n\n uint256 rootK = sqrt(uint256(_reserve0) * _reserve1);\n uint256 rootKLast = sqrt(_kLast);\n\n if (rootK \u003e rootKLast) {\n\n uint256 liquidity = totalSupply\n * (rootK - rootKLast)\n / (rootK * 5 + rootKLast);\n\n if (liquidity == 0) return;\n\n _mint(\n ISwapsFactory(factory).feeTo(),\n liquidity\n );\n }\n }\n\n function mint(\n address _to\n )\n external\n lock\n returns (uint256 liquidity)\n {\n (\n uint112 _reserve0,\n uint112 _reserve1,\n\n ) = getReserves();\n\n uint256 balance0 = IERC20(token0).balanceOf(address(this));\n uint256 balance1 = IERC20(token1).balanceOf(address(this));\n\n uint256 amount0 = balance0 - _reserve0;\n uint256 amount1 = balance1 - _reserve1;\n\n _mintFee(\n _reserve0,\n _reserve1,\n kLast\n );\n\n uint256 _totalSupply = totalSupply;\n\n if (_totalSupply == 0) {\n\n liquidity = sqrt(\n amount0 * amount1\n ) - MINIMUM_LIQUIDITY;\n\n _mint(\n ZERO_ADDRESS,\n MINIMUM_LIQUIDITY\n );\n\n } else {\n\n liquidity = min(\n amount0 * _totalSupply / _reserve0,\n amount1 * _totalSupply / _reserve1\n );\n }\n\n require(\n liquidity \u003e 0,\n \"INSUFFICIENT_LIQUIDITY_MINTED\"\n );\n\n _mint(\n _to,\n liquidity\n );\n\n _update(\n balance0,\n balance1,\n _reserve0,\n _reserve1\n );\n\n kLast = uint256(reserve0) * reserve1;\n\n emit Mint(\n msg.sender,\n amount0,\n amount1\n );\n }\n\n function burn(\n address _to\n )\n external\n lock\n returns (\n uint256 amount0,\n uint256 amount1\n )\n {\n (\n uint112 _reserve0,\n uint112 _reserve1,\n\n ) = getReserves();\n\n address _token0 = token0;\n address _token1 = token1;\n\n uint256 balance0 = IERC20(_token0).balanceOf(address(this));\n uint256 balance1 = IERC20(_token1).balanceOf(address(this));\n\n uint256 liquidity = balanceOf[address(this)];\n\n _mintFee(\n _reserve0,\n _reserve1,\n kLast\n );\n\n uint256 _totalSupply = totalSupply;\n\n amount0 = liquidity * balance0 / _totalSupply;\n amount1 = liquidity * balance1 / _totalSupply;\n\n require(\n amount0 \u003e 0 \u0026\u0026\n amount1 \u003e 0,\n \"INSUFFICIENT_LIQUIDITY_BURNED\"\n );\n\n _burn(\n address(this),\n liquidity\n );\n\n _safeTransfer(\n _token0,\n _to,\n amount0\n );\n\n _safeTransfer(\n _token1,\n _to,\n amount1\n );\n\n balance0 = IERC20(_token0).balanceOf(address(this));\n balance1 = IERC20(_token1).balanceOf(address(this));\n\n _update(\n balance0,\n balance1,\n _reserve0,\n _reserve1\n );\n\n kLast = uint256(reserve0) * reserve1;\n\n emit Burn(\n msg.sender,\n amount0,\n amount1,\n _to\n );\n }\n\n function swap(\n uint256 _amount0Out,\n uint256 _amount1Out,\n address _to,\n bytes calldata _data\n )\n external\n lock\n {\n require(\n _amount0Out \u003e 0 ||\n _amount1Out \u003e 0,\n \"INSUFFICIENT_OUTPUT_AMOUNT\"\n );\n\n (\n uint112 _reserve0,\n uint112 _reserve1,\n\n ) = getReserves();\n\n require(\n _amount0Out \u003c _reserve0 \u0026\u0026\n _amount1Out \u003c _reserve1,\n \"INSUFFICIENT_LIQUIDITY\"\n );\n\n uint256 balance0;\n uint256 balance1;\n\n {\n address _token0 = token0;\n address _token1 = token1;\n\n if (_amount0Out \u003e 0) _safeTransfer(_token0, _to, _amount0Out);\n if (_amount1Out \u003e 0) _safeTransfer(_token1, _to, _amount1Out);\n\n if (_data.length \u003e 0) ISwapsCallee(_to).swapsCall(\n msg.sender,\n _amount0Out,\n _amount1Out,\n _data\n );\n\n balance0 = IERC20(_token0).balanceOf(address(this));\n balance1 = IERC20(_token1).balanceOf(address(this));\n }\n\n uint256 _amount0In =\n balance0 \u003e _reserve0 - _amount0Out ?\n balance0 - (_reserve0 - _amount0Out) : 0;\n\n uint256 _amount1In =\n balance1 \u003e _reserve1 - _amount1Out ?\n balance1 - (_reserve1 - _amount1Out) : 0;\n\n require(\n _amount0In \u003e 0 ||\n _amount1In \u003e 0,\n \"INSUFFICIENT_INPUT_AMOUNT\"\n );\n\n {\n uint256 balance0Adjusted = balance0 * 1000 - (_amount0In * 3);\n uint256 balance1Adjusted = balance1 * 1000 - (_amount1In * 3);\n\n require(\n balance0Adjusted * balance1Adjusted \u003e=\n uint256(_reserve0)\n * _reserve1\n * (1000 ** 2)\n );\n }\n\n _update(\n balance0,\n balance1,\n _reserve0,\n _reserve1\n );\n\n emit Swap(\n msg.sender,\n _amount0In,\n _amount1In,\n _amount0Out,\n _amount1Out,\n _to\n );\n }\n\n function skim()\n external\n lock\n {\n address _token0 = token0;\n address _token1 = token1;\n address _feesTo = ISwapsFactory(factory).feeTo();\n\n _safeTransfer(\n _token0,\n _feesTo,\n IERC20(_token0).balanceOf(address(this)) - reserve0\n );\n\n _safeTransfer(\n _token1,\n _feesTo,\n IERC20(_token1).balanceOf(address(this)) - reserve1\n );\n }\n\n function sync()\n external\n lock\n {\n _update(\n IERC20(token0).balanceOf(address(this)),\n IERC20(token1).balanceOf(address(this)),\n reserve0,\n reserve1\n );\n }\n\n function encode(\n uint112 _y\n )\n pure\n internal\n returns (uint224 z)\n {\n unchecked {\n z = uint224(_y) * Q112;\n }\n }\n\n function uqdiv(\n uint224 _x,\n uint112 _y\n )\n pure\n internal\n returns (uint224 z)\n {\n unchecked {\n z = _x / uint224(_y);\n }\n }\n\n function min(\n uint256 _x,\n uint256 _y\n )\n internal\n pure\n returns (uint256 z)\n {\n z = _x \u003c _y ? _x : _y;\n }\n\n function sqrt(\n uint256 _y\n )\n internal\n pure\n returns (uint256 z)\n {\n unchecked {\n if (_y \u003e 3) {\n z = _y;\n uint256 x = _y / 2 + 1;\n while (x \u003c z) {\n z = x;\n x = (_y / x + x) / 2;\n }\n } else if (_y != 0) {\n z = 1;\n }\n }\n }\n\n function _safeTransfer(\n address _token,\n address _to,\n uint256 _value\n )\n internal\n {\n (bool success, bytes memory data) = _token.call(\n abi.encodeWithSelector(\n SELECTOR,\n _to,\n _value\n )\n );\n\n require(\n success \u0026\u0026 (\n data.length == 0 || abi.decode(\n data, (bool)\n )\n ),\n \"SwapsPair: TRANSFER_FAILED\"\n );\n }\n}\n"}}File 3 of 4: VerseToken
{"MerkleProof.sol":{"content":"// SPDX-License-Identifier: --BCOM--\n\npragma solidity =0.8.17;\n\nlibrary MerkleProof {\n\n function verify(\n bytes32[] memory proof,\n bytes32 root,\n bytes32 leaf\n )\n internal\n pure\n returns (bool)\n {\n bytes32 computedHash = leaf;\n\n for (uint256 i = 0; i \u003c proof.length; i++) {\n\n bytes32 proofElement = proof[i];\n\n computedHash = computedHash \u003c= proofElement\n ? keccak256(abi.encodePacked(computedHash, proofElement))\n : keccak256(abi.encodePacked(proofElement, computedHash));\n }\n\n return computedHash == root;\n }\n}\n"},"VerseClaimer.sol":{"content":"// SPDX-License-Identifier: --BCOM--\n\npragma solidity =0.8.17;\n\nimport \"./MerkleProof.sol\";\nimport \"./VerseHelper.sol\";\n\ncontract VerseClaimer is VerseHelper {\n\n bytes32 public immutable merkleRoot;\n uint256 public immutable createTime;\n\n uint256 immutable minimumTimeFrame;\n\n struct KeeperInfo {\n uint256 keeperRate;\n uint256 keeperTill;\n uint256 keeperInstant;\n uint256 keeperPayouts;\n }\n\n mapping(address =\u003e KeeperInfo) public keeperList;\n\n constructor(\n bytes32 _merkleRoot,\n uint256 _minimumTimeFrame,\n address _verseTokenAddress\n )\n VerseHelper(_verseTokenAddress)\n {\n require(\n _minimumTimeFrame \u003e 0,\n \"VerseClaimer: INVALID_TIMEFRAME\"\n );\n\n require(\n _merkleRoot \u003e 0,\n \"VerseClaimer: INVALID_MERKLE_ROOT\"\n );\n\n createTime = getNow();\n merkleRoot = _merkleRoot;\n minimumTimeFrame = _minimumTimeFrame;\n }\n\n function enrollRecipient(\n uint256 _index,\n address _recipient,\n uint256 _tokensLocked,\n uint256 _tokensOpened,\n uint256 _timeFrame,\n bytes32[] calldata _merkleProof\n )\n external\n {\n _enrollRecipient(\n _index,\n _recipient,\n _tokensLocked,\n _tokensOpened,\n _timeFrame,\n _merkleProof\n );\n }\n\n function enrollRecipientBulk(\n uint256 _index,\n address[] calldata _recipient,\n uint256[] calldata _tokensLocked,\n uint256[] calldata _tokensOpened,\n uint256[] calldata _timeFrame,\n bytes32[][] calldata _merkleProof\n )\n external\n {\n require(\n _recipient.length \u003c 10,\n \"VerseClaimer: TOO_MANY\"\n );\n\n for (uint256 i = 0; i \u003c _recipient.length; i++) {\n _enrollRecipient(\n _index + i,\n _recipient[i],\n _tokensLocked[i],\n _tokensOpened[i],\n _timeFrame[i],\n _merkleProof[i]\n );\n }\n }\n\n function _enrollRecipient(\n uint256 _index,\n address _recipient,\n uint256 _tokensLocked,\n uint256 _tokensOpened,\n uint256 _timeFrame,\n bytes32[] memory _merkleProof\n )\n private\n {\n require(\n keeperList[_recipient].keeperTill == 0,\n \"VerseClaimer: RECIPIENT_ALREADY_ENROLLED\"\n );\n\n bytes32 node = keccak256(\n abi.encodePacked(\n _index,\n _recipient,\n _tokensLocked,\n _tokensOpened,\n _timeFrame\n )\n );\n\n require(\n MerkleProof.verify(\n _merkleProof,\n merkleRoot,\n node\n ),\n \"VerseClaimer: INVALID_PROOF\"\n );\n\n _allocateTokens(\n _recipient,\n _tokensLocked,\n _tokensOpened,\n _timeFrame\n );\n }\n\n function _allocateTokens(\n address _recipient,\n uint256 _tokensLocked,\n uint256 _tokensOpened,\n uint256 _timeFrame\n )\n private\n {\n require(\n _timeFrame \u003e= minimumTimeFrame,\n \"VerseClaimer: INVALID_TIME_FRAME\"\n );\n\n totalRequired = totalRequired\n + _tokensOpened\n + _tokensLocked;\n\n keeperList[_recipient].keeperTill = createTime\n + _timeFrame;\n\n keeperList[_recipient].keeperRate = _tokensLocked\n / _timeFrame;\n\n keeperList[_recipient].keeperInstant = _tokensLocked\n % _timeFrame\n + _tokensOpened;\n\n _checkVerseBalance(\n totalRequired\n );\n\n emit recipientEnrolled(\n _recipient,\n _timeFrame,\n _tokensLocked,\n _tokensOpened\n );\n }\n\n function enrollAndScrape(\n uint256 _index,\n uint256 _tokensLocked,\n uint256 _tokensOpened,\n uint256 _timeFrame,\n bytes32[] calldata _merkleProof\n )\n external\n {\n _enrollRecipient(\n _index,\n msg.sender,\n _tokensLocked,\n _tokensOpened,\n _timeFrame,\n _merkleProof\n );\n\n _scrapeTokens(\n msg.sender\n );\n }\n\n function scrapeMyTokens()\n external\n {\n _scrapeTokens(\n msg.sender\n );\n }\n\n function _scrapeTokens(\n address _recipient\n )\n private\n {\n uint256 scrapeAmount = availableBalance(\n _recipient\n );\n\n keeperList[_recipient].keeperPayouts += scrapeAmount;\n\n _safeVerseScrape(\n _recipient,\n scrapeAmount\n );\n\n emit tokensScraped(\n _recipient,\n scrapeAmount,\n getNow()\n );\n }\n\n function availableBalance(\n address _recipient\n )\n public\n view\n returns (uint256 balance)\n {\n uint256 timeNow = getNow();\n uint256 timeMax = keeperList[_recipient].keeperTill;\n\n if (timeMax == 0) return 0;\n\n uint256 timePassed = timeNow \u003e timeMax\n ? timeMax - createTime\n : timeNow - createTime;\n\n balance = keeperList[_recipient].keeperRate\n * timePassed\n + keeperList[_recipient].keeperInstant\n - keeperList[_recipient].keeperPayouts;\n }\n\n function lockedBalance(\n address _recipient\n )\n external\n view\n returns (uint256 balance)\n {\n uint256 timeNow = getNow();\n\n uint256 timeRemaining =\n keeperList[_recipient].keeperTill \u003e timeNow ?\n keeperList[_recipient].keeperTill - timeNow : 0;\n\n balance = keeperList[_recipient].keeperRate\n * timeRemaining;\n }\n}\n"},"VerseHelper.sol":{"content":"// SPDX-License-Identifier: --BCOM--\n\npragma solidity =0.8.17;\n\ncontract VerseHelper {\n\n uint256 public totalRequired;\n address public immutable verseToken;\n\n event recipientEnrolled(\n address indexed recipient,\n uint256 timeFrame,\n uint256 tokensLocked,\n uint256 tokensOpened\n );\n\n event tokensScraped(\n address indexed scraper,\n uint256 scrapedAmount,\n uint256 timestamp\n );\n\n constructor(\n address _verseTokenAddress\n ) {\n if (_verseTokenAddress == address(0x0)) {\n revert(\"VerseHelper: INVALID_VERSE_TOKEN\");\n }\n\n verseToken = _verseTokenAddress;\n }\n\n bytes4 private constant TRANSFER = bytes4(\n keccak256(\n bytes(\n \"transfer(address,uint256)\"\n )\n )\n );\n\n bytes4 private constant BALANCEOF = bytes4(\n keccak256(\n bytes(\n \"balanceOf(address)\"\n )\n )\n );\n\n function _safeVerseScrape(\n address _to,\n uint256 _scrapeAmount\n )\n internal\n {\n totalRequired -= _scrapeAmount;\n\n (bool success, bytes memory data) = verseToken.call(\n abi.encodeWithSelector(\n TRANSFER,\n _to,\n _scrapeAmount\n )\n );\n\n require(\n success \u0026\u0026 (\n abi.decode(\n data, (bool)\n )\n ),\n \"VerseHelper: TRANSFER_FAILED\"\n );\n }\n\n function _checkVerseBalance(\n uint256 _required\n )\n internal\n {\n (bool success, bytes memory data) = verseToken.call(\n abi.encodeWithSelector(\n BALANCEOF,\n address(this)\n )\n );\n\n require(\n success \u0026\u0026 abi.decode(\n data, (uint256)\n ) \u003e= _required,\n \"VerseHelper: BALANCE_CHECK_FAILED\"\n );\n }\n\n function getNow()\n public\n view\n returns (uint256 time)\n {\n time = block.timestamp;\n }\n}\n"},"VerseToken.sol":{"content":"// SPDX-License-Identifier: --BCOM--\n\npragma solidity =0.8.17;\n\nimport \"./VerseClaimer.sol\";\n\ncontract VerseToken {\n\n string public constant name = \"Verse\";\n string public constant symbol = \"VERSE\";\n uint8 public constant decimals = 18;\n\n VerseClaimer public immutable claimer;\n\n address constant ZERO_ADDRESS = address(0);\n uint256 constant UINT256_MAX = type(uint256).max;\n\n uint256 public totalSupply;\n\n mapping(address =\u003e uint256) public balanceOf;\n mapping(address =\u003e mapping(address =\u003e uint256)) public allowance;\n mapping(address =\u003e uint256) public nonces;\n\n bytes32 public immutable DOMAIN_SEPARATOR;\n bytes32 public constant PERMIT_TYPEHASH = keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n );\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n\n event Transfer(\n address indexed from,\n address indexed to,\n uint256 value\n );\n\n constructor(\n uint256 _initialSupply,\n uint256 _minimumTimeFrame,\n bytes32 _merkleRoot\n ) {\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(bytes(\"1\")),\n block.chainid,\n address(this)\n )\n );\n\n claimer = new VerseClaimer(\n _merkleRoot,\n _minimumTimeFrame,\n address(this)\n );\n\n _mint(\n address(claimer),\n _initialSupply\n );\n }\n\n function _mint(\n address _to,\n uint256 _value\n )\n internal\n {\n totalSupply =\n totalSupply + _value;\n\n unchecked {\n balanceOf[_to] =\n balanceOf[_to] + _value;\n }\n\n emit Transfer(\n ZERO_ADDRESS,\n _to,\n _value\n );\n }\n\n function burn(\n uint256 _value\n )\n external\n {\n _burn(\n msg.sender,\n _value\n );\n }\n\n function _burn(\n address _from,\n uint256 _value\n )\n internal\n {\n unchecked {\n totalSupply =\n totalSupply - _value;\n }\n\n balanceOf[_from] =\n balanceOf[_from] - _value;\n\n emit Transfer(\n _from,\n ZERO_ADDRESS,\n _value\n );\n }\n\n function _approve(\n address _owner,\n address _spender,\n uint256 _value\n )\n private\n {\n allowance[_owner][_spender] = _value;\n\n emit Approval(\n _owner,\n _spender,\n _value\n );\n }\n\n function _transfer(\n address _from,\n address _to,\n uint256 _value\n )\n private\n {\n balanceOf[_from] =\n balanceOf[_from] - _value;\n\n unchecked {\n balanceOf[_to] =\n balanceOf[_to] + _value;\n }\n\n emit Transfer(\n _from,\n _to,\n _value\n );\n }\n\n function approve(\n address _spender,\n uint256 _value\n )\n external\n returns (bool)\n {\n _approve(\n msg.sender,\n _spender,\n _value\n );\n\n return true;\n }\n\n function increaseAllowance(\n address _spender,\n uint256 _addedValue\n )\n external\n returns (bool)\n {\n _approve(\n msg.sender,\n _spender,\n allowance[msg.sender][_spender] + _addedValue\n );\n\n return true;\n }\n\n function decreaseAllowance(\n address _spender,\n uint256 _subtractedValue\n )\n external\n returns (bool)\n {\n _approve(\n msg.sender,\n _spender,\n allowance[msg.sender][_spender] - _subtractedValue\n );\n\n return true;\n }\n\n function transfer(\n address _to,\n uint256 _value\n )\n external\n returns (bool)\n {\n _transfer(\n msg.sender,\n _to,\n _value\n );\n\n return true;\n }\n\n function transferFrom(\n address _from,\n address _to,\n uint256 _value\n )\n external\n returns (bool)\n {\n if (allowance[_from][msg.sender] != UINT256_MAX) {\n allowance[_from][msg.sender] -= _value;\n }\n\n _transfer(\n _from,\n _to,\n _value\n );\n\n return true;\n }\n\n function permit(\n address _owner,\n address _spender,\n uint256 _value,\n uint256 _deadline,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\n external\n {\n require(\n _deadline \u003e= block.timestamp,\n \"VerseToken: PERMIT_CALL_EXPIRED\"\n );\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(\n abi.encode(\n PERMIT_TYPEHASH,\n _owner,\n _spender,\n _value,\n nonces[_owner]++,\n _deadline\n )\n )\n )\n );\n\n if (uint256(_s) \u003e 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n revert(\"VerseToken: INVALID_SIGNATURE\");\n }\n\n address recoveredAddress = ecrecover(\n digest,\n _v,\n _r,\n _s\n );\n\n require(\n recoveredAddress != ZERO_ADDRESS \u0026\u0026\n recoveredAddress == _owner,\n \"VerseToken: INVALID_SIGNATURE\"\n );\n\n _approve(\n _owner,\n _spender,\n _value\n );\n }\n}\n"}}File 4 of 4: WETH9
// Copyright (C) 2015, 2016, 2017 Dapphub
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.4.18;
contract WETH9 {
string public name = "Wrapped Ether";
string public symbol = "WETH";
uint8 public decimals = 18;
event Approval(address indexed src, address indexed guy, uint wad);
event Transfer(address indexed src, address indexed dst, uint wad);
event Deposit(address indexed dst, uint wad);
event Withdrawal(address indexed src, uint wad);
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
function() public payable {
deposit();
}
function deposit() public payable {
balanceOf[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
}
function withdraw(uint wad) public {
require(balanceOf[msg.sender] >= wad);
balanceOf[msg.sender] -= wad;
msg.sender.transfer(wad);
Withdrawal(msg.sender, wad);
}
function totalSupply() public view returns (uint) {
return this.balance;
}
function approve(address guy, uint wad) public returns (bool) {
allowance[msg.sender][guy] = wad;
Approval(msg.sender, guy, wad);
return true;
}
function transfer(address dst, uint wad) public returns (bool) {
return transferFrom(msg.sender, dst, wad);
}
function transferFrom(address src, address dst, uint wad)
public
returns (bool)
{
require(balanceOf[src] >= wad);
if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
require(allowance[src][msg.sender] >= wad);
allowance[src][msg.sender] -= wad;
}
balanceOf[src] -= wad;
balanceOf[dst] += wad;
Transfer(src, dst, wad);
return true;
}
}
/*
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
*/