UNPKG

@valueswap/v2-periphery

Version:

🎚 Peripheral smart contracts for interacting with Valueswap V2

774 lines • 239 kB
{ "contractName": "ValueswapV2Migrator", "abi": [ { "inputs": [ { "internalType": "address", "name": "_factoryV1", "type": "address" }, { "internalType": "address", "name": "_router", "type": "address" } ], "stateMutability": "nonpayable", "type": "constructor" }, { "stateMutability": "payable", "type": "receive" }, { "inputs": [ { "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "amountTokenMin", "type": "uint256" }, { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "deadline", "type": "uint256" } ], "name": "migrate", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_factoryV1\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_router\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountTokenMin\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountETHMin\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"migrate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/ValueswapV2Migrator.sol\":\"ValueswapV2Migrator\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/ValueswapV2Migrator.sol\":{\"keccak256\":\"0x76f65b39696b6b4b8a2fabfc865f7d06ffdc9a2f2fc7719aa8dad545ea9ddac7\",\"urls\":[\"bzz-raw://a123de3cddc8b59fdb82e9b7574bcfd01a78177ebefd380b8ff04daf4dac77a2\",\"dweb:/ipfs/QmS3TkLJDZAf3EnYkqs3WTDw3MZ2huqibhTAaPrxZbBjn6\"]},\"/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/IValueswapV2Migrator.sol\":{\"keccak256\":\"0x892e70808b5263f38b7f68c4f0f23766a35a4cb90ab47c215e9edc4992fd7989\",\"urls\":[\"bzz-raw://cf94d37f8cdc877097a6ed46a7452ab49c944d5ef1f2665bc96e50b5c6800fe3\",\"dweb:/ipfs/QmNicJzwH45Y8JPMZ6jjZ7DPi1fSKWq2d6BvYofFSUUcTH\"]},\"/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/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\"]},\"@valueswap/lib/contracts/libraries/TransferHelper.sol\":{\"keccak256\":\"0xaff99b54915f57e2a4e71b8d15afd4ee425410e5a6f45c07517ae1beb806f8bd\",\"urls\":[\"bzz-raw://15432ec031f4cfa6709921289e198b030a0c5eac75b5a3e0eb64827a2b3b5595\",\"dweb:/ipfs/QmZvR1KuuDvuzXFiADCngTKyMCTy31uhq9U6CazP59B55j\"]}},\"version\":1}", "bytecode": "0x60c060405234801561001057600080fd5b50604051610b7c380380610b7c8339818101604052604081101561003357600080fd5b5080516020909101516001600160601b0319606092831b8116608052911b1660a05260805160601c60a05160601c610af5610087600039806103ee5280610484528061051652508060905250610af56000f3fe6080604052600436106100225760003560e01c8063b7df1d251461002e57610029565b3661002957005b600080fd5b34801561003a57600080fd5b5061008a600480360360a081101561005157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020810135916040820135916060810135909116906080013561008c565b005b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166306f2bf62876040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561012b57600080fd5b505afa15801561013f573d6000803e3d6000fd5b505050506040513d602081101561015557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152336004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b1580156101c957600080fd5b505afa1580156101dd573d6000803e3d6000fd5b505050506040513d60208110156101f357600080fd5b5051604080517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101839052905191925073ffffffffffffffffffffffffffffffffffffffff8416916323b872dd916064808201926020929091908290030181600087803b15801561027457600080fd5b505af1158015610288573d6000803e3d6000fd5b505050506040513d602081101561029e57600080fd5b505161030b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c4544000000000000000000000000604482015290519081900360640190fd5b604080517ff88bf15a0000000000000000000000000000000000000000000000000000000081526004810183905260016024820181905260448201527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60648201528151600092839273ffffffffffffffffffffffffffffffffffffffff87169263f88bf15a9260848084019391929182900301818787803b1580156103b057600080fd5b505af11580156103c4573d6000803e3d6000fd5b505050506040513d60408110156103da57600080fd5b5080516020909101519092509050610413897f00000000000000000000000000000000000000000000000000000000000000008361056f565b604080517ff305d71900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b8116600483015260248201849052604482018b9052606482018a9052888116608483015260a48201889052915160009283927f00000000000000000000000000000000000000000000000000000000000000009091169163f305d71991879160c480830192606092919082900301818588803b1580156104cf57600080fd5b505af11580156104e3573d6000803e3d6000fd5b50505050506040513d60608110156104fa57600080fd5b50805160209091015190925090508183111561054e5761053c8b7f0000000000000000000000000000000000000000000000000000000000000000600061056f565b6105498b33848603610736565b610562565b8084111561056257610562338286036108f6565b5050505050505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000178152925182516000946060949389169392918291908083835b6020831061064557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610608565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146106a7576040519150601f19603f3d011682016040523d82523d6000602084013e6106ac565b606091505b50915091508180156106da5750805115806106da57508080602001905160208110156106d757600080fd5b50515b61072f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180610a68602b913960400191505060405180910390fd5b5050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000178152925182516000946060949389169392918291908083835b6020831061080c57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107cf565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461086e576040519150601f19603f3d011682016040523d82523d6000602084013e610873565b606091505b50915091508180156108a15750805115806108a1575080806020019051602081101561089e57600080fd5b50515b61072f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180610a93602d913960400191505060405180910390fd5b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff84169083906040518082805190602001908083835b6020831061096d57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610930565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146109cf576040519150601f19603f3d011682016040523d82523d6000602084013e6109d4565b606091505b5050905080610a2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526034815260200180610a346034913960400191505060405180910390fd5b50505056fe5472616e7366657248656c7065723a3a736166655472616e736665724554483a20455448207472616e73666572206661696c65645472616e7366657248656c7065723a3a73616665417070726f76653a20617070726f7665206661696c65645472616e7366657248656c7065723a3a736166655472616e736665723a207472616e73666572206661696c6564a2646970667358221220427abcac71f8a59f2f294aed2296313336c46e4f79ca3f2a867d5653e13cb41f64736f6c63430006060033", "deployedBytecode": "0x6080604052600436106100225760003560e01c8063b7df1d251461002e57610029565b3661002957005b600080fd5b34801561003a57600080fd5b5061008a600480360360a081101561005157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020810135916040820135916060810135909116906080013561008c565b005b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166306f2bf62876040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561012b57600080fd5b505afa15801561013f573d6000803e3d6000fd5b505050506040513d602081101561015557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152336004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b1580156101c957600080fd5b505afa1580156101dd573d6000803e3d6000fd5b505050506040513d60208110156101f357600080fd5b5051604080517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101839052905191925073ffffffffffffffffffffffffffffffffffffffff8416916323b872dd916064808201926020929091908290030181600087803b15801561027457600080fd5b505af1158015610288573d6000803e3d6000fd5b505050506040513d602081101561029e57600080fd5b505161030b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c4544000000000000000000000000604482015290519081900360640190fd5b604080517ff88bf15a0000000000000000000000000000000000000000000000000000000081526004810183905260016024820181905260448201527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60648201528151600092839273ffffffffffffffffffffffffffffffffffffffff87169263f88bf15a9260848084019391929182900301818787803b1580156103b057600080fd5b505af11580156103c4573d6000803e3d6000fd5b505050506040513d60408110156103da57600080fd5b5080516020909101519092509050610413897f00000000000000000000000000000000000000000000000000000000000000008361056f565b604080517ff305d71900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b8116600483015260248201849052604482018b9052606482018a9052888116608483015260a48201889052915160009283927f00000000000000000000000000000000000000000000000000000000000000009091169163f305d71991879160c480830192606092919082900301818588803b1580156104cf57600080fd5b505af11580156104e3573d6000803e3d6000fd5b50505050506040513d60608110156104fa57600080fd5b50805160209091015190925090508183111561054e5761053c8b7f0000000000000000000000000000000000000000000000000000000000000000600061056f565b6105498b33848603610736565b610562565b8084111561056257610562338286036108f6565b5050505050505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000178152925182516000946060949389169392918291908083835b6020831061064557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610608565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146106a7576040519150601f19603f3d011682016040523d82523d6000602084013e6106ac565b606091505b50915091508180156106da5750805115806106da57508080602001905160208110156106d757600080fd5b50515b61072f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180610a68602b913960400191505060405180910390fd5b5050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000178152925182516000946060949389169392918291908083835b6020831061080c57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107cf565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461086e576040519150601f19603f3d011682016040523d82523d6000602084013e610873565b606091505b50915091508180156108a15750805115806108a1575080806020019051602081101561089e57600080fd5b50515b61072f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180610a93602d913960400191505060405180910390fd5b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff84169083906040518082805190602001908083835b6020831061096d57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610930565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146109cf576040519150601f19603f3d011682016040523d82523d6000602084013e6109d4565b606091505b5050905080610a2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526034815260200180610a346034913960400191505060405180910390fd5b50505056fe5472616e7366657248656c7065723a3a736166655472616e736665724554483a20455448207472616e73666572206661696c65645472616e7366657248656c7065723a3a73616665417070726f76653a20617070726f7665206661696c65645472616e7366657248656c7065723a3a736166655472616e736665723a207472616e73666572206661696c6564a2646970667358221220427abcac71f8a59f2f294aed2296313336c46e4f79ca3f2a867d5653e13cb41f64736f6c63430006060033", "immutableReferences": { "44": [ { "length": 32, "start": 144 } ], "46": [ { "length": 32, "start": 1006 }, { "length": 32, "start": 1156 }, { "length": 32, "start": 1302 } ] }, "sourceMap": "322:1916:1:-:0;;;470:164;5:9:-1;2:2;;;27:1;24;17:12;2:2;470:164:1;;;;;;;;;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;470:164:1;;;;;;;-1:-1:-1;;;;;;536:43:1;;;;;;;;589:38;;;;;322:1916;;;;;;;;;;;;;;;;", "deployedSourceMap": "322:1916:1:-:0;;;;;;;;;;;;;;;;;;;;;;;;;12:1:-1;9;2:12;889:1347:1;;5:9:-1;2:2;;;27:1;24;17:12;2:2;889:1347:1;;;;;;15:3:-1;10;7:12;4:2;;;32:1;29;22:12;4:2;-1:-1;889:1347:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;1036:31;1091:9;:21;;;1113:5;1091:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;1091:28:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1091:28:1;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1091:28:1;1149:32;;;;;;1170:10;1149:32;;;;;;1091:28;;-1:-1:-1;1130:16:1;;1149:20;;;;;;:32;;;;;1091:28;;1149:32;;;;;;;:20;:32;;;2:2:-1;;;;27:1;24;17:12;2:2;1149:32:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1149:32:1;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1149:32:1;1199:63;;;;;;1223:10;1199:63;;;;1243:4;1199:63;;;;;;;;;;;;1149:32;;-1:-1:-1;1199:23:1;;;;;;:63;;;;;1149:32;;1199:63;;;;;;;;-1:-1:-1;1199:23:1;:63;;;2:2:-1;;;;27:1;24;17:12;2:2;1199:63:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1199:63:1;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1199:63:1;1191:96;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1338:55;;;;;;;;;;;;1378:1;1338:55;;;;;;;;;;1389:2;1338:55;;;;;;1298:16;;;;1338:26;;;;;;:55;;;;;;;;;;;;;1298:16;1338:26;:55;;;2:2:-1;;;;27:1;24;17:12;2:2;1338:55:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1338:55:1;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1338:55:1;;;;;;;;;-1:-1:-1;1338:55:1;-1:-1:-1;1403:65:1;1430:5;1445:6;1338:55;1403:26;:65::i;:::-;1520:190;;;;;;:22;:190;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;1520:6:1;:22;;;;;;1550:11;;1520:190;;;;;;;;;;;;;;1550:11;1520:22;:190;;;2:2:-1;;;;27:1;24;17:12;2:2;1520:190:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1520:190:1;;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1520:190:1;;;;;;;;;-1:-1:-1;1520:190:1;-1:-1:-1;1724:29:1;;;1720:510;;;1769:53;1796:5;1811:6;1820:1;1769:26;:53::i;:::-;1890:77;1918:5;1925:10;1953:13;1937;:29;1890:27;:77::i;:::-;1720:510;;;2002:11;1988;:25;1984:246;;;2150:69;2181:10;2207:11;2193;:25;2150:30;:69::i;:::-;889:1347;;;;;;;;;;;:::o;212:434:26:-;436:45;;;425:10;436:45;;;;;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;436:45:26;;;;;;;25:18:-1;;61:17;;96:58;182:15;436:45:26;179:29:-1;160:49;;425:57:26;;;;390:12;;404:17;;425:10;;;;436:45;425:57;;;25:18:-1;425:57:26;;25:18:-1;36:153;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;;;425:57:26;;;;;;;;;;;;;;;;;;;;;;;;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;;389:93:26;;;;513:7;:57;;;;-1:-1:-1;525:11:26;;:16;;:44;;;556:4;545:24;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;545:24:26;525:44;492:147;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;212:434;;;;;:::o;652:438::-;878:45;;;867:10;878:45;;;;;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;878:45:26;;;;;;;25:18:-1;;61:17;;96:58;182:15;878:45:26;179:29:-1;160:49;;867:57:26;;;;832:12;;846:17;;867:10;;;;878:45;867:57;;;25:18:-1;867:57:26;;25:18:-1;36:153;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;;;867:57:26;;;;;;;;;;;;;;;;;;;;;;;;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;;831:93:26;;;;955:7;:57;;;;-1:-1:-1;967:11:26;;:16;;:44;;;998:4;987:24;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;987:24:26;967:44;934:149;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1588:214;1700:12;;;1660;1700;;;;;;;;;1678:7;;;;1693:5;;1678:35;;;;;;;;;;;;;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;;;1678:35:26;;;;;;;;;;;;;;;;;;;;;;;;;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;;1659:54:26;;;1731:7;1723:72;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1588:214;;;:::o", "source": "pragma solidity =0.6.6;\n\nimport '@valueswap/lib/contracts/libraries/TransferHelper.sol';\n\nimport './interfaces/IValueswapV2Migrator.sol';\nimport './interfaces/V1/IValueswapV1Factory.sol';\nimport './interfaces/V1/IValueswapV1Exchange.sol';\nimport './interfaces/IValueswapV2Router01.sol';\nimport './interfaces/IERC20.sol';\n\ncontract ValueswapV2Migrator is IValueswapV2Migrator {\n IValueswapV1Factory immutable factoryV1;\n IValueswapV2Router01 immutable router;\n\n constructor(address _factoryV1, address _router) public {\n factoryV1 = IValueswapV1Factory(_factoryV1);\n router = IValueswapV2Router01(_router);\n }\n\n // needs to accept ETH from any v1 exchange and the router. 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 function migrate(address token, uint amountTokenMin, uint amountETHMin, address to, uint deadline)\n external\n override\n {\n IValueswapV1Exchange exchangeV1 = IValueswapV1Exchange(factoryV1.getExchange(token));\n uint liquidityV1 = exchangeV1.balanceOf(msg.sender);\n require(exchangeV1.transferFrom(msg.sender, address(this), liquidityV1), 'TRANSFER_FROM_FAILED');\n (uint amountETHV1, uint amountTokenV1) = exchangeV1.removeLiquidity(liquidityV1, 1, 1, uint(-1));\n TransferHelper.safeApprove(token, address(router), amountTokenV1);\n (uint amountTokenV2, uint amountETHV2,) = router.addLiquidityETH{value: amountETHV1}(\n token,\n amountTokenV1,\n amountTokenMin,\n amountETHMin,\n to,\n deadline\n );\n if (amountTokenV1 > amountTokenV2) {\n TransferHelper.safeApprove(token, address(router), 0); // be a good blockchain citizen, reset allowance to 0\n TransferHelper.safeTransfer(token, msg.sender, amountTokenV1 - amountTokenV2);\n } else if (amountETHV1 > amountETHV2) {\n // addLiquidityETH guarantees that all of amountETHV1 or amountTokenV1 will be used, hence this else is safe\n TransferHelper.safeTransferETH(msg.sender, amountETHV1 - amountETHV2);\n }\n }\n}\n", "sourcePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/ValueswapV2Migrator.sol", "ast": { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/ValueswapV2Migrator.sol", "exportedSymbols": { "ValueswapV2Migrator": [ 202 ] }, "id": 203, "nodeType": "SourceUnit", "nodes": [ { "id": 34, "literals": [ "solidity", "=", "0.6", ".6" ], "nodeType": "PragmaDirective", "src": "0:23:1" }, { "absolutePath": "@valueswap/lib/contracts/libraries/TransferHelper.sol", "file": "@valueswap/lib/contracts/libraries/TransferHelper.sol", "id": 35, "nodeType": "ImportDirective", "scope": 203, "sourceUnit": 9040, "src": "25:63:1", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/IValueswapV2Migrator.sol", "file": "./interfaces/IValueswapV2Migrator.sol", "id": 36, "nodeType": "ImportDirective", "scope": 203, "sourceUnit": 5025, "src": "90:47:1", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/V1/IValueswapV1Factory.sol", "file": "./interfaces/V1/IValueswapV1Factory.sol", "id": 37, "nodeType": "ImportDirective", "scope": 203, "sourceUnit": 5507, "src": "138:49:1", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/V1/IValueswapV1Exchange.sol", "file": "./interfaces/V1/IValueswapV1Exchange.sol", "id": 38, "nodeType": "ImportDirective", "scope": 203, "sourceUnit": 5497, "src": "188:50:1", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/IValueswapV2Router01.sol", "file": "./interfaces/IValueswapV2Router01.sol", "id": 39, "nodeType": "ImportDirective", "scope": 203, "sourceUnit": 5333, "src": "239:47:1", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/interfaces/IERC20.sol", "file": "./interfaces/IERC20.sol", "id": 40, "nodeType": "ImportDirective", "scope": 203, "sourceUnit": 5009, "src": "287:33:1", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 41, "name": "IValueswapV2Migrator", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5024, "src": "354:20:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV2Migrator_$5024", "typeString": "contract IValueswapV2Migrator" } }, "id": 42, "nodeType": "InheritanceSpecifier", "src": "354:20:1" } ], "contractDependencies": [ 5024 ], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 202, "linearizedBaseContracts": [ 202, 5024 ], "name": "ValueswapV2Migrator", "nodeType": "ContractDefinition", "nodes": [ { "constant": false, "id": 44, "mutability": "immutable", "name": "factoryV1", "nodeType": "VariableDeclaration", "overrides": null, "scope": 202, "src": "381:39:1", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Factory_$5506", "typeString": "contract IValueswapV1Factory" }, "typeName": { "contractScope": null, "id": 43, "name": "IValueswapV1Factory", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5506, "src": "381:19:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Factory_$5506", "typeString": "contract IValueswapV1Factory" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 46, "mutability": "immutable", "name": "router", "nodeType": "VariableDeclaration", "overrides": null, "scope": 202, "src": "426:37:1", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV2Router01_$5332", "typeString": "contract IValueswapV2Router01" }, "typeName": { "contractScope": null, "id": 45, "name": "IValueswapV2Router01", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5332, "src": "426:20:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV2Router01_$5332", "typeString": "contract IValueswapV2Router01" } }, "value": null, "visibility": "internal" }, { "body": { "id": 65, "nodeType": "Block", "src": "526:108:1", "statements": [ { "expression": { "argumentTypes": null, "id": 57, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 53, "name": "factoryV1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44, "src": "536:9:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Factory_$5506", "typeString": "contract IValueswapV1Factory" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 55, "name": "_factoryV1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 48, "src": "568:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 54, "name": "IValueswapV1Factory", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5506, "src": "548:19:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IValueswapV1Factory_$5506_$", "typeString": "type(contract IValueswapV1Factory)" } }, "id": 56, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "548:31:1", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Factory_$5506", "typeString": "contract IValueswapV1Factory" } }, "src": "536:43:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Factory_$5506", "typeString": "contract IValueswapV1Factory" } }, "id": 58, "nodeType": "ExpressionStatement", "src": "536:43:1" }, { "expression": { "argumentTypes": null, "id": 63, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 59, "name": "router", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 46, "src": "589:6:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV2Router01_$5332", "typeString": "contract IValueswapV2Router01" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 61, "name": "_router", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 50, "src": "619:7:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 60, "name": "IValueswapV2Router01", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5332, "src": "598:20:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IValueswapV2Router01_$5332_$", "typeString": "type(contract IValueswapV2Router01)" } }, "id": 62, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "598:29:1", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV2Router01_$5332", "typeString": "contract IValueswapV2Router01" } }, "src": "589:38:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV2Router01_$5332", "typeString": "contract IValueswapV2Router01" } }, "id": 64, "nodeType": "ExpressionStatement", "src": "589:38:1" } ] }, "documentation": null, "id": 66, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 51, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 48, "mutability": "mutable", "name": "_factoryV1", "nodeType": "VariableDeclaration", "overrides": null, "scope": 66, "src": "482:18:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 47, "name": "address", "nodeType": "ElementaryTypeName", "src": "482:7:1", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 50, "mutability": "mutable", "name": "_router", "nodeType": "VariableDeclaration", "overrides": null, "scope": 66, "src": "502:15:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 49, "name": "address", "nodeType": "ElementaryTypeName", "src": "502:7:1", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "481:37:1" }, "returnParameters": { "id": 52, "nodeType": "ParameterList", "parameters": [], "src": "526:0:1" }, "scope": 202, "src": "470:164:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" }, { "body": { "id": 69, "nodeType": "Block", "src": "881:2:1", "statements": [] }, "documentation": null, "id": 70, "implemented": true, "kind": "receive", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 67, "nodeType": "ParameterList", "parameters": [], "src": "861:2:1" }, "returnParameters": { "id": 68, "nodeType": "ParameterList", "parameters": [], "src": "881:0:1" }, "scope": 202, "src": "854:29:1", "stateMutability": "payable", "virtual": false, "visibility": "external" }, { "baseFunctions": [ 5023 ], "body": { "id": 200, "nodeType": "Block", "src": "1026:1210:1", "statements": [ { "assignments": [ 85 ], "declarations": [ { "constant": false, "id": 85, "mutability": "mutable", "name": "exchangeV1", "nodeType": "VariableDeclaration", "overrides": null, "scope": 200, "src": "1036:31:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Exchange_$5496", "typeString": "contract IValueswapV1Exchange" }, "typeName": { "contractScope": null, "id": 84, "name": "IValueswapV1Exchange", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5496, "src": "1036:20:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Exchange_$5496", "typeString": "contract IValueswapV1Exchange" } }, "value": null, "visibility": "internal" } ], "id": 92, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 89, "name": "token", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 72, "src": "1113:5:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "expression": { "argumentTypes": null, "id": 87, "name": "factoryV1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44, "src": "1091:9:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Factory_$5506", "typeString": "contract IValueswapV1Factory" } }, "id": 88, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "getExchange", "nodeType": "MemberAccess", "referencedDeclaration": 5505, "src": "1091:21:1", "typeDescriptions": { "typeIdentifier": "t_function_external_view$_t_address_$returns$_t_address_$", "typeString": "function (address) view external returns (address)" } }, "id": 90, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1091:28:1", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 86, "name": "IValueswapV1Exchange", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5496, "src": "1070:20:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IValueswapV1Exchange_$5496_$", "typeString": "type(contract IValueswapV1Exchange)" } }, "id": 91, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1070:50:1", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IValueswapV1Exchange_$5496", "typeString": "contract IValueswapV1Exchange" } }, "nodeType": "VariableDeclarationStatement", "src": "1036:84:1" }, { "assignments": [ 94 ], "declarations": [ { "constant": false, "id": 94, "mutability": "mutable", "name": "liquidityV1", "nodeType": "VariableDeclaration", "overrides": null, "scope": 200, "src": "1130:16:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 93, "name": "uint", "nodeType": "ElementaryTypeName", "src": "1130:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 100, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 97, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -15, "src": "1170:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 98, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclarat