Transaction Hash:
Block:
22684595 at Jun-11-2025 11:27:11 PM +UTC
Transaction Fee:
0.000469330362807889 ETH
$1.47
Gas Used:
335,477 Gas / 1.398994157 Gwei
Emitted Events:
659 |
WETH9.Deposit( dst=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, wad=154376838000000 )
|
660 |
WETH9.Approval( src=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, guy=Vault, wad=154376838000000 )
|
661 |
Vault.Swap( poolId=D4E2AF4507B6B89333441C0C398EDFFB40F86F4D0001000000000000000002AB, tokenIn=WETH9, tokenOut=WBTC, amountIn=154376838000000, amountOut=396 )
|
662 |
WETH9.Transfer( src=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, dst=Vault, wad=154376838000000 )
|
663 |
WBTC.Transfer( from=Vault, to=SwapsPair, value=396 )
|
664 |
FiatTokenProxy.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x000000000000000000000000f3f82bc165a83425e81b8f2858d786e41ab21671, 0x00000000000000000000000055877bd7f2ee37bde55ca4b271a3631f3a7ef121, 0000000000000000000000000000000000000000000000000000000000069466 )
|
665 |
SwapsPair.Sync( reserve0=2025333, reserve1=2211598632 )
|
666 |
SwapsPair.Swap( sender=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, amount0In=396, amount1In=0, amount0Out=0, amount1Out=431206, to=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121 )
|
667 |
FiatTokenProxy.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x00000000000000000000000055877bd7f2ee37bde55ca4b271a3631f3a7ef121, 0x00000000000000000000000084ab6c7cef654edbbfaf34033a0301ed5cf10658, 0000000000000000000000000000000000000000000000000000000000069466 )
|
668 |
OpenOceanExchangeProxy.0x76af224a143865a50b41496e1a73622698692c565c1214bc862f18e22d829c5e( 0x76af224a143865a50b41496e1a73622698692c565c1214bc862f18e22d829c5e, 0x00000000000000000000000084ab6c7cef654edbbfaf34033a0301ed5cf10658, 0x000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee, 0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 00000000000000000000000084ab6c7cef654edbbfaf34033a0301ed5cf10658, 00000000000000000000000000000000000000000000000000008dd2b9cf0200, 00000000000000000000000000000000000000000000000000008dd2b9cf0200, 0000000000000000000000000000000000000000000000000000000000069466, 00000000000000000000000000000000000000000000000000000000000661dd, 0000000000000000000000000000000000000000000000000000000000069466, 000000000000000000000000096daa643ba24e53b087af2ceed3a6ddeb56945b )
|
Account State Difference:
Address | Before | After | State Difference | ||
---|---|---|---|---|---|
0x096DAA64...dEb56945b | 0.728167047389283928 Eth | 0.728168372846983928 Eth | 0.0000013254577 | ||
0x2260FAC5...93bc2C599 | |||||
0x84AB6C7C...D5cf10658 |
0.00138757 Eth
Nonce: 0
|
0.000762303437192111 Eth
Nonce: 1
| 0.000625266562807889 | ||
0x922164BB...949fCAEef | 0.628366158345387393 Eth | 0.628366392249687393 Eth | 0.0000002339043 | ||
0x95222290...5CC4BAfe5
Miner
| (beaverbuild) | 17.657547233288175358 Eth | 17.657557425003617556 Eth | 0.000010191715442198 | |
0xA0b86991...E3606eB48 | |||||
0xBA122222...d566BF2C8 | (Balancer: Vault) | ||||
0xC02aaA39...83C756Cc2 | 2,608,697.487531394609132714 Eth | 2,608,697.487685771447132714 Eth | 0.000154376838 | ||
0xF3f82bC1...41ab21671 |
Execution Trace
ETH 0.0001559362
OpenOceanExchangeProxy.90411a32( )
ETH 0.0001559362
OpenOceanExchange.swap( caller=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, desc=[{name:srcToken, type:address, order:1, indexed:false, value:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE, valueString:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE}, {name:dstToken, type:address, order:2, indexed:false, value:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, valueString:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48}, {name:srcReceiver, type:address, order:3, indexed:false, value:0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, valueString:0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121}, {name:dstReceiver, type:address, order:4, indexed:false, value:0x84AB6C7CeF654EdbbFAF34033A0301ED5cf10658, valueString:0x84AB6C7CeF654EdbbFAF34033A0301ED5cf10658}, {name:amount, type:uint256, order:5, indexed:false, value:155936200000000, valueString:155936200000000}, {name:minReturnAmount, type:uint256, order:6, indexed:false, value:418269, valueString:418269}, {name:guaranteedAmount, type:uint256, order:7, indexed:false, value:431206, valueString:431206}, {name:flags, type:uint256, order:8, indexed:false, value:0, valueString:0}, {name:referrer, type:address, order:9, indexed:false, value:0x096DAA643bA24e53b087AF2ceeD3a6ddEb56945b, valueString:0x096DAA643bA24e53b087AF2ceeD3a6ddEb56945b}, {name:permit, type:bytes, order:10, indexed:false, value:0x, valueString:0x}], calls= ) => ( returnAmount=431206 )
FiatTokenProxy.70a08231( )
-
FiatTokenV2_2.balanceOf( account=0x84AB6C7CeF654EdbbFAF34033A0301ED5cf10658 ) => ( 0 )
-
ETH 0.0001559362
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.a8920d2b( )
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.0c7e1209( )
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.d1660f99( )
- ETH 0.0000002339043
0x922164bbbd36acf9e854acbbf32facc949fcaeef.CALL( )
- ETH 0.0000002339043
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.0c7e1209( )
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.d1660f99( )
- ETH 0.0000013254577
0x096daa643ba24e53b087af2ceed3a6ddeb56945b.CALL( )
- ETH 0.0000013254577
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.0c7e1209( )
- ETH 0.000154376838
WETH9.CALL( )
- ETH 0.000154376838
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.0c7e1209( )
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.eb5625d9( )
-
WETH9.allowance( 0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, 0xBA12222222228d8Ba445958a75a0704d566BF2C8 ) => ( 0 )
-
WETH9.allowance( 0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, 0xBA12222222228d8Ba445958a75a0704d566BF2C8 ) => ( 0 )
-
WETH9.approve( guy=0xBA12222222228d8Ba445958a75a0704d566BF2C8, wad=154376838000000 ) => ( True )
-
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.0c7e1209( )
Vault.swap( singleSwap=[{name:poolId, type:bytes32, order:1, indexed:false, value:D4E2AF4507B6B89333441C0C398EDFFB40F86F4D0001000000000000000002AB, valueString:D4E2AF4507B6B89333441C0C398EDFFB40F86F4D0001000000000000000002AB}, {name:kind, type:uint8, order:2, indexed:false, value:0, valueString:0}, {name:assetIn, type:address, order:3, indexed:false, value:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, valueString:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2}, {name:assetOut, type:address, order:4, indexed:false, value:0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599, valueString:0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599}, {name:amount, type:uint256, order:5, indexed:false, value:154376838000000, valueString:154376838000000}, {name:userData, type:bytes, order:6, indexed:false, value:0x, valueString:0x}], funds=[{name:sender, type:address, order:1, indexed:false, value:0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, valueString:0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121}, {name:fromInternalBalance, type:bool, order:2, indexed:false, value:false, valueString:False}, {name:recipient, type:address, order:3, indexed:false, value:0xF3f82bC165a83425e81b8f2858D786E41ab21671, valueString:0xF3f82bC165a83425e81b8f2858D786E41ab21671}, {name:toInternalBalance, type:bool, order:4, indexed:false, value:false, valueString:False}], limit=0, deadline=4294967295 ) => ( amountCalculated=396 )
-
WeightedPool.onSwap( request=[{name:kind, type:uint8, order:1, indexed:false, value:0, valueString:0}, {name:tokenIn, type:address, order:2, indexed:false, value:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, valueString:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2}, {name:tokenOut, type:address, order:3, indexed:false, value:0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599, valueString:0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599}, {name:amount, type:uint256, order:4, indexed:false, value:154376838000000, valueString:154376838000000}, {name:poolId, type:bytes32, order:5, indexed:false, value:D4E2AF4507B6B89333441C0C398EDFFB40F86F4D0001000000000000000002AB, valueString:D4E2AF4507B6B89333441C0C398EDFFB40F86F4D0001000000000000000002AB}, {name:lastChangeBlock, type:uint256, order:6, indexed:false, value:22684141, valueString:22684141}, {name:from, type:address, order:7, indexed:false, value:0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, valueString:0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121}, {name:to, type:address, order:8, indexed:false, value:0xF3f82bC165a83425e81b8f2858D786E41ab21671, valueString:0xF3f82bC165a83425e81b8f2858D786E41ab21671}, {name:userData, type:bytes, order:9, indexed:false, value:0x, valueString:0x}], balanceTokenIn=800379078350910159, balanceTokenOut=2064598 ) => ( 396 )
-
WETH9.transferFrom( src=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, dst=0xBA12222222228d8Ba445958a75a0704d566BF2C8, wad=154376838000000 ) => ( True )
-
WBTC.transfer( _to=0xF3f82bC165a83425e81b8f2858D786E41ab21671, _value=396 ) => ( True )
-
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.0c7e1209( )
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.cac460ee( )
SwapsPair.STATICCALL( )
-
SwapsPair.DELEGATECALL( )
-
-
WBTC.balanceOf( _owner=0xF3f82bC165a83425e81b8f2858D786E41ab21671 ) => ( 2025333 )
SwapsPair.swap( _amount0Out=0, _amount1Out=431206, _to=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, _data=0x )
-
SwapsPair.swap( _amount0Out=0, _amount1Out=431206, _to=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121, _data=0x )
-
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.0c7e1209( )
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.8a6a1e85( )
FiatTokenProxy.70a08231( )
-
FiatTokenV2_2.balanceOf( account=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121 ) => ( 431206 )
-
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.0c7e1209( )
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.9f865422( )
FiatTokenProxy.70a08231( )
-
FiatTokenV2_2.balanceOf( account=0x55877bD7F2EE37BDe55cA4B271A3631f3A7ef121 ) => ( 431206 )
-
0x55877bd7f2ee37bde55ca4b271a3631f3a7ef121.d1660f99( )
-
FiatTokenProxy.a9059cbb( )
-
FiatTokenProxy.70a08231( )
-
FiatTokenV2_2.balanceOf( account=0x84AB6C7CeF654EdbbFAF34033A0301ED5cf10658 ) => ( 431206 )
-
swap[OpenOceanExchange (ln:3689)]
isETH[OpenOceanExchange (ln:3701)]
isETH[OpenOceanExchange (ln:3704)]
_claim[OpenOceanExchange (ln:3705)]
_permit[OpenOceanExchange (ln:3750)]
safeTransferFrom[OpenOceanExchange (ln:3751)]
universalBalanceOf[OpenOceanExchange (ln:3709)]
universalBalanceOf[OpenOceanExchange (ln:3710)]
makeCalls[OpenOceanExchange (ln:3712)]
sub[OpenOceanExchange (ln:3715)]
universalBalanceOf[OpenOceanExchange (ln:3715)]
sub[OpenOceanExchange (ln:3718)]
add[OpenOceanExchange (ln:3718)]
universalBalanceOf[OpenOceanExchange (ln:3718)]
mul[OpenOceanExchange (ln:3719)]
mul[OpenOceanExchange (ln:3719)]
_emitSwapped[OpenOceanExchange (ln:3724)]
File 1 of 10: OpenOceanExchangeProxy
File 2 of 10: WETH9
File 3 of 10: Vault
File 4 of 10: SwapsPair
File 5 of 10: WBTC
File 6 of 10: FiatTokenProxy
File 7 of 10: OpenOceanExchange
File 8 of 10: FiatTokenV2_2
File 9 of 10: WeightedPool
File 10 of 10: SwapsPair
12345678910111213141516// File: @openzeppelin/contracts/proxy/Proxy.sol// SPDX-License-Identifier: MITpragma solidity >=0.6.0 <0.8.0;/*** @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to* be specified by overriding the virtual {_implementation} function.** Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a* different contract through the {_delegate} function.** The success and return data of the delegated call will be returned back to the caller of the proxy.*/
File 2 of 10: WETH9
12345678910111213141516// 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;
File 3 of 10: Vault
12345678910111213141516// SPDX-License-Identifier: GPL-3.0-or-later// 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.7.0;pragma experimental ABIEncoderV2;import "./interfaces/IAuthorizer.sol";import "./interfaces/IWETH.sol";import "./VaultAuthorization.sol";
File 4 of 10: SwapsPair
1{"IERC20.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ninterface IERC20 {\n\n function balanceOf(\naddress _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,\nuint256 _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,\naddress _tokenB\n )\n external\n view\n returns (address pair);\n\n function allPairs(uint256)\n external\nview\n returns (address pair);\n\n function allPairsLength()\n external\n view\n returns (uint256);\n\nfunction createPair(\n address _tokenA,\n address _tokenB\n )\n external\n returns (address pair);\n\n functionsetFeeTo(\n address\n )\n external;\n\n function setFeeToSetter(\n address\n )\n external;\n\n functioncloneTarget()\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 constantsymbol = \"VERSE-X\";\n uint8 public constant decimals = 18;\n\n address constant ZERO_ADDRESS = address(0);\n uint256 constantUINT256_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 immutableDOMAIN_SEPARATOR;\n bytes32 public constant PERMIT_TYPEHASH = keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256nonce,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() {\nDOMAIN_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 )\ninternal\n {\n totalSupply =\n totalSupply + _value;\n\n unchecked {\n balanceOf[_to] =\nbalanceOf[_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 {\ntotalSupply =\n totalSupply - _value;\n }\n\n balanceOf[_from] =\n balanceOf[_from] - _value;\n\n emitTransfer(\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 emitApproval(\n _owner,\n _spender,\n _value\n );\n }\n\n function _transfer(\n address _from,\naddress _to,\n uint256 _value\n )\n private\n {\n balanceOf[_from] =\n balanceOf[_from] - _value;\n\nunchecked {\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 )\nexternal\n returns (bool)\n {\n _approve(\n msg.sender,\n _spender,\n _value\n );\n\nreturn 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 functiontransferFrom(\n address _from,\n address _to,\n uint256 _value\n )\n external\n returns (bool)\n {\nif (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,\naddress _spender,\n uint256 _value,\n uint256 _deadline,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\nexternal\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,\nkeccak256(\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) \u003e0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n revert(\"SwapsERC20: INVALID_SIGNATURE\");\n }\n\naddress recoveredAddress = ecrecover(\n digest,\n _v,\n _r,\n _s\n );\n\n require(\nrecoveredAddress != 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 constantUINT112_MAX = type(uint112).max;\n uint256 public constant MINIMUM_LIQUIDITY = 10 ** 3;\n\n bytes4 private constant SELECTOR = bytes4(\nkeccak256(bytes(\u0027transfer(address,uint256)\u0027))\n );\n\n address public factory;\n address public token0;\n address publictoken1;\n\n uint112 private reserve0;\n uint112 private reserve1;\n uint32 private blockTimestampLast;\n\n uint256 publicprice0CumulativeLast;\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(\naddress indexed sender,\n uint256 amount0,\n uint256 amount1,\n address indexed to\n );\n\n event Swap(\naddress indexed sender,\n uint256 amount0In,\n uint256 amount1In,\n uint256 amount0Out,\n uint256 amount1Out,\naddress indexed to\n );\n\n event Sync(\n uint112 reserve0,\n uint112 reserve1\n );\n\n function initialize(\naddress _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;\nunlocked = 1;\n }\n\n function getReserves()\n public\n view\n returns (\n uint112,\n uint112,\nuint32\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 )\nprivate\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 {\nuint32 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);\nreserve1 = 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 )\nprivate\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\nlock\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(\nZERO_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 functionburn(\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\namount1 \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,\namount1,\n _to\n );\n }\n\n function swap(\n uint256 _amount0Out,\n uint256 _amount1Out,\naddress _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,\nuint112 _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,\nbalance1,\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()\nexternal\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\nfunction 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\nreturns (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\nfunction 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 5 of 10: WBTC
12345678910111213141516pragma solidity 0.4.24;// File: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol/*** @title ERC20Basic* @dev Simpler version of ERC20 interface* See https://github.com/ethereum/EIPs/issues/179*/contract ERC20Basic {function totalSupply() public view returns (uint256);function balanceOf(address _who) public view returns (uint256);function transfer(address _to, uint256 _value) public returns (bool);event Transfer(address indexed from, address indexed to, uint256 value);}
File 6 of 10: FiatTokenProxy
12345678910111213141516pragma solidity ^0.4.24;// File: zos-lib/contracts/upgradeability/Proxy.sol/*** @title Proxy* @dev Implements delegation of calls to other contracts, with proper* forwarding of return values and bubbling of failures.* It defines a fallback function that delegates all calls to the address* returned by the abstract _implementation() internal function.*/contract Proxy {/*** @dev Fallback function.* Implemented entirely in `_fallback`.*/
File 7 of 10: OpenOceanExchange
12345678910111213141516// File: @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)pragma solidity ^0.8.1;/*** @dev Collection of functions related to the address type*/library AddressUpgradeable {/*** @dev Returns true if `account` is a contract.** [IMPORTANT]* ====
File 8 of 10: FiatTokenV2_2
12345678910111213141516/*** SPDX-License-Identifier: Apache-2.0** Copyright (c) 2023, Circle Internet Financial, LLC.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.
File 9 of 10: WeightedPool
12345678910111213141516// SPDX-License-Identifier: GPL-3.0-or-later// 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.7.0;pragma experimental ABIEncoderV2;import "../../vault/interfaces/IVault.sol";import "../factories/BasePoolFactory.sol";import "../factories/FactoryWidePauseWindow.sol";
File 10 of 10: SwapsPair
1{"IERC20.sol":{"content":"// SPDX-License-Identifier: BCOM\n\npragma solidity =0.8.14;\n\ninterface IERC20 {\n\n function balanceOf(\naddress _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,\nuint256 _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,\naddress _tokenB\n )\n external\n view\n returns (address pair);\n\n function allPairs(uint256)\n external\nview\n returns (address pair);\n\n function allPairsLength()\n external\n view\n returns (uint256);\n\nfunction createPair(\n address _tokenA,\n address _tokenB\n )\n external\n returns (address pair);\n\n functionsetFeeTo(\n address\n )\n external;\n\n function setFeeToSetter(\n address\n )\n external;\n\n functioncloneTarget()\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 constantsymbol = \"VERSE-X\";\n uint8 public constant decimals = 18;\n\n address constant ZERO_ADDRESS = address(0);\n uint256 constantUINT256_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 immutableDOMAIN_SEPARATOR;\n bytes32 public constant PERMIT_TYPEHASH = keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256nonce,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() {\nDOMAIN_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 )\ninternal\n {\n totalSupply =\n totalSupply + _value;\n\n unchecked {\n balanceOf[_to] =\nbalanceOf[_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 {\ntotalSupply =\n totalSupply - _value;\n }\n\n balanceOf[_from] =\n balanceOf[_from] - _value;\n\n emitTransfer(\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 emitApproval(\n _owner,\n _spender,\n _value\n );\n }\n\n function _transfer(\n address _from,\naddress _to,\n uint256 _value\n )\n private\n {\n balanceOf[_from] =\n balanceOf[_from] - _value;\n\nunchecked {\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 )\nexternal\n returns (bool)\n {\n _approve(\n msg.sender,\n _spender,\n _value\n );\n\nreturn 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 functiontransferFrom(\n address _from,\n address _to,\n uint256 _value\n )\n external\n returns (bool)\n {\nif (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,\naddress _spender,\n uint256 _value,\n uint256 _deadline,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\nexternal\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,\nkeccak256(\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) \u003e0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n revert(\"SwapsERC20: INVALID_SIGNATURE\");\n }\n\naddress recoveredAddress = ecrecover(\n digest,\n _v,\n _r,\n _s\n );\n\n require(\nrecoveredAddress != 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 constantUINT112_MAX = type(uint112).max;\n uint256 public constant MINIMUM_LIQUIDITY = 10 ** 3;\n\n bytes4 private constant SELECTOR = bytes4(\nkeccak256(bytes(\u0027transfer(address,uint256)\u0027))\n );\n\n address public factory;\n address public token0;\n address publictoken1;\n\n uint112 private reserve0;\n uint112 private reserve1;\n uint32 private blockTimestampLast;\n\n uint256 publicprice0CumulativeLast;\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(\naddress indexed sender,\n uint256 amount0,\n uint256 amount1,\n address indexed to\n );\n\n event Swap(\naddress indexed sender,\n uint256 amount0In,\n uint256 amount1In,\n uint256 amount0Out,\n uint256 amount1Out,\naddress indexed to\n );\n\n event Sync(\n uint112 reserve0,\n uint112 reserve1\n );\n\n function initialize(\naddress _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;\nunlocked = 1;\n }\n\n function getReserves()\n public\n view\n returns (\n uint112,\n uint112,\nuint32\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 )\nprivate\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 {\nuint32 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);\nreserve1 = 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 )\nprivate\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\nlock\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(\nZERO_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 functionburn(\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\namount1 \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,\namount1,\n _to\n );\n }\n\n function swap(\n uint256 _amount0Out,\n uint256 _amount1Out,\naddress _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,\nuint112 _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,\nbalance1,\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()\nexternal\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\nfunction 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\nreturns (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\nfunction 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"}}