Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x3b6442AA0f05c82E9535E224C453EE1836d7e7ed
Balance 0 ETH
Nonce 1
Code Size 13336 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

13336 bytes
0x6080604052600436106100e0575f3560e01c8063c2eaf08b1161007e578063d2fefce411610058578063d2fefce4146102a3578063d9c0d9a2146102cb578063f3acae3a146102f3578063ffba553e1461031d576100e7565b8063c2eaf08b14610223578063cd0821631461023f578063d27df1ce14610267576100e7565b80636257a38e116100ba5780636257a38e1461017b5780636637e38c146101a5578063913e77ad146101cf578063bf333f2c146101f9576100e7565b80632b4849c6146100eb5780632f48ab7d146101275780633fc8cef314610151576100e7565b366100e757005b5f5ffd5b3480156100f6575f5ffd5b50610111600480360381019061010c9190612589565b610345565b60405161011e9190612621565b60405180910390f35b348015610132575f5ffd5b5061013b6105fc565b6040516101489190612649565b60405180910390f35b34801561015c575f5ffd5b50610165610620565b6040516101729190612649565b60405180910390f35b348015610186575f5ffd5b5061018f610644565b60405161019c91906126bd565b60405180910390f35b3480156101b0575f5ffd5b506101b9610668565b6040516101c69190612621565b60405180910390f35b3480156101da575f5ffd5b506101e361066e565b6040516101f09190612649565b60405180910390f35b348015610204575f5ffd5b5061020d610692565b60405161021a9190612621565b60405180910390f35b61023d60048036038101906102389190612589565b610697565b005b34801561024a575f5ffd5b50610265600480360381019061026091906126d6565b610b2a565b005b348015610272575f5ffd5b5061028d60048036038101906102889190612773565b610d21565b60405161029a9190612621565b60405180910390f35b3480156102ae575f5ffd5b506102c960048036038101906102c491906127ea565b610f3a565b005b3480156102d6575f5ffd5b506102f160048036038101906102ec91906127ea565b611592565b005b3480156102fe575f5ffd5b50610307611c4d565b60405161031491906128a7565b60405180910390f35b348015610328575f5ffd5b50610343600480360381019061033e91906127ea565b611c71565b005b5f3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ab9061291a565b60405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1663d0e30db0876040518263ffffffff1660e01b81526004015f604051808303818588803b15801561041a575f5ffd5b505af115801561042c573d5f5f3e3d5ffd5b505050505061049c7f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45877f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1661218f9092919063ffffffff16565b5f6040518061010001604052807f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1681526020018973ffffffffffffffffffffffffffffffffffffffff1681526020018662ffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018881526020018781526020015f73ffffffffffffffffffffffffffffffffffffffff1681525090507f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc4573ffffffffffffffffffffffffffffffffffffffff1663414bf389826040518263ffffffff1660e01b81526004016105af9190612a14565b6020604051808303815f875af11580156105cb573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105ef9190612a42565b9150509695505050505050565b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b7f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc4581565b61271081565b7f00000000000000000000000003b6ed6f17b2c9b15502e7288cd5804062606fb581565b606481565b5f34116106d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d090612ab7565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610747576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161073e90612b1f565b60405180910390fd5b5f6107513461229c565b90505f81346107609190612b6a565b90505f7f00000000000000000000000003b6ed6f17b2c9b15502e7288cd5804062606fb573ffffffffffffffffffffffffffffffffffffffff16836040516107a790612bca565b5f6040518083038185875af1925050503d805f81146107e1576040519150601f19603f3d011682016040523d82523d5f602084013e6107e6565b606091505b505090508061082a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082190612c28565b60405180910390fd5b5f5f90505f5f90505f73ffffffffffffffffffffffffffffffffffffffff167f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc4573ffffffffffffffffffffffffffffffffffffffff1614610919573073ffffffffffffffffffffffffffffffffffffffff16632b4849c68c868d8c8c8c6040518763ffffffff1660e01b81526004016108c896959493929190612c55565b6020604051808303815f875af192505050801561090357506040513d601f19601f820116820180604052508101906109009190612a42565b60015b61090f575f9150610918565b60019250809150505b5b811561096c5789811015610962576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161095990612cfe565b60405180910390fd5b5050505050610b22565b5f600267ffffffffffffffff81111561098857610987612d1c565b5b6040519080825280602002602001820160405280156109b65781602001602082028036833780820191505090505b5090507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2815f815181106109ed576109ec612d49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508b81600181518110610a3c57610a3b612d49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff16637ff36ab5868c848c8c6040518663ffffffff1660e01b8152600401610ad69493929190612e1e565b5f6040518083038185885af1158015610af1573d5f5f3e3d5ffd5b50505050506040513d5f823e3d601f19601f82011682018060405250810190610b1a9190612f8b565b505050505050505b505050505050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b98576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8f9061291a565b60405180910390fd5b610be37f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45868973ffffffffffffffffffffffffffffffffffffffff1661218f9092919063ffffffff16565b5f6040518061010001604052808973ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1681526020018562ffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018781526020018681526020015f73ffffffffffffffffffffffffffffffffffffffff1681525090507f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc4573ffffffffffffffffffffffffffffffffffffffff1663414bf389826040518263ffffffff1660e01b8152600401610cd69190612a14565b6020604051808303815f875af1158015610cf2573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d169190612a42565b505050505050505050565b5f3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d879061291a565b60405180910390fd5b610ddb7f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45868873ffffffffffffffffffffffffffffffffffffffff1661218f9092919063ffffffff16565b5f6040518061010001604052808873ffffffffffffffffffffffffffffffffffffffff1681526020017f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1681526020018562ffffff1681526020013073ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018781526020018681526020015f73ffffffffffffffffffffffffffffffffffffffff1681525090507f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc4573ffffffffffffffffffffffffffffffffffffffff1663414bf389826040518263ffffffff1660e01b8152600401610eee9190612a14565b6020604051808303815f875af1158015610f0a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f2e9190612a42565b91505095945050505050565b5f8611610f7c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f739061301c565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610fea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fe190612b1f565b60405180910390fd5b6110173330888a73ffffffffffffffffffffffffffffffffffffffff166122be909392919063ffffffff16565b5f5f90505f5f90505f73ffffffffffffffffffffffffffffffffffffffff167f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc4573ffffffffffffffffffffffffffffffffffffffff1614611104573073ffffffffffffffffffffffffffffffffffffffff1663d27df1ce8a8a8a89886040518663ffffffff1660e01b81526004016110b395949392919061303a565b6020604051808303815f875af19250505080156110ee57506040513d601f19601f820116820180604052508101906110eb9190612a42565b60015b6110fa575f9150611103565b60019250809150505b5b8161132f576111547f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d898b73ffffffffffffffffffffffffffffffffffffffff1661218f9092919063ffffffff16565b5f600267ffffffffffffffff8111156111705761116f612d1c565b5b60405190808252806020026020018201604052801561119e5781602001602082028036833780820191505090505b50905089815f815181106111b5576111b4612d49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28160018151811061122457611223612d49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505f4790507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff166318cbafe58b8a85308a6040518663ffffffff1660e01b81526004016112c395949392919061308b565b5f604051808303815f875af11580156112de573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906113069190612f8b565b505f479050818111611318575f611325565b81816113249190612b6a565b5b93505050506113b6565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b81526004016113889190612621565b5f604051808303815f87803b15801561139f575f5ffd5b505af11580156113b1573d5f5f3e3d5ffd5b505050505b5f81116113f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ef9061312d565b60405180910390fd5b5f6114028261229c565b90505f81836114119190612b6a565b90505f7f00000000000000000000000003b6ed6f17b2c9b15502e7288cd5804062606fb573ffffffffffffffffffffffffffffffffffffffff168360405161145890612bca565b5f6040518083038185875af1925050503d805f8114611492576040519150601f19603f3d011682016040523d82523d5f602084013e611497565b606091505b50509050806114db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d290612c28565b60405180910390fd5b5f8773ffffffffffffffffffffffffffffffffffffffff168360405161150090612bca565b5f6040518083038185875af1925050503d805f811461153a576040519150601f19603f3d011682016040523d82523d5f602084013e61153f565b606091505b5050905080611583576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157a90613195565b60405180910390fd5b50505050505050505050505050565b5f86116115d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115cb9061301c565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161163990612b1f565b60405180910390fd5b61166f3330888a73ffffffffffffffffffffffffffffffffffffffff166122be909392919063ffffffff16565b5f7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016116c99190612649565b602060405180830381865afa1580156116e4573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117089190612a42565b90505f5f90505f5f90505f73ffffffffffffffffffffffffffffffffffffffff167f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc4573ffffffffffffffffffffffffffffffffffffffff1614611804573073ffffffffffffffffffffffffffffffffffffffff1663cd0821638b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec78c8c8b308b6040518863ffffffff1660e01b81526004016117ca97969594939291906131b3565b5f604051808303815f87803b1580156117e1575f5ffd5b505af19250505080156117f2575060015b6117fe575f9050611803565b600190505b5b80611a74576118547f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d8a8c73ffffffffffffffffffffffffffffffffffffffff1661218f9092919063ffffffff16565b5f600367ffffffffffffffff8111156118705761186f612d1c565b5b60405190808252806020026020018201604052801561189e5781602001602082028036833780820191505090505b5090508a815f815181106118b5576118b4612d49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28160018151811061192457611923612d49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec78160028151811061199357611992612d49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff166338ed17398b8a84308a6040518663ffffffff1660e01b8152600401611a2e95949392919061308b565b5f604051808303815f875af1158015611a49573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190611a719190612f8b565b50505b5f7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611ace9190612649565b602060405180830381865afa158015611ae9573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b0d9190612a42565b9050838111611b1c575f611b29565b8381611b289190612b6a565b5b92505f8311611b6d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b649061326a565b60405180910390fd5b5f611b778461229c565b90505f8185611b869190612b6a565b9050611bf37f00000000000000000000000003b6ed6f17b2c9b15502e7288cd5804062606fb5837f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166123409092919063ffffffff16565b611c3e88827f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166123409092919063ffffffff16565b50505050505050505050505050565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b5f8611611cb3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611caa9061301c565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611d21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d1890612b1f565b60405180910390fd5b611d6e3330887f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166122be909392919063ffffffff16565b5f611d788761229c565b90505f8188611d879190612b6a565b9050611df47f00000000000000000000000003b6ed6f17b2c9b15502e7288cd5804062606fb5837f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166123409092919063ffffffff16565b5f5f90505f73ffffffffffffffffffffffffffffffffffffffff167f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc4573ffffffffffffffffffffffffffffffffffffffff1614611eea573073ffffffffffffffffffffffffffffffffffffffff1663cd0821637f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec78c858c8b8b8b6040518863ffffffff1660e01b8152600401611eb097969594939291906131b3565b5f604051808303815f87803b158015611ec7575f5ffd5b505af1925050508015611ed8575060015b611ee4575f9050611ee9565b600190505b5b8015611ef857505050612186565b611f637f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d837f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff1661218f9092919063ffffffff16565b5f600367ffffffffffffffff811115611f7f57611f7e612d1c565b5b604051908082528060200260200182016040528015611fad5781602001602082028036833780820191505090505b5090507f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7815f81518110611fe457611fe3612d49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28160018151811061205357612052612d49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508a816002815181106120a2576120a1612d49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff166338ed1739848a848a8a6040518663ffffffff1660e01b815260040161213d95949392919061308b565b5f604051808303815f875af1158015612158573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906121809190612f8b565b50505050505b50505050505050565b5f8373ffffffffffffffffffffffffffffffffffffffff1663095ea7b384846040516024016121bf929190613288565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905061220d84826123bf565b6122965761228b848573ffffffffffffffffffffffffffffffffffffffff1663095ea7b3865f6040516024016122449291906132e8565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612418565b6122958482612418565b5b50505050565b5f6127106064836122ad919061330f565b6122b7919061337d565b9050919050565b61233a848573ffffffffffffffffffffffffffffffffffffffff166323b872dd8686866040516024016122f3939291906133ad565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612418565b50505050565b6123ba838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401612373929190613288565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612418565b505050565b5f5f5f5f60205f8651602088015f8a5af192503d91505f51905082801561240d57505f82146123f1576001811461240c565b5f8673ffffffffffffffffffffffffffffffffffffffff163b115b5b935050505092915050565b5f5f60205f8451602086015f885af180612437576040513d5f823e3d81fd5b3d92505f519150505f821461245057600181141561246b565b5f8473ffffffffffffffffffffffffffffffffffffffff163b145b156124ad57836040517f5274afe70000000000000000000000000000000000000000000000000000000081526004016124a49190612649565b60405180910390fd5b50505050565b5f604051905090565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6124ed826124c4565b9050919050565b6124fd816124e3565b8114612507575f5ffd5b50565b5f81359050612518816124f4565b92915050565b5f819050919050565b6125308161251e565b811461253a575f5ffd5b50565b5f8135905061254b81612527565b92915050565b5f62ffffff82169050919050565b61256881612551565b8114612572575f5ffd5b50565b5f813590506125838161255f565b92915050565b5f5f5f5f5f5f60c087890312156125a3576125a26124bc565b5b5f6125b089828a0161250a565b96505060206125c189828a0161253d565b95505060406125d289828a0161253d565b94505060606125e389828a01612575565b93505060806125f489828a0161250a565b92505060a061260589828a0161253d565b9150509295509295509295565b61261b8161251e565b82525050565b5f6020820190506126345f830184612612565b92915050565b612643816124e3565b82525050565b5f60208201905061265c5f83018461263a565b92915050565b5f819050919050565b5f61268561268061267b846124c4565b612662565b6124c4565b9050919050565b5f6126968261266b565b9050919050565b5f6126a78261268c565b9050919050565b6126b78161269d565b82525050565b5f6020820190506126d05f8301846126ae565b92915050565b5f5f5f5f5f5f5f60e0888a0312156126f1576126f06124bc565b5b5f6126fe8a828b0161250a565b975050602061270f8a828b0161250a565b96505060406127208a828b0161253d565b95505060606127318a828b0161253d565b94505060806127428a828b01612575565b93505060a06127538a828b0161250a565b92505060c06127648a828b0161253d565b91505092959891949750929550565b5f5f5f5f5f60a0868803121561278c5761278b6124bc565b5b5f6127998882890161250a565b95505060206127aa8882890161253d565b94505060406127bb8882890161253d565b93505060606127cc88828901612575565b92505060806127dd8882890161253d565b9150509295509295909350565b5f5f5f5f5f5f5f60e0888a031215612805576128046124bc565b5b5f6128128a828b0161250a565b97505060206128238a828b0161253d565b96505060406128348a828b0161253d565b95505060606128458a828b0161253d565b94505060806128568a828b01612575565b93505060a06128678a828b0161250a565b92505060c06128788a828b0161253d565b91505092959891949750929550565b5f6128918261268c565b9050919050565b6128a181612887565b82525050565b5f6020820190506128ba5f830184612898565b92915050565b5f82825260208201905092915050565b7f6f6e6c792073656c6600000000000000000000000000000000000000000000005f82015250565b5f6129046009836128c0565b915061290f826128d0565b602082019050919050565b5f6020820190508181035f830152612931816128f8565b9050919050565b612941816124e3565b82525050565b61295081612551565b82525050565b61295f8161251e565b82525050565b61296e816124c4565b82525050565b61010082015f8201516129895f850182612938565b50602082015161299c6020850182612938565b5060408201516129af6040850182612947565b5060608201516129c26060850182612938565b5060808201516129d56080850182612956565b5060a08201516129e860a0850182612956565b5060c08201516129fb60c0850182612956565b5060e0820151612a0e60e0850182612965565b50505050565b5f61010082019050612a285f830184612974565b92915050565b5f81519050612a3c81612527565b92915050565b5f60208284031215612a5757612a566124bc565b5b5f612a6484828501612a2e565b91505092915050565b7f6e6f2045544800000000000000000000000000000000000000000000000000005f82015250565b5f612aa16006836128c0565b9150612aac82612a6d565b602082019050919050565b5f6020820190508181035f830152612ace81612a95565b9050919050565b7f62616420726563697069656e74000000000000000000000000000000000000005f82015250565b5f612b09600d836128c0565b9150612b1482612ad5565b602082019050919050565b5f6020820190508181035f830152612b3681612afd565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f612b748261251e565b9150612b7f8361251e565b9250828203905081811115612b9757612b96612b3d565b5b92915050565b5f81905092915050565b50565b5f612bb55f83612b9d565b9150612bc082612ba7565b5f82019050919050565b5f612bd482612baa565b9150819050919050565b7f6665652073656e64206661696c656400000000000000000000000000000000005f82015250565b5f612c12600f836128c0565b9150612c1d82612bde565b602082019050919050565b5f6020820190508181035f830152612c3f81612c06565b9050919050565b612c4f81612551565b82525050565b5f60c082019050612c685f83018961263a565b612c756020830188612612565b612c826040830187612612565b612c8f6060830186612c46565b612c9c608083018561263a565b612ca960a0830184612612565b979650505050505050565b7f763320736c6970706167650000000000000000000000000000000000000000005f82015250565b5f612ce8600b836128c0565b9150612cf382612cb4565b602082019050919050565b5f6020820190508181035f830152612d1581612cdc565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f612daa8383612938565b60208301905092915050565b5f602082019050919050565b5f612dcc82612d76565b612dd68185612d80565b9350612de183612d90565b805f5b83811015612e11578151612df88882612d9f565b9750612e0383612db6565b925050600181019050612de4565b5085935050505092915050565b5f608082019050612e315f830187612612565b8181036020830152612e438186612dc2565b9050612e52604083018561263a565b612e5f6060830184612612565b95945050505050565b5f5ffd5b5f601f19601f8301169050919050565b612e8582612e6c565b810181811067ffffffffffffffff82111715612ea457612ea3612d1c565b5b80604052505050565b5f612eb66124b3565b9050612ec28282612e7c565b919050565b5f67ffffffffffffffff821115612ee157612ee0612d1c565b5b602082029050602081019050919050565b5f5ffd5b5f612f08612f0384612ec7565b612ead565b90508083825260208201905060208402830185811115612f2b57612f2a612ef2565b5b835b81811015612f545780612f408882612a2e565b845260208401935050602081019050612f2d565b5050509392505050565b5f82601f830112612f7257612f71612e68565b5b8151612f82848260208601612ef6565b91505092915050565b5f60208284031215612fa057612f9f6124bc565b5b5f82015167ffffffffffffffff811115612fbd57612fbc6124c0565b5b612fc984828501612f5e565b91505092915050565b7f6e6f20616d6f756e7400000000000000000000000000000000000000000000005f82015250565b5f6130066009836128c0565b915061301182612fd2565b602082019050919050565b5f6020820190508181035f83015261303381612ffa565b9050919050565b5f60a08201905061304d5f83018861263a565b61305a6020830187612612565b6130676040830186612612565b6130746060830185612c46565b6130816080830184612612565b9695505050505050565b5f60a08201905061309e5f830188612612565b6130ab6020830187612612565b81810360408301526130bd8186612dc2565b90506130cc606083018561263a565b6130d96080830184612612565b9695505050505050565b7f6e6f20455448206f7574000000000000000000000000000000000000000000005f82015250565b5f613117600a836128c0565b9150613122826130e3565b602082019050919050565b5f6020820190508181035f8301526131448161310b565b9050919050565b7f757365722073656e64206661696c6564000000000000000000000000000000005f82015250565b5f61317f6010836128c0565b915061318a8261314b565b602082019050919050565b5f6020820190508181035f8301526131ac81613173565b9050919050565b5f60e0820190506131c65f83018a61263a565b6131d3602083018961263a565b6131e06040830188612612565b6131ed6060830187612612565b6131fa6080830186612c46565b61320760a083018561263a565b61321460c0830184612612565b98975050505050505050565b7f6e6f2055534454206f75740000000000000000000000000000000000000000005f82015250565b5f613254600b836128c0565b915061325f82613220565b602082019050919050565b5f6020820190508181035f83015261328181613248565b9050919050565b5f60408201905061329b5f83018561263a565b6132a86020830184612612565b9392505050565b5f819050919050565b5f6132d26132cd6132c8846132af565b612662565b61251e565b9050919050565b6132e2816132b8565b82525050565b5f6040820190506132fb5f83018561263a565b61330860208301846132d9565b9392505050565b5f6133198261251e565b91506133248361251e565b92508282026133328161251e565b9150828204841483151761334957613348612b3d565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f6133878261251e565b91506133928361251e565b9250826133a2576133a1613350565b5b828204905092915050565b5f6060820190506133c05f83018661263a565b6133cd602083018561263a565b6133da6040830184612612565b94935050505056fea264697066735822122019641cf500f50f694c376cf80de6e1bf85d1cbdc1ac167f9344efcf9b97001b564736f6c634300081f0033

Verified Source Code Full Match

Compiler: v0.8.31+commit.fd3a2265 EVM: osaka Optimization: No
TokenLightRouter.sol 346 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IUniswapV2Router {
    function swapExactETHForTokens(
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable returns (uint256[] memory amounts);

    function swapExactTokensForETH(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);
}

interface IWETH {
    function deposit() external payable;
    function withdraw(uint256) external;
}

interface ISwapRouterV3 {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
}

contract TokenLightRouter {
    using SafeERC20 for IERC20;

    address public immutable collector;
    address public immutable usdt;
    address public immutable weth;
    IUniswapV2Router public immutable v2;
    ISwapRouterV3 public immutable v3;

    uint256 public constant FEE_BPS = 100; // 1%
    uint256 public constant BPS_DENOM = 10_000;

    constructor(
        address collector_,
        address usdt_,
        address weth_,
        address v2Router_,
        address v3Router_
    ) {
        collector = collector_;
        usdt = usdt_;
        weth = weth_;
        v2 = IUniswapV2Router(v2Router_);
        v3 = ISwapRouterV3(v3Router_);
    }

    receive() external payable {}

    function _fee(uint256 amount) internal pure returns (uint256) {
        return (amount * FEE_BPS) / BPS_DENOM;
    }

    function swapEthToTokenWithFallback(
        address tokenOut,
        uint256 amountOutMinV3,
        uint256 amountOutMinV2,
        uint24 v3PoolFee,
        address recipient,
        uint256 deadline
    ) external payable {
        require(msg.value > 0, "no ETH");
        require(recipient != address(0), "bad recipient");

        uint256 feeEth = _fee(msg.value);
        uint256 swapEth = msg.value - feeEth;

        // Fee transfer is atomic with the tx; if swap reverts, this reverts too.
        (bool ok,) = collector.call{value: feeEth}("");
        require(ok, "fee send failed");

        // Try V3 first.
        bool v3Ok = false;
        uint256 amountOut = 0;
        if (address(v3) != address(0)) {
            try this._v3SwapExactETHForTokens(tokenOut, swapEth, amountOutMinV3, v3PoolFee, recipient, deadline) returns (uint256 out) {
                v3Ok = true;
                amountOut = out;
            } catch {
                v3Ok = false;
            }
        }

        if (v3Ok) {
            require(amountOut >= amountOutMinV3, "v3 slippage");
            return;
        }

        address[] memory path = new address[](2);
        path[0] = weth;
        path[1] = tokenOut;

        v2.swapExactETHForTokens{value: swapEth}(amountOutMinV2, path, recipient, deadline);
    }

    function _v3SwapExactETHForTokens(
        address tokenOut,
        uint256 amountInEth,
        uint256 amountOutMin,
        uint24 poolFee,
        address recipient,
        uint256 deadline
    ) external returns (uint256 amountOut) {
        require(msg.sender == address(this), "only self");

        IWETH(weth).deposit{value: amountInEth}();
        IERC20(weth).forceApprove(address(v3), amountInEth);

        ISwapRouterV3.ExactInputSingleParams memory params = ISwapRouterV3.ExactInputSingleParams({
            tokenIn: weth,
            tokenOut: tokenOut,
            fee: poolFee,
            recipient: recipient,
            deadline: deadline,
            amountIn: amountInEth,
            amountOutMinimum: amountOutMin,
            sqrtPriceLimitX96: 0
        });

        amountOut = v3.exactInputSingle(params);
    }

    function swapTokenToEthWithFallback(
        address tokenIn,
        uint256 amountIn,
        uint256 amountOutMinV3,
        uint256 amountOutMinV2,
        uint24 v3PoolFee,
        address recipient,
        uint256 deadline
    ) external {
        require(amountIn > 0, "no amount");
        require(recipient != address(0), "bad recipient");

        IERC20(tokenIn).safeTransferFrom(msg.sender, address(this), amountIn);

        // Try V3 first (token -> WETH), receive WETH in this contract.
        bool v3Ok = false;
        uint256 wethOut = 0;
        if (address(v3) != address(0)) {
            try this._v3SwapExactTokensForWeth(tokenIn, amountIn, amountOutMinV3, v3PoolFee, deadline) returns (uint256 out) {
                v3Ok = true;
                wethOut = out;
            } catch {
                v3Ok = false;
            }
        }

        if (!v3Ok) {
            // V2 fallback (token -> ETH)
            IERC20(tokenIn).forceApprove(address(v2), amountIn);
            address[] memory path = new address[](2);
            path[0] = tokenIn;
            path[1] = weth;

            uint256 balBefore = address(this).balance;
            v2.swapExactTokensForETH(amountIn, amountOutMinV2, path, address(this), deadline);
            uint256 balAfter = address(this).balance;
            wethOut = balAfter > balBefore ? (balAfter - balBefore) : 0;
        } else {
            // unwrap WETH we received
            IWETH(weth).withdraw(wethOut);
        }

        require(wethOut > 0, "no ETH out");

        uint256 feeEth = _fee(wethOut);
        uint256 userEth = wethOut - feeEth;

        (bool okFee,) = collector.call{value: feeEth}("");
        require(okFee, "fee send failed");

        (bool okUser,) = payable(recipient).call{value: userEth}("");
        require(okUser, "user send failed");
    }

    function _v3SwapExactTokensForWeth(
        address tokenIn,
        uint256 amountIn,
        uint256 amountOutMin,
        uint24 poolFee,
        uint256 deadline
    ) external returns (uint256 amountOut) {
        require(msg.sender == address(this), "only self");

        IERC20(tokenIn).forceApprove(address(v3), amountIn);

        ISwapRouterV3.ExactInputSingleParams memory params = ISwapRouterV3.ExactInputSingleParams({
            tokenIn: tokenIn,
            tokenOut: weth,
            fee: poolFee,
            recipient: address(this),
            deadline: deadline,
            amountIn: amountIn,
            amountOutMinimum: amountOutMin,
            sqrtPriceLimitX96: 0
        });

        amountOut = v3.exactInputSingle(params);
    }

    function swapUsdtToTokenWithFallback(
        address tokenOut,
        uint256 amountIn,
        uint256 amountOutMinV3,
        uint256 amountOutMinV2,
        uint24 v3PoolFee,
        address recipient,
        uint256 deadline
    ) external {
        require(amountIn > 0, "no amount");
        require(recipient != address(0), "bad recipient");

        IERC20(usdt).safeTransferFrom(msg.sender, address(this), amountIn);

        uint256 feeUsdt = _fee(amountIn);
        uint256 swapUsdt = amountIn - feeUsdt;

        IERC20(usdt).safeTransfer(collector, feeUsdt);

        bool v3Ok = false;
        if (address(v3) != address(0)) {
            try this._v3SwapExactTokensToToken(usdt, tokenOut, swapUsdt, amountOutMinV3, v3PoolFee, recipient, deadline) {
                v3Ok = true;
            } catch {
                v3Ok = false;
            }
        }

        if (v3Ok) return;

        // V2 fallback via WETH
        IERC20(usdt).forceApprove(address(v2), swapUsdt);
        address[] memory path = new address[](3);
        path[0] = usdt;
        path[1] = weth;
        path[2] = tokenOut;

        v2.swapExactTokensForTokens(swapUsdt, amountOutMinV2, path, recipient, deadline);
    }

    function swapTokenToUsdtWithFallback(
        address tokenIn,
        uint256 amountIn,
        uint256 amountOutMinV3,
        uint256 amountOutMinV2,
        uint24 v3PoolFee,
        address recipient,
        uint256 deadline
    ) external {
        require(amountIn > 0, "no amount");
        require(recipient != address(0), "bad recipient");

        IERC20(tokenIn).safeTransferFrom(msg.sender, address(this), amountIn);

        uint256 usdtBalBefore = IERC20(usdt).balanceOf(address(this));
        uint256 usdtOut = 0;
        bool v3Ok = false;
        if (address(v3) != address(0)) {
            try this._v3SwapExactTokensToToken(tokenIn, usdt, amountIn, amountOutMinV3, v3PoolFee, address(this), deadline) {
                v3Ok = true;
            } catch {
                v3Ok = false;
            }
        }

        if (!v3Ok) {
            IERC20(tokenIn).forceApprove(address(v2), amountIn);
            address[] memory path = new address[](3);
            path[0] = tokenIn;
            path[1] = weth;
            path[2] = usdt;

            v2.swapExactTokensForTokens(amountIn, amountOutMinV2, path, address(this), deadline);
        }

        uint256 usdtBalAfter = IERC20(usdt).balanceOf(address(this));
        usdtOut = usdtBalAfter > usdtBalBefore ? (usdtBalAfter - usdtBalBefore) : 0;


        require(usdtOut > 0, "no USDT out");

        uint256 feeUsdt = _fee(usdtOut);
        uint256 userUsdt = usdtOut - feeUsdt;

        IERC20(usdt).safeTransfer(collector, feeUsdt);
        IERC20(usdt).safeTransfer(recipient, userUsdt);
    }

    function _v3SwapExactTokensToToken(
        address tokenIn,
        address tokenOut,
        uint256 amountIn,
        uint256 amountOutMin,
        uint24 poolFee,
        address recipient,
        uint256 deadline
    ) external {
        require(msg.sender == address(this), "only self");

        IERC20(tokenIn).forceApprove(address(v3), amountIn);

        ISwapRouterV3.ExactInputSingleParams memory params = ISwapRouterV3.ExactInputSingleParams({
            tokenIn: tokenIn,
            tokenOut: tokenOut,
            fee: poolFee,
            recipient: recipient,
            deadline: deadline,
            amountIn: amountIn,
            amountOutMinimum: amountOutMin,
            sqrtPriceLimitX96: 0
        });

        v3.exactInputSingle(params);
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
SafeERC20.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)

pragma solidity >=0.6.2;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)

pragma solidity >=0.4.16;

import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)

pragma solidity >=0.4.16;

import {IERC20} from "../token/ERC20/IERC20.sol";
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Read Contract

BPS_DENOM 0x6637e38c → uint256
FEE_BPS 0xbf333f2c → uint256
collector 0x913e77ad → address
usdt 0x2f48ab7d → address
v2 0xf3acae3a → address
v3 0x6257a38e → address
weth 0x3fc8cef3 → address

Write Contract 7 functions

These functions modify contract state and require a wallet transaction to execute.

_v3SwapExactETHForTokens 0x2b4849c6
address tokenOut
uint256 amountInEth
uint256 amountOutMin
uint24 poolFee
address recipient
uint256 deadline
returns: uint256
_v3SwapExactTokensForWeth 0xd27df1ce
address tokenIn
uint256 amountIn
uint256 amountOutMin
uint24 poolFee
uint256 deadline
returns: uint256
_v3SwapExactTokensToToken 0xcd082163
address tokenIn
address tokenOut
uint256 amountIn
uint256 amountOutMin
uint24 poolFee
address recipient
uint256 deadline
swapEthToTokenWithFallback 0xc2eaf08b
address tokenOut
uint256 amountOutMinV3
uint256 amountOutMinV2
uint24 v3PoolFee
address recipient
uint256 deadline
swapTokenToEthWithFallback 0xd2fefce4
address tokenIn
uint256 amountIn
uint256 amountOutMinV3
uint256 amountOutMinV2
uint24 v3PoolFee
address recipient
uint256 deadline
swapTokenToUsdtWithFallback 0xd9c0d9a2
address tokenIn
uint256 amountIn
uint256 amountOutMinV3
uint256 amountOutMinV2
uint24 v3PoolFee
address recipient
uint256 deadline
swapUsdtToTokenWithFallback 0xffba553e
address tokenOut
uint256 amountIn
uint256 amountOutMinV3
uint256 amountOutMinV2
uint24 v3PoolFee
address recipient
uint256 deadline

Recent Transactions

No transactions found for this address