Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x57539bdCB29700cb7E4399B5423BF3a3E41614bA
Balance 0 ETH
Nonce 1
Code Size 13343 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

13343 bytes
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063715018a61161008c578063e0225b1d11610066578063e0225b1d14610273578063f2fde38b146102a3578063f9a68782146102bf578063fa544161146102ef576100ea565b8063715018a61461022d5780638da5cb5b14610237578063978bbdb914610255576100ea565b806322d46d63116100c857806322d46d631461016d5780633f3ee32a1461019d5780634af2e84c146101cd57806351f3be02146101fd576100ea565b8063078b7089146100ef5780630fb120891461011f57806310a53b9a1461014f575b600080fd5b61010960048036038101906101049190612177565b61031f565b6040516101169190612242565b60405180910390f35b6101396004803603810190610134919061225d565b6106f1565b6040516101469190612242565b60405180910390f35b610157610788565b60405161016491906122ac565b60405180910390f35b610187600480360381019061018291906122c7565b6107ae565b6040516101949190612242565b60405180910390f35b6101b760048036038101906101b29190612327565b6109ea565b6040516101c49190612412565b60405180910390f35b6101e760048036038101906101e29190612327565b610aba565b6040516101f491906122ac565b60405180910390f35b610217600480360381019061021291906122c7565b610aed565b6040516102249190612242565b60405180910390f35b610235610bd7565b005b61023f610beb565b60405161024c91906122ac565b60405180910390f35b61025d610c14565b60405161026a9190612443565b60405180910390f35b61028d600480360381019061028891906122c7565b610c19565b60405161029a9190612242565b60405180910390f35b6102bd60048036038101906102b89190612327565b610c39565b005b6102d960048036038101906102d491906124b4565b610cbc565b6040516102e69190612242565b60405180910390f35b61030960048036038101906103049190612327565b610f86565b60405161031691906122ac565b60405180910390f35b60008086869050905060005b818110156104b75760008888838181106103485761034761255b565b5b905060200201602081019061035d9190612327565b9050600073ffffffffffffffffffffffffffffffffffffffff16600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461042d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610424906125e7565b60405180910390fd5b84600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508160010191505061032b565b5060008585905090506000600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060005b828110156105a05760008888838181106105235761052261255b565b5b90506020020160208101906105389190612327565b905060018360010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555081600101915050610506565b5086868260000191906105b4929190611f5e565b50338160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166384cbf6548c338d60036040518563ffffffff1660e01b815260040161065a949392919061264c565b6020604051808303816000875af1158015610679573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069d91906126a6565b507fdf55e2f259e7a596a5a36280c32afa17b21f69476a35f0b3d43b83f29e1470b6338a8a8a8a8a6040516106d79695949392919061275e565b60405180910390a160019350505050979650505050505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006107b8610ff2565b60008484905090506000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600081600001805490501161084d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161084490612801565b60405180910390fd5b60005b828110156109dc57600087878381811061086d5761086c61255b565b5b90506020020160208101906108829190612327565b9050600073ffffffffffffffffffffffffffffffffffffffff16600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610952576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610949906125e7565b60405180910390fd5b85600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600101915050610850565b506001925050509392505050565b6060600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001805480602002602001604051908101604052809291908181526020018280548015610aae57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610a64575b50505050509050919050565b60016020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000813373ffffffffffffffffffffffffffffffffffffffff16600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb79061286d565b60405180910390fd5b610bcb858585611070565b60019150509392505050565b610bdf610ff2565b610be960006114d1565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600481565b6000610c23610ff2565b610c2e848484611070565b600190509392505050565b610c41610ff2565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610cb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca7906128ff565b60405180910390fd5b610cb9816114d1565b50565b600081600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d829061296b565b60405180910390fd5b6000610d9a8888888888611595565b9050600088889050905060008167ffffffffffffffff811115610dc057610dbf61298b565b5b604051908082528060200260200182016040528015610dee5781602001602082028036833780820191505090505b5090506000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f481e8636040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610e62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8691906129cf565b905060005b83811015610f17576000858281518110610ea857610ea761255b565b5b602002602001015190506000610ee88f8f8f86818110610ecb57610eca61255b565b5b9050602002016020810190610ee09190612327565b848d886117d4565b905080858481518110610efe57610efd61255b565b5b6020026020010181815250508260010192505050610e8b565b503373ffffffffffffffffffffffffffffffffffffffff167f6bc86be19a706517256bb07e4af60af1f455bdfbd25517a9d79d9539eef5d381888d8d8d8d886004604051610f6b9796959493929190612bd3565b60405180910390a26001955050505050509695505050505050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b610ffa61182a565b73ffffffffffffffffffffffffffffffffffffffff16611018610beb565b73ffffffffffffffffffffffffffffffffffffffff161461106e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161106590612c8b565b60405180910390fd5b565b600083839050905060005b8181101561127e5760008585838181106110985761109761255b565b5b90506020020160208101906110ad9190612327565b90508373ffffffffffffffffffffffffffffffffffffffff16600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461117c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117390612cf7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461127257600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555b8160010191505061107b565b506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180548060200260200160405190810160405280929190818152602001828054801561134357602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116112f9575b5050505050905060008151905060005b818110156114155760008382815181106113705761136f61255b565b5b60200260200101519050600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905581600101915050611353565b50600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006114649190611ffe565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055505050505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60606000848490509050600081116115e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115d990612d63565b60405180910390fd5b60008787905067ffffffffffffffff8111156116015761160061298b565b5b60405190808252806020026020018201604052801561162f5781602001602082028036833780820191505090505b50905060005b828110156117c557368787838181106116515761165061255b565b5b905060600201905060008a8a83600001358181106116725761167161255b565b5b90506020020160208101906116879190612327565b9050600082602001602081019061169e9190612327565b90508773ffffffffffffffffffffffffffffffffffffffff16600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461176d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176490612cf7565b60405180910390fd5b60008360400135905061178283833084611832565b50808685600001358151811061179b5761179a61255b565b5b602002602001018181516117af9190612db2565b9150818152505084600101945050505050611635565b50809250505095945050505050565b60008060009050600085111561181d576117ed856118ed565b905061180687878684896118019190612de6565b611910565b600081111561181c5761181b87878584611910565b5b5b8091505095945050505050565b600033905090565b600084600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036118a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161189b90612e8c565b60405180910390fd5b60008311156118e15760008690506118df8686868473ffffffffffffffffffffffffffffffffffffffff16611bbb909392919063ffffffff16565b505b82915050949350505050565b60006103e86004836118ff9190612eac565b6119099190612f1d565b9050919050565b8060008111611954576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194b90612f9a565b60405180910390fd5b83600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036119c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119bb90612e8c565b60405180910390fd5b83600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611a34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a2b9061302c565b60405180910390fd5b600086905060008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611a7491906122ac565b602060405180830381865afa158015611a91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab59190613061565b905085811015611afa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611af1906130da565b60405180910390fd5b8815611b3057611b2b87878473ffffffffffffffffffffffffffffffffffffffff16611c449092919063ffffffff16565b611bb0565b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb88886040518363ffffffff1660e01b8152600401611b6b9291906130fa565b6020604051808303816000875af1158015611b8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bae91906126a6565b505b505050505050505050565b611c3e846323b872dd60e01b858585604051602401611bdc93929190613123565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611cca565b50505050565b611cc58363a9059cbb60e01b8484604051602401611c639291906130fa565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611cca565b505050565b6000611d2c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611d919092919063ffffffff16565b9050600081511115611d8c5780806020019051810190611d4c91906126a6565b611d8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d82906131cc565b60405180910390fd5b5b505050565b6060611da08484600085611da9565b90509392505050565b606082471015611dee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611de59061325e565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051611e1791906132ef565b60006040518083038185875af1925050503d8060008114611e54576040519150601f19603f3d011682016040523d82523d6000602084013e611e59565b606091505b5091509150611e6a87838387611e76565b92505050949350505050565b60608315611ed8576000835103611ed057611e9085611eeb565b611ecf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ec690613352565b60405180910390fd5b5b829050611ee3565b611ee28383611f0e565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115611f215781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5591906133c7565b60405180910390fd5b828054828255906000526020600020908101928215611fed579160200282015b82811115611fec57823573ffffffffffffffffffffffffffffffffffffffff168260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190611f7e565b5b509050611ffa919061201f565b5090565b508054600082559060005260206000209081019061201c919061201f565b50565b5b80821115612038576000816000905550600101612020565b5090565b600080fd5b600080fd5b60008115159050919050565b61205b81612046565b811461206657600080fd5b50565b60008135905061207881612052565b92915050565b6000819050919050565b6120918161207e565b811461209c57600080fd5b50565b6000813590506120ae81612088565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f8401126120d9576120d86120b4565b5b8235905067ffffffffffffffff8111156120f6576120f56120b9565b5b602083019150836020820283011115612112576121116120be565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061214482612119565b9050919050565b61215481612139565b811461215f57600080fd5b50565b6000813590506121718161214b565b92915050565b600080600080600080600060a0888a0312156121965761219561203c565b5b60006121a48a828b01612069565b97505060206121b58a828b0161209f565b965050604088013567ffffffffffffffff8111156121d6576121d5612041565b5b6121e28a828b016120c3565b9550955050606088013567ffffffffffffffff81111561220557612204612041565b5b6122118a828b016120c3565b935093505060806122248a828b01612162565b91505092959891949750929550565b61223c81612046565b82525050565b60006020820190506122576000830184612233565b92915050565b600080604083850312156122745761227361203c565b5b600061228285828601612162565b925050602061229385828601612162565b9150509250929050565b6122a681612139565b82525050565b60006020820190506122c1600083018461229d565b92915050565b6000806000604084860312156122e0576122df61203c565b5b600084013567ffffffffffffffff8111156122fe576122fd612041565b5b61230a868287016120c3565b9350935050602061231d86828701612162565b9150509250925092565b60006020828403121561233d5761233c61203c565b5b600061234b84828501612162565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61238981612139565b82525050565b600061239b8383612380565b60208301905092915050565b6000602082019050919050565b60006123bf82612354565b6123c9818561235f565b93506123d483612370565b8060005b838110156124055781516123ec888261238f565b97506123f7836123a7565b9250506001810190506123d8565b5085935050505092915050565b6000602082019050818103600083015261242c81846123b4565b905092915050565b61243d8161207e565b82525050565b60006020820190506124586000830184612434565b92915050565b60008083601f840112612474576124736120b4565b5b8235905067ffffffffffffffff811115612491576124906120b9565b5b6020830191508360608202830111156124ad576124ac6120be565b5b9250929050565b600080600080600080608087890312156124d1576124d061203c565b5b60006124df89828a01612069565b965050602087013567ffffffffffffffff811115612500576124ff612041565b5b61250c89828a016120c3565b9550955050604087013567ffffffffffffffff81111561252f5761252e612041565b5b61253b89828a0161245e565b9350935050606061254e89828a01612162565b9150509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082825260208201905092915050565b7f4164647265737320686173206265656e20626f756e6400000000000000000000600082015250565b60006125d160168361258a565b91506125dc8261259b565b602082019050919050565b60006020820190508181036000830152612600816125c4565b9050919050565b6000819050919050565b6000819050919050565b600061263661263161262c84612607565b612611565b61207e565b9050919050565b6126468161261b565b82525050565b60006080820190506126616000830187612233565b61266e602083018661229d565b61267b6040830185612434565b612688606083018461263d565b95945050505050565b6000815190506126a081612052565b92915050565b6000602082840312156126bc576126bb61203c565b5b60006126ca84828501612691565b91505092915050565b6000819050919050565b60006126ec6020840184612162565b905092915050565b6000602082019050919050565b600061270d838561235f565b9350612718826126d3565b8060005b858110156127515761272e82846126dd565b612738888261238f565b9750612743836126f4565b92505060018101905061271c565b5085925050509392505050565b6000608082019050612773600083018961229d565b8181036020830152612786818789612701565b9050818103604083015261279b818587612701565b90506127aa606083018461229d565b979650505050505050565b7f637573746f6d657241646472657373206973206572726f720000000000000000600082015250565b60006127eb60188361258a565b91506127f6826127b5565b602082019050919050565b6000602082019050818103600083015261281a816127de565b9050919050565b7f4e6f742061206f776e6572206164647265737300000000000000000000000000600082015250565b600061285760138361258a565b915061286282612821565b602082019050919050565b600060208201905081810360008301526128868161284a565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006128e960268361258a565b91506128f48261288d565b604082019050919050565b60006020820190508181036000830152612918816128dc565b9050919050565b7f4e6f7420612066696e616e6369616c2061646472657373000000000000000000600082015250565b600061295560178361258a565b91506129608261291f565b602082019050919050565b6000602082019050818103600083015261298481612948565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000815190506129c98161214b565b92915050565b6000602082840312156129e5576129e461203c565b5b60006129f3848285016129ba565b91505092915050565b600082825260208201905092915050565b6000819050919050565b6000612a26602084018461209f565b905092915050565b612a378161207e565b82525050565b60608201612a4e6000830183612a17565b612a5b6000850182612a2e565b50612a6960208301836126dd565b612a766020850182612380565b50612a846040830183612a17565b612a916040850182612a2e565b50505050565b6000612aa38383612a3d565b60608301905092915050565b600082905092915050565b6000606082019050919050565b6000612ad383856129fc565b9350612ade82612a0d565b8060005b85811015612b1757612af48284612aaf565b612afe8882612a97565b9750612b0983612aba565b925050600181019050612ae2565b5085925050509392505050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000612b5c8383612a2e565b60208301905092915050565b6000602082019050919050565b6000612b8082612b24565b612b8a8185612b2f565b9350612b9583612b40565b8060005b83811015612bc6578151612bad8882612b50565b9750612bb883612b68565b925050600181019050612b99565b5085935050505092915050565b600060a082019050612be8600083018a61229d565b8181036020830152612bfb81888a612701565b90508181036040830152612c10818688612ac7565b90508181036060830152612c248185612b75565b9050612c336080830184612434565b98975050505050505050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000612c7560208361258a565b9150612c8082612c3f565b602082019050919050565b60006020820190508181036000830152612ca481612c68565b9050919050565b7f72656c6174696f6e73686970206572726f720000000000000000000000000000600082015250565b6000612ce160128361258a565b9150612cec82612cab565b602082019050919050565b60006020820190508181036000830152612d1081612cd4565b9050919050565b7f63757272656e6379206973206e756c6c00000000000000000000000000000000600082015250565b6000612d4d60108361258a565b9150612d5882612d17565b602082019050919050565b60006020820190508181036000830152612d7c81612d40565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000612dbd8261207e565b9150612dc88361207e565b9250828201905080821115612de057612ddf612d83565b5b92915050565b6000612df18261207e565b9150612dfc8361207e565b9250828203905081811115612e1457612e13612d83565b5b92915050565b7f7472616e7366657220746f6b656e20697320746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000612e7660228361258a565b9150612e8182612e1a565b604082019050919050565b60006020820190508181036000830152612ea581612e69565b9050919050565b6000612eb78261207e565b9150612ec28361207e565b9250828202612ed08161207e565b91508282048414831517612ee757612ee6612d83565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000612f288261207e565b9150612f338361207e565b925082612f4357612f42612eee565b5b828204905092915050565b7f616d6f756e74206d7573742062652067726561746572207468616e207a65726f600082015250565b6000612f8460208361258a565b9150612f8f82612f4e565b602082019050919050565b60006020820190508181036000830152612fb381612f77565b9050919050565b7f7769746864726177206164647265737320697320746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061301660248361258a565b915061302182612fba565b604082019050919050565b6000602082019050818103600083015261304581613009565b9050919050565b60008151905061305b81612088565b92915050565b6000602082840312156130775761307661203c565b5b60006130858482850161304c565b91505092915050565b7f496e73756666696369656e742062616c616e6365000000000000000000000000600082015250565b60006130c460148361258a565b91506130cf8261308e565b602082019050919050565b600060208201905081810360008301526130f3816130b7565b9050919050565b600060408201905061310f600083018561229d565b61311c6020830184612434565b9392505050565b6000606082019050613138600083018661229d565b613145602083018561229d565b6131526040830184612434565b949350505050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b60006131b6602a8361258a565b91506131c18261315a565b604082019050919050565b600060208201905081810360008301526131e5816131a9565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b600061324860268361258a565b9150613253826131ec565b604082019050919050565b600060208201905081810360008301526132778161323b565b9050919050565b600081519050919050565b600081905092915050565b60005b838110156132b2578082015181840152602081019050613297565b60008484015250505050565b60006132c98261327e565b6132d38185613289565b93506132e3818560208601613294565b80840191505092915050565b60006132fb82846132be565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b600061333c601d8361258a565b915061334782613306565b602082019050919050565b6000602082019050818103600083015261336b8161332f565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b600061339982613372565b6133a3818561258a565b93506133b3818560208601613294565b6133bc8161337d565b840191505092915050565b600060208201905081810360008301526133e1818461338e565b90509291505056fea26469706673582212206cffe5cde6a07ff8aa6fd01e8eac06602eb5e2a5fccade5d4120975b7a866e9964736f6c63430008110033

Verified Source Code Partial Match

Compiler: v0.8.17+commit.8df45f5f EVM: london Optimization: No
BlockATMCollect.sol 910 lines
// File: contracts/IBlockATMCustomer.sol


pragma solidity >=0.8.0 <=0.8.17;

interface IBlockATMCustomer {
    
    function getOwnerAddressFlag(address ownerAddress) external returns(bool);
}
// File: contracts/IBlockFee.sol


pragma solidity >=0.8.0 <=0.8.17;

interface IBlockFee {

    // Check if the token address is supported as a fee token
    function isSupportedFeeToken(address tokenAddress) external view returns (bool);

    // Check if the token is a stable coin
    function isStableCoin(address tokenAddress) external view returns (bool);

    function subFee(bool safe,address tokenAddress,address from,uint256 amount,uint256 id,uint256 subType) external returns (bool);

    function subFee(bool safe,address from,uint256 id,uint256 subType) external returns (bool);

    function feeReceiverAddress() external returns(address);
}
// File: contracts/BlockUtils.sol


pragma solidity >=0.8.0 <=0.8.17;

contract BlockUtils {


    modifier checkAmount(uint256 amount) {
        require(amount > 0, "amount must be greater than zero");
        _;
    }

    // "transfer token is the zero address"
    modifier checkTokenAddress(address tokenAddress){
        require(tokenAddress != address(0), "transfer token is the zero address");
        _;
    }

    modifier checkWithdrawAddress(address withdrawAddress){
        require(withdrawAddress != address(0), "withdraw address is the zero address");
        _;
    }

    modifier checkAddress(address newAddress){
        require(newAddress != address(0), "address is the zero address");
        _;
    }

}
// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/token/ERC20/IERC20.sol


// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
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 amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` 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 amount
    ) external returns (bool);
}

// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/token/ERC20/extensions/draft-IERC20Permit.sol


// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/utils/Address.sol


// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/token/ERC20/utils/SafeERC20.sol


// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;




/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 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 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

// File: contracts/BlockCommon.sol


pragma solidity >=0.8.0 <=0.8.17;




contract BlockCommon is BlockUtils {

    using SafeERC20 for IERC20;

    function transferFrom(address tokenAddress,address from,address to,uint256 amount) internal checkTokenAddress(tokenAddress) returns(uint256) {
        if (amount > 0){
            IERC20 erc20 = IERC20(tokenAddress);
            erc20.safeTransferFrom(from, to, amount);
        }
        return amount;
    }

    function transferFrom(address tokenAddress,address from,address to) internal checkTokenAddress(tokenAddress) returns(uint256) {
        IERC20 erc20 = IERC20(tokenAddress);
        uint256 beforeAmount = erc20.balanceOf(from);
        return transferFrom(tokenAddress,from,to,beforeAmount);
    }

    function transferCommon(address tokenAddress,address to,uint256 amount) internal checkTokenAddress(tokenAddress) checkAmount(amount) returns(uint256) {
        IERC20 erc20 = IERC20(tokenAddress);
        uint256 beforeAmount = erc20.balanceOf(to);
        erc20.safeTransferFrom(msg.sender, to, amount);
        uint256 afterAmount = erc20.balanceOf(to);
        uint256 finalAmount = afterAmount - beforeAmount;
        require(finalAmount <= amount, "FinalAmount is error");
        return finalAmount;
    }

    function withdrawCommon(bool flag,address tokenAddress,address withdrawAddress,uint256 amount) internal checkAmount(amount) checkTokenAddress(tokenAddress) checkWithdrawAddress(withdrawAddress) {
        IERC20 erc20 = IERC20(tokenAddress);
        uint256 balance = erc20.balanceOf(address(this));
        require(balance >= amount, "Insufficient balance");
        if(flag){
            erc20.safeTransfer(withdrawAddress, amount);
        } else {
            erc20.transfer(withdrawAddress, amount);
        }

    }

}
// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/utils/Context.sol


// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/access/Ownable.sol


// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;


/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// File: contracts/BlockATMCollect.sol


pragma solidity >=0.8.0 <=0.8.17;






contract BlockATMCollect is Ownable,BlockCommon {

    mapping(address=>address) public relationMap;

    mapping(address=>User) private userMap;

    uint256 constant public feeRate = 4;

    address public feeGateway;

    struct User{
       address[] financeList;
       mapping (address=>bool) financeMap;
       address owner;
    }

    struct Trade{
        uint256 index;
        address from;
        uint256 amount;
    }

    constructor(address newFeeGateway){
        feeGateway = newFeeGateway;
    }

    modifier onlyFinancials(address customerAddress){
        require(userMap[customerAddress].financeMap[msg.sender],"Not a financial address");
        _;
    }

    modifier onlyUserOwner(address customerAddress){
        require(userMap[customerAddress].owner == msg.sender,"Not a owner address");
        _;
    }

    event BindingRelationship(address sender,address[] array,address[] newOwnerList,address customerAddress);

    event Collect(address indexed sender,address customerAddress,address[] array,Trade[] trade,uint256[] feeAmount,uint256 feeRate);

    function bindingRelationship(bool safe,uint256 id,address[] calldata array,address[] calldata newOwnerList,address customerAddress) public returns (bool){
        uint256 length = array.length; 
        for (uint256 i = 0; i < length; ) {
            address addr = array[i];
            require(relationMap[addr] == address(0), "Address has been bound");
            relationMap[addr] = customerAddress;
            unchecked { ++i; }
        }
        uint256 oLenth = newOwnerList.length; 
        User storage v = userMap[customerAddress];
        for (uint256 i = 0; i < oLenth; ) {
            address addr = newOwnerList[i];
            v.financeMap[addr] = true;
            unchecked { ++i; }
        }
        v.financeList = newOwnerList;
        v.owner = msg.sender;
        IBlockFee(feeGateway).subFee(safe,msg.sender,id,3);
        emit BindingRelationship(msg.sender,array,newOwnerList,customerAddress);
        return true;
    }

    function addRelationship(address[] calldata array,address customerAddress) onlyOwner() public returns (bool){
        uint256 length = array.length;
        User storage v = userMap[customerAddress];
        require(v.financeList.length > 0,"customerAddress is error");
        for (uint256 i = 0; i < length; ) {
            address addr = array[i];
            require(relationMap[addr] == address(0), "Address has been bound");
            relationMap[addr] = customerAddress;
            unchecked { ++i; }
        }
        return true;
    }

    function recoverRelationship(address[] calldata array,address customerAddress) onlyOwner() public returns (bool){
        deleteRelationshipCommon(array, customerAddress);
        return true;
    }

    function deleteRelationship(address[] calldata array,address customerAddress) onlyUserOwner(customerAddress) public returns (bool){
        deleteRelationshipCommon(array, customerAddress);
        return true;
    }

    function deleteRelationshipCommon(address[] calldata array,address customerAddress) internal {
        uint256 length = array.length; 
        for (uint256 i = 0; i < length; ) {
            address addr = array[i];
            require(relationMap[addr] == customerAddress,"relationship error");
            if (relationMap[addr] != address(0)){
                delete relationMap[addr];
            }
            unchecked { ++i; }
        }
        address[] memory fList = userMap[customerAddress].financeList;
        uint256 oLength = fList.length; 
        for (uint256 i = 0; i < oLength; ) {
            address addr = fList[i];
            delete userMap[customerAddress].financeMap[addr];
            unchecked { ++i; }
        }
        delete userMap[customerAddress].financeList;
        delete userMap[customerAddress].owner;
    }

    function calcFee(uint256 amount) internal pure returns (uint256 feeAmount) {
        return (amount * feeRate) / 1000;
    }

    function transferToken(address[] calldata currency,Trade[] calldata trade,address customerAddress) internal returns(uint256[] memory){
        uint256 length = trade.length;
        require(length > 0,"currency is null");
        uint256[] memory total = new uint256[](currency.length);
        for (uint256 i = 0; i < length; ) {
            Trade calldata t = trade[i];
            address token = currency[t.index];
            address from = t.from;
            require(relationMap[from] == customerAddress,"relationship error");
            uint256 sendAmount = t.amount;
            super.transferFrom(token,from,address(this),sendAmount);
            total[t.index] += sendAmount;
            unchecked { ++i; }
        }
        return total;
    }

    function withdrawToken(bool safe,address currency,uint256 value,address customerAddress,address feeAddrees) internal returns(uint256) {
        uint256 feeAmount = 0;
        if (value > 0){
                feeAmount = calcFee(value);
                super.withdrawCommon(safe, currency, customerAddress, value - feeAmount);
                if (feeAmount > 0){
                    // send fee
                    super.withdrawCommon(safe, currency, feeAddrees, feeAmount);
                }
        }
        return feeAmount;
    }

    function collect(bool safe,address[] calldata currency,Trade[] calldata trade,address customerAddress) onlyFinancials(customerAddress) public returns (bool){
        uint256[] memory total = transferToken(currency,trade,customerAddress);
        uint256 fLength = currency.length;
        uint256[] memory feeArray = new uint256[](fLength);
        address feeAddrees = IBlockFee(feeGateway).feeReceiverAddress();
        for (uint256 i = 0; i < fLength; ){
            uint256 value = total[i];
            uint256 feeAmount = withdrawToken(safe,currency[i],value,customerAddress,feeAddrees);
            feeArray[i] = feeAmount;
            unchecked { ++i; }
            
        }
        emit Collect(msg.sender,customerAddress,currency,trade,feeArray,feeRate);
        return true;
    }

    function getOwnerUserFlag(address customerAddress,address financeAddress) public view returns(bool){
        return userMap[customerAddress].financeMap[financeAddress];
    }

    function getOwnerUserList(address customerAddress) public view returns(address[] memory){
        return userMap[customerAddress].financeList;
    }

    function getOwner(address customerAddress) public view returns(address){
        return userMap[customerAddress].owner;
    }
}

Read Contract

feeGateway 0x10a53b9a → address
feeRate 0x978bbdb9 → uint256
getOwner 0xfa544161 → address
getOwnerUserFlag 0x0fb12089 → bool
getOwnerUserList 0x3f3ee32a → address[]
owner 0x8da5cb5b → address
relationMap 0x4af2e84c → address

Write Contract 7 functions

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

addRelationship 0x22d46d63
address[] array
address customerAddress
returns: bool
bindingRelationship 0x078b7089
bool safe
uint256 id
address[] array
address[] newOwnerList
address customerAddress
returns: bool
collect 0x48a80c76
bool safe
address[] currency
tuple[] trade
address customerAddress
returns: bool
deleteRelationship 0x51f3be02
address[] array
address customerAddress
returns: bool
recoverRelationship 0xe0225b1d
address[] array
address customerAddress
returns: bool
renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address