UNPKG

@valueswap/v2-periphery

Version:

🎚 Peripheral smart contracts for interacting with Valueswap V2

387 lines (386 loc) • 578 kB
{ "contractName": "ExampleFlashSwap", "abi": [ { "inputs": [ { "internalType": "address", "name": "_factory", "type": "address" }, { "internalType": "address", "name": "_factoryV1", "type": "address" }, { "internalType": "address", "name": "router", "type": "address" } ], "stateMutability": "nonpayable", "type": "constructor" }, { "stateMutability": "payable", "type": "receive" }, { "inputs": [ { "internalType": "address", "name": "sender", "type": "address" }, { "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "internalType": "uint256", "name": "amount1", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" } ], "name": "valueswapV2Call", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_factory\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_factoryV1\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"router\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount1\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"valueswapV2Call\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/examples/ExampleFlashSwap.sol\":\"ExampleFlashSwap\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/examples/ExampleFlashSwap.sol\":{\"keccak256\":\"0x2624b41a44e62b12d214a591fb11f9bd07ed2d3cf2aa9a128c081dbd98dbe1d6\",\"urls\":[\"bzz-raw://470c8cf2903b9c9b5d86a72bbc5318d38ea20d530be467ca383889d05ec68ac2\",\"dweb:/ipfs/QmeM2TK7pt2ncPpk9c9GrJQAgkW6zSFcQ67umtqLenDpMn\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/IERC20.sol\":{\"keccak256\":\"0x61db17aebc5d812c7002d15c1da954065e56abe49d64b14c034abe5604d70eb3\",\"urls\":[\"bzz-raw://b006685e753f9120469f10b09c159f222d4cb8b507a6c1f0c14ed50c883ebe66\",\"dweb:/ipfs/QmSyY7iTugbczPwfGK67etiyPULenYGzzRYbt8aabwwkUb\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/IValueswapV2Router01.sol\":{\"keccak256\":\"0x36353f46a62274a8eba493ea0bed9284da4f97e30025def7688d84de95552826\",\"urls\":[\"bzz-raw://e258df9bf935cb183c593417f96967ffcb32e438d834a6840cc8c51ab61dfce8\",\"dweb:/ipfs/QmWqucAgec2mSqtMzMDFSaJWQFUByvw1L6oodDZEwYm5vk\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/IWETH.sol\":{\"keccak256\":\"0xfc10758fd8dba790c39468dccd358cb7cef06ae7c4781832cc7aa76f91f167e6\",\"urls\":[\"bzz-raw://dc22493dea6c60d47835eeba53726f8a6f76f4fcd798d40e54608a1380515d49\",\"dweb:/ipfs/QmS1QVcBRH4TELYNE7XCfjSVQEWFupyaNLKmMkKH7iPjrm\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/V1/IValueswapV1Exchange.sol\":{\"keccak256\":\"0x18347987e5ec9f2db6d046221e16425bbbd2b615f7d857e581eaa3c4622a299e\",\"urls\":[\"bzz-raw://152e46b593cc84f238a26ac798a240a104f83473db87528a1dd90f4624dd70b9\",\"dweb:/ipfs/QmVCrpGsk4cmvLBN56tdcdtaZojFFkwsNrKWw9oZSjRkAT\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/V1/IValueswapV1Factory.sol\":{\"keccak256\":\"0x97cf41f192263151cb96dc3c80d52b155ab550df4814fa66fe7fef808fd2ffab\",\"urls\":[\"bzz-raw://1d67f84c9bcb570a8aaaeb2108a81a454b4516bc67fabfec93f701db30eed84e\",\"dweb:/ipfs/QmYHtYT7E3ftKLdQbCciwjgSipYxt4sr8VVhPyDmLZfC1g\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/SafeMath.sol\":{\"keccak256\":\"0x27f0ea82f879b3b01387b583e6d9d0ec858dca3b22b0aad173f8fbda06e761e1\",\"urls\":[\"bzz-raw://0db9cf37793eb7035f0bfced36323d240f0212150009c39a3a108701d9b50b6c\",\"dweb:/ipfs/QmUAdiG9XNcieXkKfiMB49zQqD34FbXFE15csV2KQzwEqg\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2Library.sol\":{\"keccak256\":\"0xf676dcf67bcef334c141c95ae2c8328c76bcaf316edd882fe9bf960dc7887904\",\"urls\":[\"bzz-raw://37aa805cf7db173d7465a186acb5d9a958c8d1628c2335807c054e7864501dc5\",\"dweb:/ipfs/QmbZhcmRJkPLzsfMoNbeRZ8UKrqsjF86QNiZjsYyfxg9t6\"]},\"@valueswap/v2-core/contracts/interfaces/IValueswapV2Callee.sol\":{\"keccak256\":\"0x6ae31ab548230a0da52d5478beb1759507c55d9be5bbb3393dd84f769c796781\",\"urls\":[\"bzz-raw://f94793e529f221f55f6eb94ea18c28a7dc4c393c16a036efbe292eb83fd00d89\",\"dweb:/ipfs/QmbbBRZV73opEXQHrW8txVHNCXCrXM2f6eLnB6qTGGXKFi\"]},\"@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol\":{\"keccak256\":\"0x4899f60670cbc336cd8f5fefb631d6ce27ae4226ad4aac5d0963cd23db2fc36a\",\"urls\":[\"bzz-raw://7aa68c3572d1a4713c4af9ba99dd1907a9dc5a104273dab86e1d02797f6b1dd6\",\"dweb:/ipfs/QmXq89Vb6D4XeA2PDqNy13VkNeevTJePCrLF7KUHkver4q\"]}},\"version\":1}", "bytecode": "0x60e060405234801561001057600080fd5b5060405161162e38038061162e8339818101604052606081101561003357600080fd5b5080516020808301516040938401516001600160601b0319606083811b821660805285901b1660a05284516315ab88c960e31b815294519394919390926001600160a01b0384169263ad5c46489260048083019392829003018186803b15801561009c57600080fd5b505afa1580156100b0573d6000803e3d6000fd5b505050506040513d60208110156100c657600080fd5b50516001600160601b031960609190911b1660c05250505060805160601c60a05160601c60c05160601c6114ee610140600039806102e15280610316528061037552806103de528061044a528061078b52806108545280610a215250806101f652806107445280610b345250806104e552506114ee6000f3fe6080604052600436106100225760003560e01c8063f2e82feb1461002e57610029565b3661002957005b600080fd5b34801561003a57600080fd5b506100d46004803603608081101561005157600080fd5b73ffffffffffffffffffffffffffffffffffffffff823516916020810135916040820135919081019060808101606082013564010000000081111561009557600080fd5b8201836020820111156100a757600080fd5b803590602001918460018302840111640100000000831117156100c957600080fd5b5090925090506100d6565b005b604080516002808252606080830184529260208301908036833701905050905060008060003373ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561014157600080fd5b505afa158015610155573d6000803e3d6000fd5b505050506040513d602081101561016b57600080fd5b5051604080517fd21220a70000000000000000000000000000000000000000000000000000000081529051919250600091339163d21220a7916004808301926020929190829003018186803b1580156101c357600080fd5b505afa1580156101d7573d6000803e3d6000fd5b505050506040513d60208110156101ed57600080fd5b5051905061021c7f00000000000000000000000000000000000000000000000000000000000000008383610cdc565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461025057fe5b88158061025b575087155b61026157fe5b881561026d578061026f565b815b8560008151811061027c57fe5b73ffffffffffffffffffffffffffffffffffffffff9092166020928302919091019091015288156102ad57816102af565b805b856001815181106102bc57fe5b73ffffffffffffffffffffffffffffffffffffffff92831660209182029290920101527f00000000000000000000000000000000000000000000000000000000000000008116908316146103105788610312565b875b93507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161461036d578761036f565b885b925050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836000815181106103b757fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16148061044057507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168360018151811061042057fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16145b61044657fe5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168460008151811061048c57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16146104c957836000815181106104bc57fe5b60200260200101516104df565b836001815181106104d657fe5b60200260200101515b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166306f2bf62836040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561058057600080fd5b505afa158015610594573d6000803e3d6000fd5b505050506040513d60208110156105aa57600080fd5b5051905083156109c3576000878760208110156105c657600080fd5b50604080517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018990529151923593509085169163095ea7b3916044808201926020929091908290030181600087803b15801561064457600080fd5b505af1158015610658573d6000803e3d6000fd5b505050506040513d602081101561066e57600080fd5b5050604080517f95e3c50b00000000000000000000000000000000000000000000000000000000815260048101879052602481018390527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6044820152905160009173ffffffffffffffffffffffffffffffffffffffff8516916395e3c50b9160648082019260209290919082900301818787803b15801561070f57600080fd5b505af1158015610723573d6000803e3d6000fd5b505050506040513d602081101561073957600080fd5b50519050600061076a7f0000000000000000000000000000000000000000000000000000000000000000888a610dc7565b60008151811061077657fe5b6020026020010151905080821161078957fe5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156107f157600080fd5b505af1158015610805573d6000803e3d6000fd5b5050604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101869052905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016945063a9059cbb9350604480830193506020928290030181600087803b15801561089d57600080fd5b505af11580156108b1573d6000803e3d6000fd5b505050506040513d60208110156108c757600080fd5b50516108cf57fe5b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff8f1690838503906040518082805190602001908083835b6020831061094857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161090b565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146109aa576040519150601f19603f3d011682016040523d82523d6000602084013e6109af565b606091505b50509050806109ba57fe5b50505050610cd0565b6000878760208110156109d557600080fd5b50604080517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526004810187905290519135925073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001691632e1a7d4d9160248082019260009290919082900301818387803b158015610a6957600080fd5b505af1158015610a7d573d6000803e3d6000fd5b5050505060008273ffffffffffffffffffffffffffffffffffffffff1663f39b5b9b86847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518463ffffffff1660e01b815260040180838152602001828152602001925050506020604051808303818588803b158015610afe57600080fd5b505af1158015610b12573d6000803e3d6000fd5b50505050506040513d6020811015610b2957600080fd5b505190506000610b5a7f0000000000000000000000000000000000000000000000000000000000000000878a610dc7565b600081518110610b6657fe5b60200260200101519050808211610b7957fe5b604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101839052905173ffffffffffffffffffffffffffffffffffffffff87169163a9059cbb9160448083019260209291908290030181600087803b158015610bee57600080fd5b505af1158015610c02573d6000803e3d6000fd5b505050506040513d6020811015610c1857600080fd5b5051610c2057fe5b604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8f81166004830152838503602483015291519187169163a9059cbb916044808201926020929091908290030181600087803b158015610c9a57600080fd5b505af1158015610cae573d6000803e3d6000fd5b505050506040513d6020811015610cc457600080fd5b5051610ccc57fe5b5050505b50505050505050505050565b6000806000610ceb8585610f6a565b604080517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501207fff0000000000000000000000000000000000000000000000000000000000000060688401529a90941b9093166069840152607d8301989098527ff27fee3fc000c2148077e3c1de2bfc88ca0e8881a5c9fbb18615dc16f0cc1b75609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b6060600282511015610e3a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f56616c75657377617056324c6962726172793a20494e56414c49445f50415448604482015290519081900360640190fd5b815167ffffffffffffffff81118015610e5257600080fd5b50604051908082528060200260200182016040528015610e7c578160200160208202803683370190505b5090508281600183510381518110610e9057fe5b602090810291909101015281517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff015b8015610f6257600080610efd87866001860381518110610edc57fe5b6020026020010151878681518110610ef057fe5b60200260200101516110bd565b91509150610f1f848481518110610f1057fe5b602002602001015183836111a5565b846001850381518110610f2e57fe5b602090810291909101015250507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01610ec0565b509392505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610ff2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806114686027913960400191505060405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161061102c57828461102f565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff82166110b657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f56616c75657377617056324c6962726172793a205a45524f5f41444452455353604482015290519081900360640190fd5b9250929050565b60008060006110cc8585610f6a565b5090506000806110dd888888610cdc565b73ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561112257600080fd5b505afa158015611136573d6000803e3d6000fd5b505050506040513d606081101561114c57600080fd5b5080516020909101516dffffffffffffffffffffffffffff918216935016905073ffffffffffffffffffffffffffffffffffffffff87811690841614611193578082611196565b81815b90999098509650505050505050565b60008084116111ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061143a602e913960400191505060405180910390fd5b60008311801561120f5750600082115b611264576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061148f602a913960400191505060405180910390fd5b60006112886103e861127c868863ffffffff6112c916565b9063ffffffff6112c916565b905060006112a26103e561127c868963ffffffff61135516565b90506112bf60018284816112b257fe5b049063ffffffff6113c716565b9695505050505050565b60008115806112e4575050808202828282816112e157fe5b04145b61134f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b92915050565b8082038281111561134f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b8082018281101561134f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe56616c75657377617056324c6962726172793a20494e53554646494349454e545f4f55545055545f414d4f554e5456616c75657377617056324c6962726172793a204944454e544943414c5f41444452455353455356616c75657377617056324c6962726172793a20494e53554646494349454e545f4c4951554944495459a2646970667358221220a2d36e6d3ce3220cebd3c549ac6fa5f9c4dc1c9f1d8e6144a382ff2456efde8864736f6c63430006060033", "deployedBytecode": "0x6080604052600436106100225760003560e01c8063f2e82feb1461002e57610029565b3661002957005b600080fd5b34801561003a57600080fd5b506100d46004803603608081101561005157600080fd5b73ffffffffffffffffffffffffffffffffffffffff823516916020810135916040820135919081019060808101606082013564010000000081111561009557600080fd5b8201836020820111156100a757600080fd5b803590602001918460018302840111640100000000831117156100c957600080fd5b5090925090506100d6565b005b604080516002808252606080830184529260208301908036833701905050905060008060003373ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561014157600080fd5b505afa158015610155573d6000803e3d6000fd5b505050506040513d602081101561016b57600080fd5b5051604080517fd21220a70000000000000000000000000000000000000000000000000000000081529051919250600091339163d21220a7916004808301926020929190829003018186803b1580156101c357600080fd5b505afa1580156101d7573d6000803e3d6000fd5b505050506040513d60208110156101ed57600080fd5b5051905061021c7f00000000000000000000000000000000000000000000000000000000000000008383610cdc565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461025057fe5b88158061025b575087155b61026157fe5b881561026d578061026f565b815b8560008151811061027c57fe5b73ffffffffffffffffffffffffffffffffffffffff9092166020928302919091019091015288156102ad57816102af565b805b856001815181106102bc57fe5b73ffffffffffffffffffffffffffffffffffffffff92831660209182029290920101527f00000000000000000000000000000000000000000000000000000000000000008116908316146103105788610312565b875b93507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161461036d578761036f565b885b925050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836000815181106103b757fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16148061044057507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168360018151811061042057fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16145b61044657fe5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168460008151811061048c57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16146104c957836000815181106104bc57fe5b60200260200101516104df565b836001815181106104d657fe5b60200260200101515b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166306f2bf62836040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561058057600080fd5b505afa158015610594573d6000803e3d6000fd5b505050506040513d60208110156105aa57600080fd5b5051905083156109c3576000878760208110156105c657600080fd5b50604080517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018990529151923593509085169163095ea7b3916044808201926020929091908290030181600087803b15801561064457600080fd5b505af1158015610658573d6000803e3d6000fd5b505050506040513d602081101561066e57600080fd5b5050604080517f95e3c50b00000000000000000000000000000000000000000000000000000000815260048101879052602481018390527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6044820152905160009173ffffffffffffffffffffffffffffffffffffffff8516916395e3c50b9160648082019260209290919082900301818787803b15801561070f57600080fd5b505af1158015610723573d6000803e3d6000fd5b505050506040513d602081101561073957600080fd5b50519050600061076a7f0000000000000000000000000000000000000000000000000000000000000000888a610dc7565b60008151811061077657fe5b6020026020010151905080821161078957fe5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156107f157600080fd5b505af1158015610805573d6000803e3d6000fd5b5050604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101869052905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016945063a9059cbb9350604480830193506020928290030181600087803b15801561089d57600080fd5b505af11580156108b1573d6000803e3d6000fd5b505050506040513d60208110156108c757600080fd5b50516108cf57fe5b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff8f1690838503906040518082805190602001908083835b6020831061094857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161090b565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146109aa576040519150601f19603f3d011682016040523d82523d6000602084013e6109af565b606091505b50509050806109ba57fe5b50505050610cd0565b6000878760208110156109d557600080fd5b50604080517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526004810187905290519135925073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001691632e1a7d4d9160248082019260009290919082900301818387803b158015610a6957600080fd5b505af1158015610a7d573d6000803e3d6000fd5b5050505060008273ffffffffffffffffffffffffffffffffffffffff1663f39b5b9b86847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518463ffffffff1660e01b815260040180838152602001828152602001925050506020604051808303818588803b158015610afe57600080fd5b505af1158015610b12573d6000803e3d6000fd5b50505050506040513d6020811015610b2957600080fd5b505190506000610b5a7f0000000000000000000000000000000000000000000000000000000000000000878a610dc7565b600081518110610b6657fe5b60200260200101519050808211610b7957fe5b604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101839052905173ffffffffffffffffffffffffffffffffffffffff87169163a9059cbb9160448083019260209291908290030181600087803b158015610bee57600080fd5b505af1158015610c02573d6000803e3d6000fd5b505050506040513d6020811015610c1857600080fd5b5051610c2057fe5b604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8f81166004830152838503602483015291519187169163a9059cbb916044808201926020929091908290030181600087803b158015610c9a57600080fd5b505af1158015610cae573d6000803e3d6000fd5b505050506040513d6020811015610cc457600080fd5b5051610ccc57fe5b5050505b50505050505050505050565b6000806000610ceb8585610f6a565b604080517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501207fff0000000000000000000000000000000000000000000000000000000000000060688401529a90941b9093166069840152607d8301989098527ff27fee3fc000c2148077e3c1de2bfc88ca0e8881a5c9fbb18615dc16f0cc1b75609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b6060600282511015610e3a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f56616c75657377617056324c6962726172793a20494e56414c49445f50415448604482015290519081900360640190fd5b815167ffffffffffffffff81118015610e5257600080fd5b50604051908082528060200260200182016040528015610e7c578160200160208202803683370190505b5090508281600183510381518110610e9057fe5b602090810291909101015281517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff015b8015610f6257600080610efd87866001860381518110610edc57fe5b6020026020010151878681518110610ef057fe5b60200260200101516110bd565b91509150610f1f848481518110610f1057fe5b602002602001015183836111a5565b846001850381518110610f2e57fe5b602090810291909101015250507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01610ec0565b509392505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610ff2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806114686027913960400191505060405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161061102c57828461102f565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff82166110b657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f56616c75657377617056324c6962726172793a205a45524f5f41444452455353604482015290519081900360640190fd5b9250929050565b60008060006110cc8585610f6a565b5090506000806110dd888888610cdc565b73ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561112257600080fd5b505afa158015611136573d6000803e3d6000fd5b505050506040513d606081101561114c57600080fd5b5080516020909101516dffffffffffffffffffffffffffff918216935016905073ffffffffffffffffffffffffffffffffffffffff87811690841614611193578082611196565b81815b90999098509650505050505050565b60008084116111ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061143a602e913960400191505060405180910390fd5b60008311801561120f5750600082115b611264576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061148f602a913960400191505060405180910390fd5b60006112886103e861127c868863ffffffff6112c916565b9063ffffffff6112c916565b905060006112a26103e561127c868963ffffffff61135516565b90506112bf60018284816112b257fe5b049063ffffffff6113c716565b9695505050505050565b60008115806112e4575050808202828282816112e157fe5b04145b61134f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b92915050565b8082038281111561134f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b8082018281101561134f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe56616c75657377617056324c6962726172793a20494e53554646494349454e545f4f55545055545f414d4f554e5456616c75657377617056324c6962726172793a204944454e544943414c5f41444452455353455356616c75657377617056324c6962726172793a20494e53554646494349454e545f4c4951554944495459a2646970667358221220a2d36e6d3ce3220cebd3c549ac6fa5f9c4dc1c9f1d8e6144a382ff2456efde8864736f6c63430006060033", "immutableReferences": { "3711": [ { "length": 32, "start": 1253 } ], "3713": [ { "length": 32, "start": 502 }, { "length": 32, "start": 1860 }, { "length": 32, "start": 2868 } ], "3715": [ { "length": 32, "start": 737 }, { "length": 32, "start": 790 }, { "length": 32, "start": 885 }, { "length": 32, "start": 990 }, { "length": 32, "start": 1098 }, { "length": 32, "start": 1931 }, { "length": 32, "start": 2132 }, { "length": 32, "start": 2593 } ] }, "sourceMap": "367:3405:4:-:0;;;524:220;5:9:-1;2:2;;;27:1;24;17:12;2:2;524:220:4;;;;;;;;;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;524:220:4;;;;;;;;;;;;-1:-1:-1;;;;;;524:220:4;607:43;;;;;;;660:18;;;;;;701:35;;-1:-1:-1;;;701:35:4;;;;524:220;;;;;;-1:-1:-1;;;;;701:33:4;;;;;:35;;;;;524:220;701:35;;;;;:33;:35;;;2:2:-1;;;;27:1;24;17:12;2:2;701:35:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;701:35:4;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;701:35:4;-1:-1:-1;;;;;;688:49:4;;;;;;;;-1:-1:-1;;;367:3405:4;;;;;;;;;;;;;;;;;;;;;", "deployedSourceMap": "367:3405:4:-:0;;;;;;;;;;;;;;;;;;;;;;;;;12:1:-1;9;2:12;1101:2669:4;;5:9:-1;2:2;;;27:1;24;17:12;2:2;1101:2669:4;;;;;;15:3:-1;10;7:12;4:2;;;32:1;29;22:12;4:2;1101:2669:4;;;;;;;;;;;;;;;;;;;;;;;;;;27:11:-1;11:28;;8:2;;;52:1;49;42:12;8:2;1101:2669:4;;41:9:-1;34:4;18:14;14:25;11:40;8:2;;;64:1;61;54:12;8:2;1101:2669:4;;;;;;100:9:-1;95:1;81:12;77:20;67:8;63:35;60:50;39:11;25:12;22:29;11:107;8:2;;;131:1;128;121:12;8:2;-1:-1;1101:2669:4;;-1:-1:-1;1101:2669:4;-1:-1:-1;1101:2669:4;:::i;:::-;;;1243:16;;;1257:1;1243:16;;;1219:21;1243:16;;;;;1219:21;1243:16;;;;;109:14:-1;1243:16:4;88:42:-1;144:17;;-1:-1;1243:16:4;1219:40;;1269:16;1295:14;1383;1417:10;1400:35;;;:37;;;;;;;;;;;;;;;;;;;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;1400:37:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1400:37:4;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1400:37:4;1464;;;;;;;;1400;;-1:-1:-1;1447:14:4;;1481:10;;1464:35;;:37;;;;;1400;;1464;;;;;;;1481:10;1464:37;;;2:2:-1;;;;27:1;24;17:12;2:2;1464:37:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1464:37:4;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1464:37:4;;-1:-1:-1;1532:51:4;1559:7;1568:6;1464:37;1532:26;:51::i;:::-;1518:65;;:10;:65;;;1511:73;;;;1649:12;;;:28;;-1:-1:-1;1665:12:4;;1649:28;1642:36;;;;1733:12;;:30;;1757:6;1733:30;;;1748:6;1733:30;1723:4;1728:1;1723:7;;;;;;;;:40;;;;:7;;;;;;;;;;;:40;1783:12;;:30;;1807:6;1783:30;;;1798:6;1783:30;1773:4;1778:1;1773:7;;;;;;;;:40;;;;:7;;;;;;;;;:40;1855:4;1837:23;;;;;;:43;;1873:7;1837:43;;;1863:7;1837:43;1823:57;;1920:4;1902:23;;:6;:23;;;:43;;1938:7;1902:43;;;1928:7;1902:43;1890:55;;1101:2669;;1992:4;1973:24;;:4;1978:1;1973:7;;;;;;;;;;;;;;:24;;;:52;;;;2020:4;2001:24;;:4;2006:1;2001:7;;;;;;;;;;;;;;:24;;;1973:52;1966:60;;;;2084:12;2125:4;2106:24;;:4;2111:1;2106:7;;;;;;;;;;;;;;:24;;;:44;;2143:4;2148:1;2143:7;;;;;;;;;;;;;;2106:44;;;2133:4;2138:1;2133:7;;;;;;;;;;;;;;2106:44;2084:67;;2161:31;2216:9;:21;;;2246:5;2216:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;2216:37:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2216:37:4;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;2216:37:4;;-1:-1:-1;2288:15:4;;2284:1480;;2320:11;2346:4;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;2423:47:4;;;;;;:13;:47;;;;;;;;;;;;;;;2335:24;;;-1:-1:-1;2423:13:4;;;;;;:47;;;;;2335:24;;2423:47;;;;;;;;-1:-1:-1;2423:13:4;:47;;;2:2:-1;;;;27:1;24;17:12;2:2;2423:47:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2423:47:4;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;;2506:61:4;;;;;;;;;;;;;;;;;;2563:2;2506:61;;;;;;2484:19;;2506:30;;;;;;:61;;;;;2423:47;;2506:61;;;;;;;;2484:19;2506:30;:61;;;2:2:-1;;;;27:1;24;17:12;2:2;2506:61:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2506:61:4;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;2506:61:4;;-1:-1:-1;2581:19:4;2603:59;2635:7;2644:11;2657:4;2603:31;:59::i;:::-;2663:1;2603:62;;;;;;;;;;;;;;2581:84;;2703:14;2686;:31;2679:39;;;;2797:4;:12;;;2817:14;2797:37;;;;;;;;;;;;;;;;;;;;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;2797:37:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;-1:-1;;2855:41:4;;;;;;2869:10;2855:41;;;;;;;;;;;;:13;:4;:13;;-1:-1:-1;2855:13:4;;-1:-1:-1;2855:41:4;;;;;-1:-1:-1;2855:41:4;;;;;;;-1:-1:-1;2855:13:4;:41;;;2:2:-1;;;;27:1;24;17:12;2:2;2855:41:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2855:41:4;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;2855:41:4;2848:49;;;;3007:12;;;2938;3007;;;;;;;;;2955:11;;;;2974:31;;;;2955:65;;;;;;;;;;;;;36:153:-1;66:2;61:3;58:11;36:153;;176:10;;164:23;;139:12;;;;;98:2;89:12;;;;114;36:153;;;274:1;267:3;263:2;259:12;254:3;250:22;246:30;315:4;311:9;305:3;299:10;295:26;356:4;350:3;344:10;340:21;389:7;380;377:20;372:3;365:33;3:399;;;2955:65:4;;;;;;;;;;;;;;;;;;;;;;;;;12:1:-1;19;14:27;;;;67:4;61:11;56:16;;134:4;130:9;123:4;105:16;101:27;97:43;94:1;90:51;84:4;77:65;157:16;154:1;147:27;211:16;208:1;201:4;198:1;194:12;179:49;5:228;;14:27;32:4;27:9;;5:228;;2937:83:4;;;3065:7;3058:15;;;;2284:1480;;;;;;;3105:14;3134:4;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;3211:24:4;;;;;;;;;;;;;;3123;;;-1:-1:-1;3211:13:4;:4;:13;;;;:24;;;;;-1:-1:-1;;3211:24:4;;;;;;;;-1:-1:-1;3211:13:4;:24;;;2:2:-1;;;;27:1;24;17:12;2:2;3211:24:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3211:24:4;;;;3249:19;3271:10;:30;;;3309:9;3320;3336:2;3271:69;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;3271:69:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3271:69:4;;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;3271:69:4;;-1:-1:-1;3354:19:4;3376:57;3408:7;3417:9;3428:4;3376:31;:57::i;:::-;3434:1;3376:60;;;;;;;;;;;;;;3354:82;;3474:14;3457;:31;3450:39;;;;3578:42;;;;;;3593:10;3578:42;;;;;;;;;;;;:14;;;;;;:42;;;;;;;;;;;;;;-1:-1:-1;3578:14:4;:42;;;2:2:-1;;;;27:1;24;17:12;2:2;3578:42:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3578:42:4;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;3578:42:4;3571:50;;;;3670:55;;;;;;:14;:55;;;;;;;3693:31;;;3670:55;;;;;;:14;;;;;;:55;;;;;;;;;;;;;;;-1:-1:-1;3670:14:4;:55;;;2:2:-1;;;;27:1;24;17:12;2:2;3670:55:4;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3670:55:4;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;3670:55:4;3663:63;;;;2284:1480;;;;1101:2669;;;;;;;;;;:::o;725:470:16:-;814:12;839:14;855;873:26;884:6;892;873:10;:26::i;:::-;1033:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;22::-1;26:21;;;22:32;6:49;;1033:32:16;;;;;1023:43;;;;;;939:246;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;939:246:16;;;;;;;929:257;;;;;;;;;725:470;-1:-1:-1;;;;;725:470:16:o;3953:526::-;4054:21;4110:1;4095:4;:11;:16;;4087:61;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4179:4;:11;4168:23;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;4168:23:16;;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;125:4;109:14;101:6;88:42;144:17;;-1:-1;4168:23:16;;4158:33;;4231:9;4201:7;4226:1;4209:7;:14;:18;4201:27;;;;;;;;;;;;;;;;;:39;4264:11;;:15;;4250:223;4281:5;;4250:223;;4308:14;4324:15;4343:42;4355:7;4364:4;4373:1;4369;:5;4364:11;;;;;;;;;;;;;;4377:4;4382:1;4377:7;;;;;;;;;;;;;;4343:11;:42::i;:::-;4307:78;;;;4416:46;4428:7;4436:1;4428:10;;;;;;;;;;;;;;4440:9;4451:10;4416:11;:46::i;:::-;4399:7;4411:1;4407;:5;4399:14;;;;;;;;;;;;;;;;;:63;-1:-1:-1;;4288:3:16;;4250:223;;;;3953:526;;;;;:::o;287:349::-;362:14;378;422:6;412:16;;:6;:16;;;;404:68;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;510:6;501:15;;:6;:15;;;:53;;539:6;547;501:53;;;520:6;528;501:53;482:72;;-1:-1:-1;482:72:16;-1:-1:-1;572:20:16;;;564:65;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;287:349;;;;;:::o;1250:389::-;1343:13;1358;1384:14;1403:26;1414:6;1422;1403:10;:26::i;:::-;1383:46;;;1440:13;1455;1490:32;1498:7;1507:6;1515;1490:7;:32::i;:::-;1473:62;;;:64;;;;;;;;;;;;;;;;;;;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;1473:64:16;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1473:64:16;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1473:64:16;;;;;;;1439:98;;;;;-1:-1:-1;1439:98:16;;-1:-1:-1;1570:16:16;;;;;;;;:62;;1613:8;1623;1570:62;;;1590:8;1600;1570:62;1547:85;;;;-1:-1:-1;1250:389:16;-1:-1:-1;;;;;;;1250:389:16:o;2821:470::-;2914:13;2959:1;2947:9;:13;2939:72;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3041:1;3029:9;:13;:31;;;;;3059:1;3046:10;:14;3029:31;3021:86;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3117:14;3134:34;3163:4;3134:24;:9;3148;3134:24;:13;:24;:::i;:::-;:28;:34;:28;:34;:::i;:::-;3117:51;-1:-1:-1;3178:16:16;3197:34;3227:3;3197:25;:10;3212:9;3197:25;:14;:25;:::i;:34::-;3178:53;;3252:32;3282:1;3265:11;3253:9;:23;;;;;;;3252:32;:29;:32;:::i;:::-;3241:43;2821:470;-1:-1:-1;;;;;;2821:470:16:o;419:140:15:-;471:6;497;;;:30;;-1:-1:-1;;512:5:15;;;526:1;521;512:5;521:1;507:15;;;;;:20;497:30;489:63;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;419:140;;;;:::o;286:127::-;369:5;;;364:16;;;;356:50;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;154:126;237:5;;;232:16;;;;224:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "source": "pragma solidity =0.6.6;\n\nimport '@valueswap/v2-core/contracts/interfaces/IValueswapV2Callee.sol';\n\nimport '../libraries/ValueswapV2Library.sol';\nimport '../interfaces/V1/IValueswapV1Factory.sol';\nimport '../interfaces/V1/IValueswapV1Exchange.sol';\nimport '../interfaces/IValueswapV2Router01.sol';\nimport '../interfaces/IERC20.sol';\nimport '../interfaces/IWETH.sol';\n\ncontract ExampleFlashSwap is IValueswapV2Callee {\n IValueswapV1Factory immutable factoryV1;\n address immutable factory;\n IWETH immutable WETH;\n\n constructor(address _factory, address _factoryV1, address router) public {\n factoryV1 = IValueswapV1Factory(_factoryV1);\n factory = _factory;\n WETH = IWETH(IValueswapV2Router01(router).WETH());\n }\n\n // needs to accept ETH from any V1 exchange and WETH. ideally this could be enforced, as in the router,\n // but it's not possible because it requires a call to the v1 factory, which takes too much gas\n receive() external payable {}\n\n // gets tokens/WETH via a V2 flash swap, swaps for the ETH/tokens on V1, repays V2, and keeps the rest!\n function valueswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external override {\n address[] memory path = new address[](2);\n uint amountToken;\n uint amountETH;\n { // scope for token{0,1}, avoids stack too deep errors\n address token0 = IValueswapV2Pair(msg.sender).token0();\n address token1 = IValueswapV2Pair(msg.sender).token1();\n assert(msg.sender == ValueswapV2Library.pairFor(factory, token0, token1)); // ensure that msg.sender is actually a V2 pair\n assert(amount0 == 0 || amount1 == 0); // this strategy is unidirectional\n path[0] = amount0 == 0 ? token0 : token1;\n path[1] = amount0 == 0 ? token1 : token0;\n amountToken = token0 == address(WETH) ? amount1 : amount0;\n amountETH = token0 == address(WETH) ? amount0 : amount1;\n }\n\n assert(path[0] == address(WETH) || path[1] == address(WETH)); // this strategy only works with a V2 WETH pair\n IERC20 token = IERC20(path[0] == address(WETH) ? path[1] : path[0]);\n IValueswapV1Exchange exchangeV1 = IValueswapV1Exchange(factoryV1.getExchange(address(token))); // get V1 exchange\n\n if (amountToken > 0) {\n (uint minETH) = abi.decode(data, (uint)); // slippage parameter for V1, passed in by caller\n token.approve(address(exchangeV1), amountToken);\n uint amountReceived = exchangeV1.tokenToEthSwapInput(amountToken, minETH, uint(-1));\n uint amountRequired = ValueswapV2Library.getAmountsIn(factory, amountToken, path)[0];\n assert(amountReceived > amountRequired); // fail if we didn't get enough ETH back to repay our flash loan\n WETH.deposit{value: amountRequired}();\n assert(WETH.transfer(msg.sender, amountRequired)); // return WETH to V2 pair\n (bool success,) = sender.call{value: amountReceived - amountRequired}(new bytes(0)); // keep the rest! (ETH)\n assert(success);\n } else {\n (uint minTokens) = abi.decode(data, (uint)); // slippage parameter for V1, passed in by caller\n WETH.withdraw(amountETH);\n uint amountReceived = exchangeV1.ethToTokenSwapInput{value: amountETH}(minTokens, uint(-1));\n uint amountRequired = ValueswapV2Library.getAmountsIn(factory, amountETH, path)[0];\n assert(amountReceived > amountRequired); // fail if we didn't get enough tokens back to repay our flash loan\n assert(token.transfer(msg.sender, amountRequired)); // return tokens to V2 pair\n assert(token.transfer(sender, amountReceived - amountRequired)); // keep the rest! (tokens)\n }\n }\n}\n", "sourcePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/examples/ExampleFlashSwap.sol", "ast": { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/examples/ExampleFlashSwap.sol", "exportedSymbols": { "ExampleFlashSwap": [ 4075 ] }, "id": 4076, "nodeType": "SourceUnit", "nodes": [ { "id": 3700, "literals": [ "solidity", "=", "0.6", ".6" ], "nodeType": "PragmaDirective", "src": "0:23:4" }, { "absolutePath": "@valueswap/v2-core/contracts/interfaces/IValueswapV2Callee.sol", "file": "@valueswap/v2-core/contracts/interfaces/IValueswapV2Callee.sol", "id": 3701, "nodeType": "ImportDirective", "scope": 4076, "sourceUnit": 9054, "src": "25:72:4", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2Library.sol", "file": "../libraries/ValueswapV2Library.sol", "id": 3702, "nodeType": "ImportDirective", "scope": 4076, "sourceUnit": 6054, "src": "99:45:4", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/V1/IValueswapV1Factory.sol", "file": "../interfaces/V1/IValueswapV1Factory.sol", "id": 3703, "nodeType": "ImportDirective", "scope": 4076, "sourceUnit": 5507, "src": "145:50:4", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/V1/IValueswapV1Exchange.sol", "file": "../interfaces/V1/IValueswapV1Exchange.sol", "id": 3704, "nodeType": "ImportDirective", "scope": 4076, "sourceUnit": 5497, "src": "196:51:4", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/IValueswapV2Router01.sol", "file": "../interfaces/IValueswapV2Router01.sol", "id": 3705, "nodeType": "ImportDirective", "scope": 4076, "sourceUnit": 5333, "src": "248:48:4", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/IERC20.sol", "file": "../interfaces/IERC20.sol", "id": 3706, "nodeType": "ImportDirective", "scope": 4076, "sourceUnit": 5009, "src": "297:34:4", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/IWETH.sol", "file": "../interfaces/IWETH.sol", "id": 3707, "nodeType": "ImportDirective", "scope": 4076, "sourceUnit": 5441, "src": "332:33:4", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 3708, "name": "IValueswapV2Callee", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 9053, "src": "396:18:4", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV2Callee_$9053", "typeString": "contract IValueswapV2Callee" } }, "id": 3709, "nodeType": "InheritanceSpecifier", "src": "396:18:4" } ], "contractDependencies": [ 9053 ], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 4075, "linearizedBaseContracts": [ 4075, 9053 ], "name": "ExampleFlashSwap", "nodeType": "ContractDefinition", "nodes": [ { "constant": false, "id": 3711, "mutability": "immutable", "name": "factoryV1", "nodeType": "VariableDeclaration", "overrides": null, "scope": 4075, "src": "421:39:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Factory_$5506", "typeString": "contract IValueswapV1Factory" }, "typeName": { "contractScope": null, "id": 3710, "name": "IValueswapV1Factory", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5506, "src": "421:19:4", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Factory_$5506", "typeString": "contract IValueswapV1Factory" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 3713, "mutability": "immutable", "name": "factory", "nodeType": "VariableDeclaration", "overrides": null, "scope": 4075, "src": "466:25:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 3712, "name": "address", "nodeType": "ElementaryTypeName", "src": "466:7:4", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 3715, "mutability": "immutable", "name": "WETH", "nodeType": "VariableDeclaration", "overrides": null, "scope": 4075, "src": "497:20:4", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_IWETH_$5440", "typeString": "contract IWETH" }, "typeName": { "contractScope": null, "id": 3714, "name": "IWETH", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5440, "src": "497:5:4", "typeDescriptions": { "typeIdentifier": "t_contract$_IWETH_$5440", "typeString": "contract IWETH" } }, "value": null, "visibility": "internal" }, { "body": { "id": 3744, "nodeType": "Block", "src": "597:147:4", "statements": [ { "expression": { "argumentTypes": null, "id": 3728, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 3724, "name": "factoryV1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3711, "src": "607:9:4", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Factory_$5506", "typeString": "contract IValueswapV1Factory" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 3726, "name": "_factoryV1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3719, "src": "639:10:4", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address"