Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xbc9B096988Db6d4d39B553A3e4B2C4E1bf36d3F2
Balance 0 ETH
Nonce 1
Code Size 19425 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

19425 bytes
0x608060405234801561000f575f5ffd5b506004361061023b575f3560e01c80636491347711610139578063b37b0f4c116100b6578063ebaeb1451161007a578063ebaeb145146106b7578063efac856e146106d5578063f0c923a414610705578063f2fde38b14610735578063f5e68973146107515761023b565b8063b37b0f4c1461060f578063b80278441461062d578063d06942391461064b578063dca31fa014610669578063e1864b5b146106995761023b565b80638456cb59116100fd5780638456cb591461058f578063873673cd146105995780638d497fba146105b75780638da5cb5b146105d5578063a8ace60b146105f35761023b565b806364913477146104d95780636b5adf3b146104f5578063715018a6146105255780637f5627b61461052f57806382c73bdf1461055f5761023b565b80633f4ba83a116101c75780635604a9eb1161018b5780635604a9eb146104215780635c975abb14610451578063604081001461046f578063628eaf471461049f5780636298f259146104bd5761023b565b80633f4ba83a1461036957806342a6a26614610373578063499fc4ff146103a35780634a9fefc7146103c15780634c7203d1146103f15761023b565b8063276010061161020e57806327601006146102c55780632f940c70146102e3578063327a943a146102ff5780633c94bf9b1461032f5780633ec3b2111461034d5761023b565b806307a09b451461023f5780630c18eeab1461025b5780630f8f2e58146102795780631fd1322814610295575b5f5ffd5b610259600480360381019061025491906142c6565b61076f565b005b61026361089f565b6040516102709190614300565b60405180910390f35b610293600480360381019061028e919061434c565b6108c7565b005b6102af60048036038101906102aa91906142c6565b6108ed565b6040516102bc9190614399565b60405180910390f35b6102cd610933565b6040516102da9190614300565b60405180910390f35b6102fd60048036038101906102f8919061434c565b61095b565b005b610319600480360381019061031491906142c6565b610b25565b6040516103269190614399565b60405180910390f35b610337610b6b565b6040516103449190614399565b60405180910390f35b610367600480360381019061036291906143b2565b610b74565b005b61037161128d565b005b61038d600480360381019061038891906143b2565b61129f565b60405161039a91906145ce565b60405180910390f35b6103ab6115ef565b6040516103b89190614399565b60405180910390f35b6103db60048036038101906103d691906142c6565b6115f8565b6040516103e89190614300565b60405180910390f35b61040b600480360381019061040691906142c6565b61165d565b6040516104189190614399565b60405180910390f35b61043b600480360381019061043691906142c6565b6116a3565b6040516104489190614399565b60405180910390f35b6104596116ec565b60405161046691906145fd565b60405180910390f35b610489600480360381019061048491906143b2565b611702565b60405161049691906145ce565b60405180910390f35b6104a7611a52565b6040516104b49190614399565b60405180910390f35b6104d760048036038101906104d29190614616565b611a5e565b005b6104f360048036038101906104ee91906142c6565b611a83565b005b61050f600480360381019061050a91906143b2565b611bb3565b60405161051c91906146e9565b60405180910390f35b61052d611ef4565b005b610549600480360381019061054491906143b2565b611f2f565b6040516105569190614817565b60405180910390f35b610579600480360381019061057491906142c6565b61227f565b60405161058691906145fd565b60405180910390f35b610597612290565b005b6105a16122a2565b6040516105ae9190614300565b60405180910390f35b6105bf6122ca565b6040516105cc9190614399565b60405180910390f35b6105dd6122d6565b6040516105ea9190614300565b60405180910390f35b61060d600480360381019061060891906143b2565b6122fe565b005b610617612a16565b6040516106249190614399565b60405180910390f35b610635612a1e565b6040516106429190614300565b60405180910390f35b610653612a46565b6040516106609190614399565b60405180910390f35b610683600480360381019061067e91906142c6565b612a4f565b6040516106909190614399565b60405180910390f35b6106a1612a98565b6040516106ae9190614399565b60405180910390f35b6106bf612aa2565b6040516106cc9190614399565b60405180910390f35b6106ef60048036038101906106ea91906142c6565b612aae565b6040516106fc9190614399565b60405180910390f35b61071f600480360381019061071a91906142c6565b612af7565b60405161072c9190614399565b60405180910390f35b61074f600480360381019061074a91906142c6565b612b40565b005b610759612bc4565b604051610766919061489d565b60405180910390f35b610777612fb0565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036107dc576040517fe6c4247b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160045f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f0bd95e9875e5a1f5cc8477eaaca6550a66783d42e212fb7741a331797511ae8860405160405180910390a35050565b5f60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6108cf613037565b6108d761307b565b6108e182826130bc565b6108e961373c565b5050565b5f60085f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610963612fb0565b5f820361099c576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610a01576040517fe6c4247b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610a3b9190614300565b602060405180830381865afa158015610a56573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a7a91906148ca565b1015610ab2576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610add33838373ffffffffffffffffffffffffffffffffffffffff166137459092919063ffffffff16565b813373ffffffffffffffffffffffffffffffffffffffff167f5fafa99d0643513820be26656b45130b01e1c03062e1266bf36f88cbd3bd969560405160405180910390a35050565b5f60065f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b5f600754905090565b610b7c613037565b610b8461307b565b60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c0a576040517fea8e4eb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610c6f576040517fe6c4247b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8203610ca8576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8103610ce1576040517fdfa1a40800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62b71b0060065f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20541015610d5b576040517f117b636d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610d668160016137c4565b15610d9d576040517fb1fb6bd000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a0823160045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401610e199190614300565b602060405180830381865afa158015610e34573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e5891906148ca565b90505f60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16306040518363ffffffff1660e01b8152600401610ed89291906148f5565b602060405180830381865afa158015610ef3573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f1791906148ca565b905083821015610f53576040517fc91e29d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83811015610f8d576040517f48afe6cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160155f8581526020019081526020015f205f6101000a81548160ff0219169083151502179055505f601180549050905060116040518060c001604052808873ffffffffffffffffffffffffffffffffffffffff1681526020018781526020014281526020016001151581526020016001808111156110105761100f614463565b5b815260200186815250908060018154018082558091505060019003905f5260205f2090600502015f909190919091505f820151815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010155604082015181600201556060820151816003015f6101000a81548160ff02191690831515021790555060808201518160030160016101000a81548160ff021916908360018111156110e1576110e0614463565b5b021790555060a08201518160040155505060135f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081908060018154018082558091505060019003905f5260205f20015f90919091909150558460095f8873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825461119f9190614949565b9250508190555084600b5f8282546111b79190614949565b9250508190555061122d60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16878760035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661386f909392919063ffffffff16565b83858773ffffffffffffffffffffffffffffffffffffffff167fc1af30fe4cadac62164a69345dcb921d4676a6a794279f7ab612aeff8d9be32d426040516112759190614399565b60405180910390a450505061128861373c565b505050565b611295612fb0565b61129d6138f1565b565b60605f8214806112af5750606482115b156112e6576040517fe5b7db2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60125f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2080548060200260200160405190810160405280929190818152602001828054801561136c57602002820191905f5260205f20905b815481526020019060010190808311611358575b5050505050905080518411156113ae576040517f01da157200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80518403611412575f67ffffffffffffffff8111156113d0576113cf61497c565b5b60405190808252806020026020018201604052801561140957816020015b6113f6614178565b8152602001906001900390816113ee5790505b509150506115e8565b5f838561141f9190614949565b9050815181111561142f57815190505b5f858261143c91906149a9565b67ffffffffffffffff8111156114555761145461497c565b5b60405190808252806020026020018201604052801561148e57816020015b61147b614178565b8152602001906001900390816114735790505b5090505f8690505b828110156115e05760108482815181106114b3576114b26149dc565b5b6020026020010151815481106114cc576114cb6149dc565b5b905f5260205f2090600502016040518060c00160405290815f82015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820154815260200160028201548152602001600382015f9054906101000a900460ff161515151581526020016003820160019054906101000a900460ff16600181111561158a57611589614463565b5b600181111561159c5761159b614463565b5b81526020016004820154815250508288836115b791906149a9565b815181106115c8576115c76149dc565b5b60200260200101819052508080600101915050611496565b508093505050505b9392505050565b5f600b54905090565b5f600c5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b5f60095f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b5f600d5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805490509050919050565b5f600160149054906101000a900460ff16905090565b60605f8214806117125750606482115b15611749576040517fe5b7db2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60135f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208054806020026020016040519081016040528092919081815260200182805480156117cf57602002820191905f5260205f20905b8154815260200190600101908083116117bb575b505050505090508051841115611811576040517f01da157200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80518403611875575f67ffffffffffffffff8111156118335761183261497c565b5b60405190808252806020026020018201604052801561186c57816020015b611859614178565b8152602001906001900390816118515790505b50915050611a4b565b5f83856118829190614949565b9050815181111561189257815190505b5f858261189f91906149a9565b67ffffffffffffffff8111156118b8576118b761497c565b5b6040519080825280602002602001820160405280156118f157816020015b6118de614178565b8152602001906001900390816118d65790505b5090505f8690505b82811015611a43576011848281518110611916576119156149dc565b5b60200260200101518154811061192f5761192e6149dc565b5b905f5260205f2090600502016040518060c00160405290815f82015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820154815260200160028201548152602001600382015f9054906101000a900460ff161515151581526020016003820160019054906101000a900460ff1660018111156119ed576119ec614463565b5b60018111156119ff576119fe614463565b5b8152602001600482015481525050828883611a1a91906149a9565b81518110611a2b57611a2a6149dc565b5b602002602001018190525080806001019150506118f9565b508093505050505b9392505050565b5f601180549050905090565b611a66613037565b611a6e61307b565b611a78815f6130bc565b611a8061373c565b50565b611a8b612fb0565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611af0576040517fe6c4247b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f86e5a79b116b1b58296614b8323eb315c7f0d67c5786fe97e11afc17fcb5b61960405160405180910390a35050565b60605f821480611bc35750606482115b15611bfa576040517fe5b7db2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600d5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2080549050831115611c74576040517f01da157200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600d5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805490508303611d0b575f67ffffffffffffffff811115611cd557611cd461497c565b5b604051908082528060200260200182016040528015611d035781602001602082028036833780820191505090505b509050611eed565b5f8284611d189190614949565b9050600d5f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2080549050811115611da657600d5f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208054905090505b5f8482611db391906149a9565b67ffffffffffffffff811115611dcc57611dcb61497c565b5b604051908082528060200260200182016040528015611dfa5781602001602082028036833780820191505090505b5090505f8590505b82811015611ee657600d5f8873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208181548110611e5957611e586149dc565b5b905f5260205f20015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828783611e8e91906149a9565b81518110611e9f57611e9e6149dc565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508080600101915050611e02565b5080925050505b9392505050565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f2690614a63565b60405180910390fd5b60605f821480611f3f5750606482115b15611f76576040517fe5b7db2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f600f5f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805480602002602001604051908101604052809291908181526020018280548015611ffc57602002820191905f5260205f20905b815481526020019060010190808311611fe8575b50505050509050805184111561203e576040517f01da157200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805184036120a2575f67ffffffffffffffff8111156120605761205f61497c565b5b60405190808252806020026020018201604052801561209957816020015b6120866141d2565b81526020019060019003908161207e5790505b50915050612278565b5f83856120af9190614949565b905081518111156120bf57815190505b5f85826120cc91906149a9565b67ffffffffffffffff8111156120e5576120e461497c565b5b60405190808252806020026020018201604052801561211e57816020015b61210b6141d2565b8152602001906001900390816121035790505b5090505f8690505b8281101561227057600e848281518110612143576121426149dc565b5b60200260200101518154811061215c5761215b6149dc565b5b905f5260205f2090600502016040518060a00160405290815f82015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820154815260200160028201548152602001600382015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160048201548152505082888361224791906149a9565b81518110612258576122576149dc565b5b60200260200101819052508080600101915050612126565b508093505050505b9392505050565b5f61228982613953565b9050919050565b612298612fb0565b6122a06139b0565b565b5f60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b5f601080549050905090565b5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b612306613037565b61230e61307b565b60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612394576040517fea8e4eb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036123f9576040517fe6c4247b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8203612432576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f810361246b576040517fdfa1a40800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62b71b0060065f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205410156124e5576040517f117b636d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6124ef815f6137c4565b15612526576040517fb1fb6bd000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a0823160045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b81526004016125a29190614300565b602060405180830381865afa1580156125bd573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125e191906148ca565b90505f60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16306040518363ffffffff1660e01b81526004016126619291906148f5565b602060405180830381865afa15801561267c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126a091906148ca565b9050838210156126dc576040517fc91e29d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83811015612716576040517f48afe6cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160145f8581526020019081526020015f205f6101000a81548160ff0219169083151502179055505f601080549050905060106040518060c001604052808873ffffffffffffffffffffffffffffffffffffffff1681526020018781526020014281526020016001151581526020015f600181111561279957612798614463565b5b815260200186815250908060018154018082558091505060019003905f5260205f2090600502015f909190919091505f820151815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010155604082015181600201556060820151816003015f6101000a81548160ff02191690831515021790555060808201518160030160016101000a81548160ff0219169083600181111561286a57612869614463565b5b021790555060a08201518160040155505060125f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081908060018154018082558091505060019003905f5260205f20015f90919091909150558460085f8873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546129289190614949565b9250508190555084600a5f8282546129409190614949565b925050819055506129b660045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16878760025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661386f909392919063ffffffff16565b83858773ffffffffffffffffffffffffffffffffffffffff167fc1af30fe4cadac62164a69345dcb921d4676a6a794279f7ab612aeff8d9be32d426040516129fe9190614399565b60405180910390a4505050612a1161373c565b505050565b5f6064905090565b5f60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b5f600a54905090565b5f600f5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805490509050919050565b5f62b71b00905090565b5f600e80549050905090565b5f60125f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805490509050919050565b5f60135f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805490509050919050565b612b48612fb0565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612bb8575f6040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401612baf9190614300565b60405180910390fd5b612bc181613a12565b50565b612bcc614228565b5f73ffffffffffffffffffffffffffffffffffffffff1660045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603612c64576040518060a001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81526020015f81526020015f81526020015f8152509050612fad565b6040518060a0016040528060045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a0823160045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401612d279190614300565b602060405180830381865afa158015612d42573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d6691906148ca565b815260200160025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16306040518363ffffffff1660e01b8152600401612de89291906148f5565b602060405180830381865afa158015612e03573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e2791906148ca565b815260200160035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a0823160045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401612ea79190614300565b602060405180830381865afa158015612ec2573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612ee691906148ca565b815260200160035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16306040518363ffffffff1660e01b8152600401612f689291906148f5565b602060405180830381865afa158015612f83573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612fa791906148ca565b81525090505b90565b612fb8613ad5565b73ffffffffffffffffffffffffffffffffffffffff16612fd66122d6565b73ffffffffffffffffffffffffffffffffffffffff161461303557612ff9613ad5565b6040517f118cdaa700000000000000000000000000000000000000000000000000000000815260040161302c9190614300565b60405180910390fd5b565b60025f5403613072576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f81905550565b6130836116ec565b156130ba576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b5f82036130f5576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f62b71b0090505f81846131099190614aae565b14613140576040517fe20bbb3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6509184e72a000905080841115613184576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f82856131919190614ade565b90505f81036131cc576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614613240576132093385613adc565b61323f576040517fe8cfb27300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b8460025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b815260040161329b9190614300565b602060405180830381865afa1580156132b6573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906132da91906148ca565b1015613312576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8460025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b815260040161336f9291906148f5565b602060405180830381865afa15801561338a573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906133ae91906148ca565b10156133e6576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614613424576134233385613c21565b5b61347233308760025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661386f909392919063ffffffff16565b5f8511156134e8576134e760055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff168660025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166137459092919063ffffffff16565b5b8460065f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546135349190614949565b925050819055508460075f82825461354c9190614949565b925050819055505f600e805490509050600e6040518060a001604052803373ffffffffffffffffffffffffffffffffffffffff1681526020018881526020018481526020018773ffffffffffffffffffffffffffffffffffffffff16815260200142815250908060018154018082558091505060019003905f5260205f2090600502015f909190919091505f820151815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010155604082015181600201556060820151816003015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550608082015181600401555050600f5f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081908060018154018082558091505060019003905f5260205f20015f909190919091505581863373ffffffffffffffffffffffffffffffffffffffff167f6734c21d5f895fa216b4d5cf8fff760f310a48baf827a8b19b81fcd14f819261884260405161372c929190614b0e565b60405180910390a4505050505050565b60015f81905550565b6137bf838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401613778929190614b0e565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613fa0565b505050565b5f5f60018111156137d8576137d7614463565b5b8260018111156137eb576137ea614463565b5b036138155760145f8481526020019081526020015f205f9054906101000a900460ff169050613869565b60018081111561382857613827614463565b5b82600181111561383b5761383a614463565b5b036138655760155f8481526020019081526020015f205f9054906101000a900460ff169050613869565b5f90505b92915050565b6138eb848573ffffffffffffffffffffffffffffffffffffffff166323b872dd8686866040516024016138a493929190614b35565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613fa0565b50505050565b6138f961403b565b5f600160146101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61393c613ad5565b6040516139499190614300565b60405180910390a1565b5f5f62b71b0060646139659190614b6a565b90508060065f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20541015915050919050565b6139b861307b565b60018060146101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586139fb613ad5565b604051613a089190614300565b60405180910390a1565b5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f33905090565b5f5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613b18575f9050613c1b565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613b53575f9050613c1b565b5f73ffffffffffffffffffffffffffffffffffffffff16600c5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614613bea575f9050613c1b565b613bf382613953565b613bff575f9050613c1b565b613c09838361407b565b15613c16575f9050613c1b565b600190505b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603613c86576040517fe6c4247b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603613ceb576040517f55e8f70e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff16600c5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614613dac576040517f9d999f0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613db581613953565b613deb576040517f6110422800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613df5828261407b565b15613e2c576040517fa8c0bcbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600c5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600d5f8273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2082908060018154018082558091505060019003905f5260205f20015f9091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8ceb585bfbbc2a8c702024b1d2f212e7ba1caff58b232f071b023d184997b11160405160405180910390a35050565b5f5f60205f8451602086015f885af180613fbf576040513d5f823e3d81fd5b3d92505f519150505f8214613fd8576001811415613ff3565b5f8473ffffffffffffffffffffffffffffffffffffffff163b145b1561403557836040517f5274afe700000000000000000000000000000000000000000000000000000000815260040161402c9190614300565b60405180910390fd5b50505050565b6140436116ec565b614079576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b5f5f8290505f5f90505b601481101561416c578473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036140cc57600192505050614172565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16031561416c57600c5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691508080600101915050614085565b505f9150505b92915050565b6040518060c001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81526020015f81526020015f151581526020015f60018111156141c6576141c5614463565b5b81526020015f81525090565b6040518060a001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81526020015f81526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81525090565b6040518060a001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81526020015f81526020015f81526020015f81525090565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6142958261426c565b9050919050565b6142a58161428b565b81146142af575f5ffd5b50565b5f813590506142c08161429c565b92915050565b5f602082840312156142db576142da614268565b5b5f6142e8848285016142b2565b91505092915050565b6142fa8161428b565b82525050565b5f6020820190506143135f8301846142f1565b92915050565b5f819050919050565b61432b81614319565b8114614335575f5ffd5b50565b5f8135905061434681614322565b92915050565b5f5f6040838503121561436257614361614268565b5b5f61436f85828601614338565b9250506020614380858286016142b2565b9150509250929050565b61439381614319565b82525050565b5f6020820190506143ac5f83018461438a565b92915050565b5f5f5f606084860312156143c9576143c8614268565b5b5f6143d6868287016142b2565b93505060206143e786828701614338565b92505060406143f886828701614338565b9150509250925092565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b6144348161428b565b82525050565b61444381614319565b82525050565b5f8115159050919050565b61445d81614449565b82525050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b600281106144a1576144a0614463565b5b50565b5f8190506144b182614490565b919050565b5f6144c0826144a4565b9050919050565b6144d0816144b6565b82525050565b60c082015f8201516144ea5f85018261442b565b5060208201516144fd602085018261443a565b506040820151614510604085018261443a565b5060608201516145236060850182614454565b50608082015161453660808501826144c7565b5060a082015161454960a085018261443a565b50505050565b5f61455a83836144d6565b60c08301905092915050565b5f602082019050919050565b5f61457c82614402565b614586818561440c565b93506145918361441c565b805f5b838110156145c15781516145a8888261454f565b97506145b383614566565b925050600181019050614594565b5085935050505092915050565b5f6020820190508181035f8301526145e68184614572565b905092915050565b6145f781614449565b82525050565b5f6020820190506146105f8301846145ee565b92915050565b5f6020828403121561462b5761462a614268565b5b5f61463884828501614338565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f614675838361442b565b60208301905092915050565b5f602082019050919050565b5f61469782614641565b6146a1818561464b565b93506146ac8361465b565b805f5b838110156146dc5781516146c3888261466a565b97506146ce83614681565b9250506001810190506146af565b5085935050505092915050565b5f6020820190508181035f830152614701818461468d565b905092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b60a082015f8201516147465f85018261442b565b506020820151614759602085018261443a565b50604082015161476c604085018261443a565b50606082015161477f606085018261442b565b506080820151614792608085018261443a565b50505050565b5f6147a38383614732565b60a08301905092915050565b5f602082019050919050565b5f6147c582614709565b6147cf8185614713565b93506147da83614723565b805f5b8381101561480a5781516147f18882614798565b97506147fc836147af565b9250506001810190506147dd565b5085935050505092915050565b5f6020820190508181035f83015261482f81846147bb565b905092915050565b60a082015f82015161484b5f85018261442b565b50602082015161485e602085018261443a565b506040820151614871604085018261443a565b506060820151614884606085018261443a565b506080820151614897608085018261443a565b50505050565b5f60a0820190506148b05f830184614837565b92915050565b5f815190506148c481614322565b92915050565b5f602082840312156148df576148de614268565b5b5f6148ec848285016148b6565b91505092915050565b5f6040820190506149085f8301856142f1565b61491560208301846142f1565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61495382614319565b915061495e83614319565b92508282019050808211156149765761497561491c565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f6149b382614319565b91506149be83614319565b92508282039050818111156149d6576149d561491c565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f82825260208201905092915050565b7f52656e6f756e6365206f776e6572736869702069732064697361626c656400005f82015250565b5f614a4d601e83614a09565b9150614a5882614a19565b602082019050919050565b5f6020820190508181035f830152614a7a81614a41565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f614ab882614319565b9150614ac383614319565b925082614ad357614ad2614a81565b5b828206905092915050565b5f614ae882614319565b9150614af383614319565b925082614b0357614b02614a81565b5b828204905092915050565b5f604082019050614b215f8301856142f1565b614b2e602083018461438a565b9392505050565b5f606082019050614b485f8301866142f1565b614b5560208301856142f1565b614b62604083018461438a565b949350505050565b5f614b7482614319565b9150614b7f83614319565b9250828202614b8d81614319565b91508282048414831517614ba457614ba361491c565b5b509291505056fea2646970667358221220fbd222809f60bf1eff715bbdbb90813611f043f5e35177d9b7f9d1627394c46664736f6c634300081e0033

Verified Source Code Full Match

Compiler: v0.8.30+commit.73712a01 EVM: prague Optimization: No
4_power.sol 794 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
 * @title PowerContract
 * @dev Computing power purchase contract with USDT payment, referral system, and wallet allocation
 * @author RWA Contract Team
 */
contract PowerContract is ReentrancyGuard, Ownable, Pausable {
    using SafeERC20 for IERC20;
    
    uint256 private constant MIN_REFERRER_PURCHASE = 100;
    
    uint256 private constant COMPUTING_POWER_PRICE_WITH_DECIMALS = 12 * 10 ** 6;
    
    address private usdtToken;
    address private wbtcToken;
    
    address private financeWallet;
    address private multisigWallet;
    
    struct FinanceWalletInfo {
        address wallet;
        uint256 usdtBalance;
        uint256 usdtAllowance;
        uint256 wbtcBalance;
        uint256 wbtcAllowance;
    }
    
    mapping(address => uint256) private amount;
    
    uint256 private totalPurchaseAmount;
    
    // User withdrawal amount statistics
    mapping(address => uint256) private userUsdtWithdrawalAmount;
    mapping(address => uint256) private userWbtcWithdrawalAmount;
    
    // Global withdrawal amount statistics
    uint256 private totalUsdtWithdrawalAmount;
    uint256 private totalWbtcWithdrawalAmount;
    
    mapping(address => address) private referrer;
    mapping(address => address[]) private referrals;
    
    enum TokenType { USDT, WBTC }
    
    struct PurchaseRecord {
        address user;
        uint256 amount;
        uint256 computingPower;
        address referrer;
        uint256 timestamp;
    }
    
    struct WithdrawalRecord {
        address user;
        uint256 amount;
        uint256 timestamp;
        bool success;
        TokenType tokenType;
        uint256 id;
    }
    
    PurchaseRecord[] private purchaseRecords;
    mapping(address => uint256[]) private userPurchaseHistory;
    
    WithdrawalRecord[] private withdrawalUsdtRecords;
    WithdrawalRecord[] private withdrawalWbtcRecords;
    mapping(address => uint256[]) private userUsdtWithdrawalHistory;
    mapping(address => uint256[]) private userWbtcWithdrawalHistory;
    
    // Mapping for quick checking if ID is already used
    mapping(uint256 => bool) private usedUsdtIds;
    mapping(uint256 => bool) private usedWbtcIds;
    
    
    event MultisigWalletUpdated(address indexed oldWallet, address indexed newWallet);
    
    event ComputingPowerPurchased(
        address indexed user,
        uint256 indexed amount,
        uint256 indexed computingPower,
        address referrer,
        uint256 timestamp
    );
    
    event ReferralBound(address indexed user, address indexed referrer);
    
    event EmergencyWithdraw(address indexed to, uint256 indexed amount);
    
    event FinanceWalletUpdated(address indexed oldWallet, address indexed newWallet);
    
    event PaymentProcessed(address indexed recipient, uint256 indexed amount, uint256 timestamp, uint256 indexed id);
    
    error InvalidAddress();
    error InvalidAmount();
    error InsufficientBalance();
    error InsufficientAllowance();
    error ReferralAlreadyExists();
    error SelfReferral();
    error OnlyIntegerAmount();
    error CircularReferral();
    error InvalidReferrer();
    error ReferralValidationFailed();
    error InvalidPageSize();
    error InvalidOffset();
    error InsufficientFinanceWalletBalance();
    error InsufficientFinanceWalletAllowance();
    error NotAuthorized();
    error RecipientNotPurchased();
    error DuplicateId();
    error InvalidId();
    
    /**
     * @dev Constructor
     * @param _usdtToken USDT token contract address
     * @param _wbtcToken WBTC token contract address
     * @param _multisigWallet Multisig wallet address for receiving funds
     * @param _financeWallet Finance wallet address
     */
    constructor(
        address _usdtToken,
        address _wbtcToken,
        address _multisigWallet,
        address _financeWallet
    ) Ownable(msg.sender) {
        if (_usdtToken == address(0)) revert InvalidAddress();
        if (_wbtcToken == address(0)) revert InvalidAddress();
        if (_multisigWallet == address(0)) revert InvalidAddress();
        if (_financeWallet == address(0)) revert InvalidAddress();
        
        usdtToken = _usdtToken;
        wbtcToken = _wbtcToken;
        multisigWallet = _multisigWallet;
        financeWallet = _financeWallet;
    }
    
    /**
     * @notice Set multisig wallet address
     * @param _multisigWallet Multisig wallet address
     */
    function setMultisigWallet(address _multisigWallet) external onlyOwner {
        if (_multisigWallet == address(0)) revert InvalidAddress();
        
        address oldWallet = multisigWallet;
        multisigWallet = _multisigWallet;
        
        emit MultisigWalletUpdated(oldWallet, _multisigWallet);
    }
    
    /**
     * @notice Set finance wallet address
     * @param _financeWallet Finance wallet address
     */
    function setFinanceWallet(address _financeWallet) external onlyOwner {
        if (_financeWallet == address(0)) revert InvalidAddress();
        
        address oldWallet = financeWallet;
        financeWallet = _financeWallet;
        
        emit FinanceWalletUpdated(oldWallet, _financeWallet);
    }
    
    /**
     * @notice Process USDT payment to a recipient using pre-authorized amount (finance wallet only)
     * @param _recipient Recipient address (must have purchased computing power)
     * @param _amount Amount to transfer (USDT, 6 decimals)
     * @param _id Unique payment ID
     */
    function paymentUsdt(address _recipient, uint256 _amount, uint256 _id) external nonReentrant whenNotPaused {
        if (msg.sender != financeWallet) revert NotAuthorized();
        if (_recipient == address(0)) revert InvalidAddress();
        if (_amount == 0) revert InvalidAmount();
        if (_id == 0) revert InvalidId();
        if (amount[_recipient] < COMPUTING_POWER_PRICE_WITH_DECIMALS) revert RecipientNotPurchased();
        if (_isIdAlreadyUsed(_id, TokenType.USDT)) revert DuplicateId();
        
        // Check finance wallet balance and allowance
        uint256 financeBalance = IERC20(usdtToken).balanceOf(financeWallet);
        uint256 financeAllowance = IERC20(usdtToken).allowance(financeWallet, address(this));
        
        if (financeBalance < _amount) revert InsufficientFinanceWalletBalance();
        if (financeAllowance < _amount) revert InsufficientFinanceWalletAllowance();
        
        // Mark ID as used
        usedUsdtIds[_id] = true;
        
        // Record USDT withdrawal history
        uint256 recordId = withdrawalUsdtRecords.length;
        withdrawalUsdtRecords.push(WithdrawalRecord({
            user: _recipient,
            amount: _amount,
            timestamp: block.timestamp,
            success: true,
            tokenType: TokenType.USDT,
            id: _id
        }));
        userUsdtWithdrawalHistory[_recipient].push(recordId);
        
        // Update user and global USDT withdrawal amounts
        userUsdtWithdrawalAmount[_recipient] += _amount;
        totalUsdtWithdrawalAmount += _amount;
        
        // Perform external call last
        IERC20(usdtToken).safeTransferFrom(financeWallet, _recipient, _amount);
        
        emit PaymentProcessed(_recipient, _amount, block.timestamp, _id);
    }
    
    /**
     * @notice Process WBTC payment to a recipient using pre-authorized amount (finance wallet only)
     * @param _recipient Recipient address (must have purchased computing power)
     * @param _amount Amount to transfer (WBTC, 8 decimals)
     * @param _id Unique payment ID
     */
    function paymentWbtc(address _recipient, uint256 _amount, uint256 _id) external nonReentrant whenNotPaused {
        if (msg.sender != financeWallet) revert NotAuthorized();
        if (_recipient == address(0)) revert InvalidAddress();
        if (_amount == 0) revert InvalidAmount();
        if (_id == 0) revert InvalidId();
        if (amount[_recipient] < COMPUTING_POWER_PRICE_WITH_DECIMALS) revert RecipientNotPurchased();
        if (_isIdAlreadyUsed(_id, TokenType.WBTC)) revert DuplicateId();
        
        // Check finance wallet balance and allowance
        uint256 financeBalance = IERC20(wbtcToken).balanceOf(financeWallet);
        uint256 financeAllowance = IERC20(wbtcToken).allowance(financeWallet, address(this));
        
        if (financeBalance < _amount) revert InsufficientFinanceWalletBalance();
        if (financeAllowance < _amount) revert InsufficientFinanceWalletAllowance();
        
        // Update all state before external call to prevent reentrancy attacks
        // Mark ID as used
        usedWbtcIds[_id] = true;
        
        // Record WBTC withdrawal history
        uint256 recordId = withdrawalWbtcRecords.length;
        withdrawalWbtcRecords.push(WithdrawalRecord({
            user: _recipient,
            amount: _amount,
            timestamp: block.timestamp,
            success: true,
            tokenType: TokenType.WBTC,
            id: _id
        }));
        userWbtcWithdrawalHistory[_recipient].push(recordId);
        
        // Update user and global WBTC withdrawal amounts
        userWbtcWithdrawalAmount[_recipient] += _amount;
        totalWbtcWithdrawalAmount += _amount;
        
        // Perform external call last
        IERC20(wbtcToken).safeTransferFrom(financeWallet, _recipient, _amount);
        
        emit PaymentProcessed(_recipient, _amount, block.timestamp, _id);
    }
    
    /**
     * @notice Purchase computing power with USDT (without referral)
     * @param _amount Purchase amount (USDT, 6 decimals)
     */
    function purchaseComputingPower(uint256 _amount) external nonReentrant whenNotPaused {
        _purchaseComputingPower(_amount, address(0));
    }
    
    /**
     * @notice Purchase computing power with USDT (with referral)
     * @param _amount Purchase amount (USDT, 6 decimals)
     * @param _referrerAddress Referrer address
     */
    function purchaseComputingPower(uint256 _amount, address _referrerAddress) external nonReentrant whenNotPaused {
        _purchaseComputingPower(_amount, _referrerAddress);
    }
    
    /**
     * @dev Internal computing power purchase function
     * @param _amount Purchase amount
     * @param _referrerAddress Referrer address (optional)
     */
    function _purchaseComputingPower(uint256 _amount, address _referrerAddress) internal {
        if (_amount == 0) revert InvalidAmount();
        
        uint256 computingPowerPrice = COMPUTING_POWER_PRICE_WITH_DECIMALS;
        
        if (_amount % computingPowerPrice != 0) revert OnlyIntegerAmount();
        
        uint256 maxPurchaseAmount = 10_000_000 * 10**6;
        if (_amount > maxPurchaseAmount) revert InvalidAmount();
        
        uint256 computingPower = _amount / computingPowerPrice;
        if (computingPower == 0) revert InvalidAmount();
        
        if (_referrerAddress != address(0)) {
            if (!_validateReferrer(msg.sender, _referrerAddress)) {
                revert ReferralValidationFailed();
            }
        }
        
        if (IERC20(usdtToken).balanceOf(msg.sender) < _amount) revert InsufficientBalance();
        if (IERC20(usdtToken).allowance(msg.sender, address(this)) < _amount) revert InsufficientAllowance();
        
        if (_referrerAddress != address(0)) {
            _safeBindReferrer(msg.sender, _referrerAddress);
        }
        
        IERC20(usdtToken).safeTransferFrom(msg.sender, address(this), _amount);
        
        // Transfer funds directly to multisig wallet
        if (_amount > 0) {
            IERC20(usdtToken).safeTransfer(multisigWallet, _amount);
        }
        
        amount[msg.sender] += _amount;
        totalPurchaseAmount += _amount;
        uint256 recordId = purchaseRecords.length;
        purchaseRecords.push(PurchaseRecord({
            user: msg.sender,
            amount: _amount,
            computingPower: computingPower,
            referrer: _referrerAddress,
            timestamp: block.timestamp
        }));
        userPurchaseHistory[msg.sender].push(recordId);
        
        emit ComputingPowerPurchased(msg.sender, _amount, computingPower, _referrerAddress, block.timestamp);
    }
    
    /**
     * @notice Get user's referrer
     * @param _user User address
     * @return Referrer address
     */
    function getReferrer(address _user) external view returns (address) {
        return referrer[_user];
    }
    
    
    /**
     * @notice Get user's referral list with pagination
     * @param _user User address
     * @param _offset Offset
     * @param _limit Limit count
     * @return Referred user address array
     */
    function getReferralsPaginated(address _user, uint256 _offset, uint256 _limit) 
        external view returns (address[] memory) {
        if (_limit == 0 || _limit > 100) revert InvalidPageSize();
        if (_offset > referrals[_user].length) revert InvalidOffset();
        
        if (_offset == referrals[_user].length) {
            return new address[](0);
        }
        
        uint256 end = _offset + _limit;
        if (end > referrals[_user].length) {
            end = referrals[_user].length;
        }
        
        address[] memory result = new address[](end - _offset);
        for (uint256 i = _offset; i < end; i++) {
            result[i - _offset] = referrals[_user][i];
        }
        
        return result;
    }
    
    /**
     * @notice Get total count of user's referral list
     * @param _user User address
     * @return Total count of referred users
     */
    function getReferralsCount(address _user) external view returns (uint256) {
        return referrals[_user].length;
    }
    
    
    /**
     * @notice Check if address can be a referrer
     * @param _referrerAddress Referrer address
     * @return Whether can be a referrer
     */
    function isValidDirectReferrer(address _referrerAddress) external view returns (bool) {
        return _isValidDirectReferrer(_referrerAddress);
    }
    

    
    
    /**
     * @notice Query user purchase history with pagination
     * @param _user User address
     * @param _offset Offset
     * @param _limit Limit count
     * @return Purchase record array
     */
    function getUserPurchaseHistoryPaginated(address _user, uint256 _offset, uint256 _limit) 
        external view returns (PurchaseRecord[] memory) {
        if (_limit == 0 || _limit > 100) revert InvalidPageSize();
        
        uint256[] memory recordIds = userPurchaseHistory[_user];
        if (_offset > recordIds.length) revert InvalidOffset();
        
        if (_offset == recordIds.length) {
            return new PurchaseRecord[](0);
        }
        
        uint256 end = _offset + _limit;
        if (end > recordIds.length) {
            end = recordIds.length;
        }
        
        PurchaseRecord[] memory records = new PurchaseRecord[](end - _offset);
        for (uint256 i = _offset; i < end; i++) {
            records[i - _offset] = purchaseRecords[recordIds[i]];
        }
        
        return records;
    }
    
    /**
     * @notice Get total count of user purchase history
     * @param _user User address
     * @return Total count of purchase records
     */
    function getUserPurchaseHistoryCount(address _user) external view returns (uint256) {
        return userPurchaseHistory[_user].length;
    }
    
    /**
     * @notice Query total purchase record count
     * @return Total record count
     */
    function getTotalPurchaseRecords() external view returns (uint256) {
        return purchaseRecords.length;
    }
    
    /**
     * @notice Get user's total purchase amount
     * @param _user User address
     * @return Total purchase amount
     */
    function getUserAmount(address _user) external view returns (uint256) {
        return amount[_user];
    }
    
    /**
     * @notice Get total purchase amount across all users
     * @return Total purchase amount across the entire network
     */
    function getTotalPurchaseAmount() external view returns (uint256) {
        return totalPurchaseAmount;
    }
    
    /**
     * @notice Query user USDT withdrawal history with pagination
     * @param _user User address
     * @param _offset Offset
     * @param _limit Limit count
     * @return USDT withdrawal record array
     */
    function getUserUsdtWithdrawalHistoryPaginated(address _user, uint256 _offset, uint256 _limit) 
        external view returns (WithdrawalRecord[] memory) {
        if (_limit == 0 || _limit > 100) revert InvalidPageSize();
        
        uint256[] memory recordIds = userUsdtWithdrawalHistory[_user];
        if (_offset > recordIds.length) revert InvalidOffset();
        
        if (_offset == recordIds.length) {
            return new WithdrawalRecord[](0);
        }
        
        uint256 end = _offset + _limit;
        if (end > recordIds.length) {
            end = recordIds.length;
        }
        
        WithdrawalRecord[] memory records = new WithdrawalRecord[](end - _offset);
        for (uint256 i = _offset; i < end; i++) {
            records[i - _offset] = withdrawalUsdtRecords[recordIds[i]];
        }
        
        return records;
    }
    
    /**
     * @notice Query user WBTC withdrawal history with pagination
     * @param _user User address
     * @param _offset Offset
     * @param _limit Limit count
     * @return WBTC withdrawal record array
     */
    function getUserWbtcWithdrawalHistoryPaginated(address _user, uint256 _offset, uint256 _limit) 
        external view returns (WithdrawalRecord[] memory) {
        if (_limit == 0 || _limit > 100) revert InvalidPageSize();
        
        uint256[] memory recordIds = userWbtcWithdrawalHistory[_user];
        if (_offset > recordIds.length) revert InvalidOffset();
        
        if (_offset == recordIds.length) {
            return new WithdrawalRecord[](0);
        }
        
        uint256 end = _offset + _limit;
        if (end > recordIds.length) {
            end = recordIds.length;
        }
        
        WithdrawalRecord[] memory records = new WithdrawalRecord[](end - _offset);
        for (uint256 i = _offset; i < end; i++) {
            records[i - _offset] = withdrawalWbtcRecords[recordIds[i]];
        }
        
        return records;
    }
    
    /**
     * @notice Get total count of user USDT withdrawal history
     * @param _user User address
     * @return Total count of USDT withdrawal records
     */
    function getUserUsdtWithdrawalHistoryCount(address _user) external view returns (uint256) {
        return userUsdtWithdrawalHistory[_user].length;
    }
    
    /**
     * @notice Get total count of user WBTC withdrawal history
     * @param _user User address
     * @return Total count of WBTC withdrawal records
     */
    function getUserWbtcWithdrawalHistoryCount(address _user) external view returns (uint256) {
        return userWbtcWithdrawalHistory[_user].length;
    }
    
    /**
     * @notice Query total USDT withdrawal record count
     * @return Total USDT withdrawal record count
     */
    function getTotalUsdtWithdrawalRecords() external view returns (uint256) {
        return withdrawalUsdtRecords.length;
    }
    
    /**
     * @notice Query total WBTC withdrawal record count
     * @return Total WBTC withdrawal record count
     */
    function getTotalWbtcWithdrawalRecords() external view returns (uint256) {
        return withdrawalWbtcRecords.length;
    }
    
    /**
     * @notice Get user's total USDT withdrawal amount (from stored amount)
     * @param _user User address
     * @return Total USDT withdrawal amount
     */
    function getUserUsdtWithdrawalAmount(address _user) external view returns (uint256) {
        return userUsdtWithdrawalAmount[_user];
    }
    
    /**
     * @notice Get user's total WBTC withdrawal amount (from stored amount)
     * @param _user User address
     * @return Total WBTC withdrawal amount
     */
    function getUserWbtcWithdrawalAmount(address _user) external view returns (uint256) {
        return userWbtcWithdrawalAmount[_user];
    }
    
    /**
     * @notice Get total USDT withdrawal amount across all users (from stored amount)
     * @return Total USDT withdrawal amount
     */
    function getTotalUsdtWithdrawalAmount() external view returns (uint256) {
        return totalUsdtWithdrawalAmount;
    }
    
    /**
     * @notice Get total WBTC withdrawal amount across all users (from stored amount)
     * @return Total WBTC withdrawal amount
     */
    function getTotalWbtcWithdrawalAmount() external view returns (uint256) {
        return totalWbtcWithdrawalAmount;
    }
    
    /**
     * @notice Get multisig wallet address
     * @return Multisig wallet address
     */
    function getMultisigWallet() external view returns (address) {
        return multisigWallet;
    }
    
    /**
     * @notice Emergency pause contract
     */
    function pause() external onlyOwner {
        _pause();
    }
    
    /**
     * @notice Resume contract operation
     */
    function unpause() external onlyOwner {
        _unpause();
    }
    
    /**
     * @notice Emergency withdraw any ERC20 token to owner (admin only)
     * @param _amount Withdrawal amount
     * @param _tokenAddress ERC20 token contract address
     */
    function emergencyWithdraw(uint256 _amount, address _tokenAddress) external onlyOwner {
        if (_amount == 0) revert InvalidAmount();
        if (_tokenAddress == address(0)) revert InvalidAddress();
        
        if (IERC20(_tokenAddress).balanceOf(address(this)) < _amount) revert InsufficientBalance();
        
        IERC20(_tokenAddress).safeTransfer(msg.sender, _amount);
        emit EmergencyWithdraw(msg.sender, _amount);
    }
    
    
    /**
     * @notice Get computing power price with decimals
     * @return Computing power price with decimals
     */
    function getComputingPowerPriceWithDecimals() external pure returns (uint256) {
        return COMPUTING_POWER_PRICE_WITH_DECIMALS;
    }
    
    /**
     * @notice Get minimum purchase amount to become a referrer (computing power units)
     * @return Minimum purchase computing power amount
     */
    function getMinReferrerPurchase() external pure returns (uint256) {
        return MIN_REFERRER_PURCHASE;
    }
    
    /**
     * @notice Get USDT token contract address
     * @return USDT token contract address
     */
    function getUSDTToken() external view returns (address) {
        return usdtToken;
    }
    
    /**
     * @notice Get WBTC token contract address
     * @return WBTC token contract address
     */
    function getWBTCToken() external view returns (address) {
        return wbtcToken;
    }
    
    /**
     * @notice Get finance wallet address
     * @return Finance wallet address
     */
    function getFinanceWallet() external view returns (address) {
        return financeWallet;
    }
    
    /**
     * @notice Get finance wallet information (address, USDT and WBTC balances and allowances)
     * @return Finance wallet information including both USDT and WBTC data
     */
    function getFinanceWalletInfo() external view returns (FinanceWalletInfo memory) {
        if (financeWallet == address(0)) {
            return FinanceWalletInfo({
                wallet: address(0),
                usdtBalance: 0,
                usdtAllowance: 0,
                wbtcBalance: 0,
                wbtcAllowance: 0
            });
        }
        
        return FinanceWalletInfo({
            wallet: financeWallet,
            usdtBalance: IERC20(usdtToken).balanceOf(financeWallet),
            usdtAllowance: IERC20(usdtToken).allowance(financeWallet, address(this)),
            wbtcBalance: IERC20(wbtcToken).balanceOf(financeWallet),
            wbtcAllowance: IERC20(wbtcToken).allowance(financeWallet, address(this))
        });
    }
    
    /**
     * @notice Disabled function - renounceOwnership is not allowed
     * @dev This function is overridden to prevent renouncing ownership
     */
    function renounceOwnership() public pure override {
        revert("Renounce ownership is disabled");
    }    
    
    /**
     * @dev Safe internal referrer binding function, prevents circular binding
     * @param _user User address
     * @param _referrerAddress Referrer address
     */
    function _safeBindReferrer(address _user, address _referrerAddress) internal {
        if (_referrerAddress == address(0)) revert InvalidAddress();
        if (_referrerAddress == _user) revert SelfReferral();
        if (referrer[_user] != address(0)) revert ReferralAlreadyExists();
        
        if (!_isValidDirectReferrer(_referrerAddress)) {
            revert InvalidReferrer();
        }
        
        if (_wouldCreateCircularReferral(_user, _referrerAddress)) {
            revert CircularReferral();
        }
        
        referrer[_user] = _referrerAddress;
        referrals[_referrerAddress].push(_user);
        
        emit ReferralBound(_user, _referrerAddress);
    }
    
    /**
     * @dev Validate referrer relationship
     * @param _user User address
     * @param _referrerAddress Referrer address
     * @return Whether validation passes
     */
    function _validateReferrer(address _user, address _referrerAddress) internal view returns (bool) {
        if (_referrerAddress == address(0)) return false;
        if (_referrerAddress == _user) return false;
        if (referrer[_user] != address(0)) return false;
        
        if (!_isValidDirectReferrer(_referrerAddress)) {
            return false;
        }
        
        if (_wouldCreateCircularReferral(_user, _referrerAddress)) {
            return false;
        }
        
        return true;
    }
    
    /**
     * @dev Check if direct referrer is valid
     * @param _referrerAddress Referrer address
     * @return Whether can be a referrer
     */
    function _isValidDirectReferrer(address _referrerAddress) internal view returns (bool) {
        uint256 minPurchaseAmount = MIN_REFERRER_PURCHASE * COMPUTING_POWER_PRICE_WITH_DECIMALS;
        
        return amount[_referrerAddress] >= minPurchaseAmount;
    }
    
    
    /**
     * @dev Check if would create circular referral relationship
     * @param _user User address
     * @param _referrerAddress Referrer address
     * @return Whether would create circular relationship
     */
    function _wouldCreateCircularReferral(address _user, address _referrerAddress) internal view returns (bool) {
        address current = _referrerAddress;
        
        for (uint256 i = 0; i < 20; i++) {
            if (current == _user) {
                return true;
            }
            if (current == address(0)) {
                break;
            }
            current = referrer[current];
        }
        
        return false;
    }
    
    /**
     * @dev Check if payment ID already exists in withdrawal records for specific token type
     * @param _id Payment ID to check
     * @param _tokenType Token type to check (USDT or WBTC)
     * @return Whether ID already exists for the specified token type
     */
    function _isIdAlreadyUsed(uint256 _id, TokenType _tokenType) internal view returns (bool) {
        if (_tokenType == TokenType.USDT) {
            return usedUsdtIds[_id];
        } else if (_tokenType == TokenType.WBTC) {
            return usedWbtcIds[_id];
        }
        return false;
    }
}

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);
    }
}
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);
}
Pausable.sol 112 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}
ReentrancyGuard.sol 87 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
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

getComputingPowerPriceWithDecimals 0xe1864b5b → uint256
getFinanceWallet 0xb8027844 → address
getFinanceWalletInfo 0xf5e68973 → tuple
getMinReferrerPurchase 0xb37b0f4c → uint256
getMultisigWallet 0x27601006 → address
getReferralsCount 0x5604a9eb → uint256
getReferralsPaginated 0x6b5adf3b → address[]
getReferrer 0x4a9fefc7 → address
getTotalPurchaseAmount 0x3c94bf9b → uint256
getTotalPurchaseRecords 0xebaeb145 → uint256
getTotalUsdtWithdrawalAmount 0xd0694239 → uint256
getTotalUsdtWithdrawalRecords 0x8d497fba → uint256
getTotalWbtcWithdrawalAmount 0x499fc4ff → uint256
getTotalWbtcWithdrawalRecords 0x628eaf47 → uint256
getUSDTToken 0x873673cd → address
getUserAmount 0x327a943a → uint256
getUserPurchaseHistoryCount 0xdca31fa0 → uint256
getUserPurchaseHistoryPaginated 0x7f5627b6 → tuple[]
getUserUsdtWithdrawalAmount 0x1fd13228 → uint256
getUserUsdtWithdrawalHistoryCount 0xefac856e → uint256
getUserUsdtWithdrawalHistoryPaginated 0x42a6a266 → tuple[]
getUserWbtcWithdrawalAmount 0x4c7203d1 → uint256
getUserWbtcWithdrawalHistoryCount 0xf0c923a4 → uint256
getUserWbtcWithdrawalHistoryPaginated 0x60408100 → tuple[]
getWBTCToken 0x0c18eeab → address
isValidDirectReferrer 0x82c73bdf → bool
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
renounceOwnership 0x715018a6

Write Contract 10 functions

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

emergencyWithdraw 0x2f940c70
uint256 _amount
address _tokenAddress
pause 0x8456cb59
No parameters
paymentUsdt 0xa8ace60b
address _recipient
uint256 _amount
uint256 _id
paymentWbtc 0x3ec3b211
address _recipient
uint256 _amount
uint256 _id
purchaseComputingPower 0x0f8f2e58
uint256 _amount
address _referrerAddress
purchaseComputingPower 0x6298f259
uint256 _amount
setFinanceWallet 0x07a09b45
address _financeWallet
setMultisigWallet 0x64913477
address _multisigWallet
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters

Recent Transactions

No transactions found for this address