Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xfc09f2447DC82848c2c40F3E5Ac54C053F3De07F
Balance 0.000000174 ETH
Nonce 1
Code Size 19098 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

19098 bytes
0x60806040526004361061018d5760003560e01c80638ca86294116100d7578063c84aae1711610085578063c84aae1714610582578063d952411f146105c0578063dfb400dc146105f0578063dfcf048d14610619578063e0347e1c14610656578063f2fde38b14610681578063f7641e8f146106aa578063fb7a1892146106d55761018d565b80638ca862941461045b5780638da5cb5b14610484578063a035d4f3146104af578063a67abbca146104da578063af9009e014610505578063b1b91cdd1461052e578063b851d601146105575761018d565b80632057cf5b1161013f5780632057cf5b146102f55780632d80edcc146103205780633ccfd60b1461034b57806340321e5614610376578063576165fc146103b35780636212d33a146103f05780636e6a7f861461041b578063715018a6146104445761018d565b8063016428c6146101925780630414f149146101bd5780630e758d25146101e8578063150b7a02146102255780631525131c1461026257806319ff31b91461028d5780631bd0d5cb146102b8575b600080fd5b34801561019e57600080fd5b506101a7610712565b6040516101b49190613197565b60405180910390f35b3480156101c957600080fd5b506101d2610718565b6040516101df91906131f3565b60405180910390f35b3480156101f457600080fd5b5061020f600480360381019061020a91906133ca565b61073e565b60405161021c9190613468565b60405180910390f35b34801561023157600080fd5b5061024c60048036038101906102479190613550565b6108f7565b604051610259919061360e565b60405180910390f35b34801561026e57600080fd5b5061027761090b565b60405161028491906131f3565b60405180910390f35b34801561029957600080fd5b506102a2610931565b6040516102af91906131f3565b60405180910390f35b3480156102c457600080fd5b506102df60048036038101906102da9190613629565b610957565b6040516102ec9190613197565b60405180910390f35b34801561030157600080fd5b5061030a61096f565b604051610317919061366f565b60405180910390f35b34801561032c57600080fd5b50610335610975565b6040516103429190613468565b60405180910390f35b34801561035757600080fd5b50610360610988565b60405161036d9190613468565b60405180910390f35b34801561038257600080fd5b5061039d600480360381019061039891906136c8565b610cc3565b6040516103aa9190613468565b60405180910390f35b3480156103bf57600080fd5b506103da60048036038101906103d5919061378b565b61121f565b6040516103e79190613468565b60405180910390f35b3480156103fc57600080fd5b50610405611529565b6040516104129190613197565b60405180910390f35b34801561042757600080fd5b50610442600480360381019061043d9190613844565b61152f565b005b34801561045057600080fd5b50610459611628565b005b34801561046757600080fd5b50610482600480360381019061047d9190613844565b61163c565b005b34801561049057600080fd5b50610499611735565b6040516104a691906131f3565b60405180910390f35b3480156104bb57600080fd5b506104c461175e565b6040516104d191906131f3565b60405180910390f35b3480156104e657600080fd5b506104ef611784565b6040516104fc91906131f3565b60405180910390f35b34801561051157600080fd5b5061052c60048036038101906105279190613629565b6117aa565b005b34801561053a57600080fd5b5061055560048036038101906105509190613629565b61187e565b005b34801561056357600080fd5b5061056c611952565b6040516105799190613468565b60405180910390f35b34801561058e57600080fd5b506105a960048036038101906105a49190613629565b611965565b6040516105b7929190613897565b60405180910390f35b6105da60048036038101906105d59190613920565b6119f1565b6040516105e79190613468565b60405180910390f35b3480156105fc57600080fd5b50610617600480360381019061061291906139ba565b6123f3565b005b34801561062557600080fd5b50610640600480360381019061063b9190613a16565b6125a1565b60405161064d9190613197565b60405180910390f35b34801561066257600080fd5b5061066b612763565b60405161067891906131f3565b60405180910390f35b34801561068d57600080fd5b506106a860048036038101906106a39190613629565b612789565b005b3480156106b657600080fd5b506106bf61280c565b6040516106cc91906131f3565b60405180910390f35b3480156106e157600080fd5b506106fc60048036038101906106f79190613629565b612832565b6040516107099190613197565b60405180910390f35b60035481565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e876040518263ffffffff1660e01b81526004016107b29190613197565b602060405180830381865afa1580156107cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f39190613a6b565b73ffffffffffffffffffffffffffffffffffffffff1614610849576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161084090613af5565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630e758d25868686866040518563ffffffff1660e01b81526004016108aa9493929190613b9b565b6020604051808303816000875af11580156108c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ed9190613bfc565b9050949350505050565b600063150b7a0260e01b9050949350505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b6020528060005260406000206000915090505481565b60085481565b600260149054906101000a900460ff1681565b600080600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610b0a5760003373ffffffffffffffffffffffffffffffffffffffff16600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020545a90604051610a3890613c5a565b600060405180830381858888f193505050503d8060008114610a76576040519150601f19603f3d011682016040523d82523d6000602084013e610a7b565b606091505b5050905080610abf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab690613cbb565b60405180910390fd5b6000600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060019150505b6000600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610cc0576000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518363ffffffff1660e01b8152600401610bf0929190613cdb565b6020604051808303816000875af1158015610c0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c339190613bfc565b905080610c75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6c90613d50565b60405180910390fd5b6000600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060019150505b90565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d55576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4c90613dbc565b60405180910390fd5b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610f6d57600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166305ae98226040518163ffffffff1660e01b8152600401602060405180830381865afa158015610df7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1b9190613df1565b9050600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b7f90f126040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610e8757600080fd5b505af1158015610e9b573d6000803e3d6000fd5b5050505060008573ffffffffffffffffffffffffffffffffffffffff16825a90604051610ec790613c5a565b600060405180830381858888f193505050503d8060008114610f05576040519150601f19603f3d011682016040523d82523d6000602084013e610f0a565b606091505b5050905080610f4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4590613e6a565b60405180910390fd5b8160036000828254610f609190613eb9565b9250508190555050611211565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166305ae98226040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffe9190613df1565b9050600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b7f90f126040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561106a57600080fd5b505af115801561107e573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611112576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161110990613f39565b60405180910390fd5b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb87846040518363ffffffff1660e01b8152600401611171929190613fb8565b6020604051808303816000875af1158015611190573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b49190613bfc565b9050806111f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ed9061402d565b60405180910390fd5b81600460008282546112089190613eb9565b92505081905550505b600191505095945050505050565b600061122961284a565b600073f7b8edba6955cd7c58f07328dcb9e7e64a8580d96351e1f796603760646040518363ffffffff1660e01b81526004016112669291906140c3565b602060405180830381865af4158015611283573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112a79190614101565b9050600073f7b8edba6955cd7c58f07328dcb9e7e64a8580d96351e1f796600860646040518363ffffffff1660e01b81526004016112e6929190614169565b602060405180830381865af4158015611303573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113279190614101565b90508085121580156113395750818513155b611378576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136f906141de565b60405180910390fd5b60008073ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff160361145c57600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638e515a0a8a8a8a8a6003546040518663ffffffff1660e01b81526004016114129594939291906141fe565b6020604051808303816000875af1158015611431573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114559190613df1565b9050611507565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638e515a0a8a8a8a8a6004546040518663ffffffff1660e01b81526004016114c19594939291906141fe565b6020604051808303816000875af11580156114e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115049190613df1565b90505b6115118a826128c8565b935061151c85612ee1565b5050509695505050505050565b60045481565b61153761284a565b600a60149054906101000a900460ff1615611587576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157e9061429d565b60405180910390fd5b82600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600a60146101000a81548160ff021916908315150217905550505050565b61163061284a565b61163a600061303c565b565b61164461284a565b600260149054906101000a900460ff1615611694576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161168b9061429d565b60405180910390fd5b82600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600260146101000a81548160ff021916908315150217905550505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461183a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161183190614309565b60405180910390fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461190e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161190590614309565b60405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600a60149054906101000a900460ff1681565b600080600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600c60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205491509150915091565b600080869050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1603611e6f57863414611a6d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6490614375565b60405180910390fd5b600073f7b8edba6955cd7c58f07328dcb9e7e64a8580d963ca0d24bf600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166379ce06776040518163ffffffff1660e01b8152600401602060405180830381865afa158015611af6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1a9190614101565b846040518363ffffffff1660e01b8152600401611b389291906143a4565b602060405180830381865af4158015611b55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b799190614101565b9050600073f7b8edba6955cd7c58f07328dcb9e7e64a8580d963ca0d24bf836008546040518363ffffffff1660e01b8152600401611bb89291906143a4565b602060405180830381865af4158015611bd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bf99190614101565b905060008183611c099190613eb9565b905080600b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611c7c91906143cd565b9250508190555060148787905010611d375781600b6000611ce28a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506000613100565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611d2b91906143cd565b92505081905550611db0565b81600b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611da891906143cd565b925050819055505b6000838b611dbe9190613eb9565b90508060036000828254611dd291906143cd565b92505081905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663cc95d5aa8b6040518263ffffffff1660e01b8152600401611e349190613197565b600060405180830381600087803b158015611e4e57600080fd5b505af1158015611e62573d6000803e3d6000fd5b50505050505050506123e4565b8473ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611eff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ef690613f39565b60405180910390fd5b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd8a308b6040518463ffffffff1660e01b8152600401611f6093929190614423565b6020604051808303816000875af1158015611f7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fa39190613bfc565b905080611fe5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fdc906144a6565b60405180910390fd5b600073f7b8edba6955cd7c58f07328dcb9e7e64a8580d963ca0d24bf600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166379ce06776040518163ffffffff1660e01b8152600401602060405180830381865afa15801561206e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120929190614101565b856040518363ffffffff1660e01b81526004016120b09291906143a4565b602060405180830381865af41580156120cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120f19190614101565b9050600073f7b8edba6955cd7c58f07328dcb9e7e64a8580d963ca0d24bf836008546040518363ffffffff1660e01b81526004016121309291906143a4565b602060405180830381865af415801561214d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121719190614101565b9050600081836121819190613eb9565b905080600c6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121f491906143cd565b92505081905550601488889050106122af5781600c600061225a8b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506000613100565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546122a391906143cd565b92505081905550612328565b81600c6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461232091906143cd565b925050819055505b6000838c6123369190613eb9565b9050806004600082825461234a91906143cd565b92505081905550600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663cc95d5aa8c6040518263ffffffff1660e01b81526004016123ac9190613197565b600060405180830381600087803b1580156123c657600080fd5b505af11580156123da573d6000803e3d6000fd5b5050505050505050505b60019150509695505050505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b815260040161244e9190613197565b602060405180830381865afa15801561246b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248f9190613a6b565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146124fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124f390614512565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dfb400dc83836040518363ffffffff1660e01b8152600401612559929190614532565b6020604051808303816000875af1158015612578573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259c9190613bfc565b505050565b600080600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361260257600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050612628565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690505b60008173ffffffffffffffffffffffffffffffffffffffff1663a87d942c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612675573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126999190613df1565b905080806126a690614562565b91505060005b8581101561275a578273ffffffffffffffffffffffffffffffffffffffff1663559e775b83806126db90614562565b94506040518263ffffffff1660e01b81526004016126f99190613197565b602060405180830381865afa158015612716573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061273a9190613df1565b8461274591906143cd565b9350808061275290614562565b9150506126ac565b50505092915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61279161284a565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612800576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127f79061461c565b60405180910390fd5b6128098161303c565b50565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600c6020528060005260406000206000915090505481565b612852613176565b73ffffffffffffffffffffffffffffffffffffffff16612870611735565b73ffffffffffffffffffffffffffffffffffffffff16146128c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128bd90614688565b60405180910390fd5b565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603612bfa5760008260035461290d9190613eb9565b90506000811115612bf4576000819050600073f7b8edba6955cd7c58f07328dcb9e7e64a8580d963ca0d24bf836008546040518363ffffffff1660e01b815260040161295a9291906143a4565b602060405180830381865af4158015612977573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299b9190614101565b9050600081836129ab9190613eb9565b9050804710156129f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129e7906146f4565b60405180910390fd5b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16825a90604051612a3a90613c5a565b600060405180830381858888f193505050503d8060008114612a78576040519150601f19603f3d011682016040523d82523d6000602084013e612a7d565b606091505b5050905080612ac1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ab890614760565b60405180910390fd5b82471015612b04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612afb906147cc565b60405180910390fd5b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16845a90604051612b4e90613c5a565b600060405180830381858888f193505050503d8060008114612b8c576040519150601f19603f3d011682016040523d82523d6000602084013e612b91565b606091505b5050905080612bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bcc90614838565b60405180910390fd5b8560036000828254612be79190613eb9565b9250508190555050505050505b50612ed7565b600082600454612c0a9190613eb9565b90506000811115612ed5576000819050600073f7b8edba6955cd7c58f07328dcb9e7e64a8580d963ca0d24bf836008546040518363ffffffff1660e01b8152600401612c579291906143a4565b602060405180830381865af4158015612c74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c989190614101565b905060008183612ca89190613eb9565b90506000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff1660e01b8152600401612d2b929190613cdb565b6020604051808303816000875af1158015612d4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6e9190613bfc565b905080612db0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612da7906148a4565b60405180910390fd5b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16866040518363ffffffff1660e01b8152600401612e31929190613cdb565b6020604051808303816000875af1158015612e50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e749190613bfc565b905080612eb6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ead90614910565b60405180910390fd5b8560046000828254612ec89190613eb9565b9250508190555050505050505b505b6001905092915050565b600073f7b8edba6955cd7c58f07328dcb9e7e64a8580d96351e1f796603260646040518363ffffffff1660e01b8152600401612f1e92919061496b565b602060405180830381865af4158015612f3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5f9190614101565b9050600073f7b8edba6955cd7c58f07328dcb9e7e64a8580d96351e1f796600f60646040518363ffffffff1660e01b8152600401612f9e9291906149cf565b602060405180830381865af4158015612fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fdf9190614101565b9050808312158015612ff15750818313155b613030576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613027906141de565b60405180910390fd5b82600881905550505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600060148261310f91906143cd565b83511015613152576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161314990614a44565b60405180910390fd5b60006c01000000000000000000000000836020860101510490508091505092915050565b600033905090565b6000819050919050565b6131918161317e565b82525050565b60006020820190506131ac6000830184613188565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006131dd826131b2565b9050919050565b6131ed816131d2565b82525050565b600060208201905061320860008301846131e4565b92915050565b6000604051905090565b600080fd5b600080fd5b61322b8161317e565b811461323657600080fd5b50565b60008135905061324881613222565b92915050565b6000819050919050565b6132618161324e565b811461326c57600080fd5b50565b60008135905061327e81613258565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6132d78261328e565b810181811067ffffffffffffffff821117156132f6576132f561329f565b5b80604052505050565b600061330961320e565b905061331582826132ce565b919050565b600067ffffffffffffffff8211156133355761333461329f565b5b61333e8261328e565b9050602081019050919050565b82818337600083830152505050565b600061336d6133688461331a565b6132ff565b90508281526020810184848401111561338957613388613289565b5b61339484828561334b565b509392505050565b600082601f8301126133b1576133b0613284565b5b81356133c184826020860161335a565b91505092915050565b600080600080608085870312156133e4576133e3613218565b5b60006133f287828801613239565b94505060206134038782880161326f565b935050604061341487828801613239565b925050606085013567ffffffffffffffff8111156134355761343461321d565b5b6134418782880161339c565b91505092959194509250565b60008115159050919050565b6134628161344d565b82525050565b600060208201905061347d6000830184613459565b92915050565b61348c816131d2565b811461349757600080fd5b50565b6000813590506134a981613483565b92915050565b600067ffffffffffffffff8211156134ca576134c961329f565b5b6134d38261328e565b9050602081019050919050565b60006134f36134ee846134af565b6132ff565b90508281526020810184848401111561350f5761350e613289565b5b61351a84828561334b565b509392505050565b600082601f83011261353757613536613284565b5b81356135478482602086016134e0565b91505092915050565b6000806000806080858703121561356a57613569613218565b5b60006135788782880161349a565b94505060206135898782880161349a565b935050604061359a87828801613239565b925050606085013567ffffffffffffffff8111156135bb576135ba61321d565b5b6135c787828801613522565b91505092959194509250565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b613608816135d3565b82525050565b600060208201905061362360008301846135ff565b92915050565b60006020828403121561363f5761363e613218565b5b600061364d8482850161349a565b91505092915050565b6000819050919050565b61366981613656565b82525050565b60006020820190506136846000830184613660565b92915050565b6000613695826131b2565b9050919050565b6136a58161368a565b81146136b057600080fd5b50565b6000813590506136c28161369c565b92915050565b600080600080600060a086880312156136e4576136e3613218565b5b60006136f288828901613239565b95505060206137038882890161349a565b9450506040613714888289016136b3565b93505060606137258882890161349a565b925050608086013567ffffffffffffffff8111156137465761374561321d565b5b61375288828901613522565b9150509295509295909350565b61376881613656565b811461377357600080fd5b50565b6000813590506137858161375f565b92915050565b60008060008060008060c087890312156137a8576137a7613218565b5b60006137b689828a0161349a565b96505060206137c789828a01613776565b95505060406137d889828a01613776565b94505060606137e989828a01613776565b93505060806137fa89828a01613776565b92505060a061380b89828a01613776565b9150509295509295509295565b6138218161344d565b811461382c57600080fd5b50565b60008135905061383e81613818565b92915050565b60008060006060848603121561385d5761385c613218565b5b600061386b8682870161349a565b935050602061387c8682870161349a565b925050604061388d8682870161382f565b9150509250925092565b60006040820190506138ac6000830185613188565b6138b96020830184613188565b9392505050565b600080fd5b600080fd5b60008083601f8401126138e0576138df613284565b5b8235905067ffffffffffffffff8111156138fd576138fc6138c0565b5b602083019150836001820283011115613919576139186138c5565b5b9250929050565b60008060008060008060a0878903121561393d5761393c613218565b5b600061394b89828a0161349a565b965050602061395c89828a01613239565b955050604061396d89828a01613239565b945050606061397e89828a0161349a565b935050608087013567ffffffffffffffff81111561399f5761399e61321d565b5b6139ab89828a016138ca565b92509250509295509295509295565b600080604083850312156139d1576139d0613218565b5b60006139df85828601613239565b925050602083013567ffffffffffffffff811115613a00576139ff61321d565b5b613a0c8582860161339c565b9150509250929050565b60008060408385031215613a2d57613a2c613218565b5b6000613a3b85828601613239565b9250506020613a4c8582860161349a565b9150509250929050565b600081519050613a6581613483565b92915050565b600060208284031215613a8157613a80613218565b5b6000613a8f84828501613a56565b91505092915050565b600082825260208201905092915050565b7f6e6f7420454554206f776e657200000000000000000000000000000000000000600082015250565b6000613adf600d83613a98565b9150613aea82613aa9565b602082019050919050565b60006020820190508181036000830152613b0e81613ad2565b9050919050565b613b1e8161324e565b82525050565b600081519050919050565b60005b83811015613b4d578082015181840152602081019050613b32565b83811115613b5c576000848401525b50505050565b6000613b6d82613b24565b613b778185613a98565b9350613b87818560208601613b2f565b613b908161328e565b840191505092915050565b6000608082019050613bb06000830187613188565b613bbd6020830186613b15565b613bca6040830185613188565b8181036060830152613bdc8184613b62565b905095945050505050565b600081519050613bf681613818565b92915050565b600060208284031215613c1257613c11613218565b5b6000613c2084828501613be7565b91505092915050565b600081905092915050565b50565b6000613c44600083613c29565b9150613c4f82613c34565b600082019050919050565b6000613c6582613c37565b9150819050919050565b7f4574686572207769746864726177206661696c00000000000000000000000000600082015250565b6000613ca5601383613a98565b9150613cb082613c6f565b602082019050919050565b60006020820190508181036000830152613cd481613c98565b9050919050565b6000604082019050613cf060008301856131e4565b613cfd6020830184613188565b9392505050565b7f4b3231207769746864726177206661696c000000000000000000000000000000600082015250565b6000613d3a601183613a98565b9150613d4582613d04565b602082019050919050565b60006020820190508181036000830152613d6981613d2d565b9050919050565b7f6f6e6c7920454554000000000000000000000000000000000000000000000000600082015250565b6000613da6600883613a98565b9150613db182613d70565b602082019050919050565b60006020820190508181036000830152613dd581613d99565b9050919050565b600081519050613deb81613222565b92915050565b600060208284031215613e0757613e06613218565b5b6000613e1584828501613ddc565b91505092915050565b7f45746820726577617264206661696c0000000000000000000000000000000000600082015250565b6000613e54600f83613a98565b9150613e5f82613e1e565b602082019050919050565b60006020820190508181036000830152613e8381613e47565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613ec48261317e565b9150613ecf8361317e565b925082821015613ee257613ee1613e8a565b5b828203905092915050565b7f6f6e6c79204b3231000000000000000000000000000000000000000000000000600082015250565b6000613f23600883613a98565b9150613f2e82613eed565b602082019050919050565b60006020820190508181036000830152613f5281613f16565b9050919050565b6000819050919050565b6000613f7e613f79613f74846131b2565b613f59565b6131b2565b9050919050565b6000613f9082613f63565b9050919050565b6000613fa282613f85565b9050919050565b613fb281613f97565b82525050565b6000604082019050613fcd6000830185613fa9565b613fda6020830184613188565b9392505050565b7f4b323120726577617264206661696c0000000000000000000000000000000000600082015250565b6000614017600f83613a98565b915061402282613fe1565b602082019050919050565b600060208201905081810360008301526140468161400a565b9050919050565b6000819050919050565b600061407261406d6140688461404d565b613f59565b613656565b9050919050565b61408281614057565b82525050565b6000819050919050565b60006140ad6140a86140a384614088565b613f59565b613656565b9050919050565b6140bd81614092565b82525050565b60006040820190506140d86000830185614079565b6140e560208301846140b4565b9392505050565b6000815190506140fb8161375f565b92915050565b60006020828403121561411757614116613218565b5b6000614125848285016140ec565b91505092915050565b6000819050919050565b600061415361414e6141498461412e565b613f59565b613656565b9050919050565b61416381614138565b82525050565b600060408201905061417e600083018561415a565b61418b60208301846140b4565b9392505050565b7f6f7574206f662072616e67650000000000000000000000000000000000000000600082015250565b60006141c8600c83613a98565b91506141d382614192565b602082019050919050565b600060208201905081810360008301526141f7816141bb565b9050919050565b600060a0820190506142136000830188613660565b6142206020830187613660565b61422d6040830186613660565b61423a6060830185613660565b6142476080830184613188565b9695505050505050565b7f66726f7a656e0000000000000000000000000000000000000000000000000000600082015250565b6000614287600683613a98565b915061429282614251565b602082019050919050565b600060208201905081810360008301526142b68161427a565b9050919050565b7f6e6f742061757468000000000000000000000000000000000000000000000000600082015250565b60006142f3600883613a98565b91506142fe826142bd565b602082019050919050565b60006020820190508181036000830152614322816142e6565b9050919050565b7f77726f6e6720616d6f756e740000000000000000000000000000000000000000600082015250565b600061435f600c83613a98565b915061436a82614329565b602082019050919050565b6000602082019050818103600083015261438e81614352565b9050919050565b61439e81613656565b82525050565b60006040820190506143b96000830185614395565b6143c66020830184614395565b9392505050565b60006143d88261317e565b91506143e38361317e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561441857614417613e8a565b5b828201905092915050565b600060608201905061443860008301866131e4565b61444560208301856131e4565b6144526040830184613188565b949350505050565b7f4b3231206e6f742073656e740000000000000000000000000000000000000000600082015250565b6000614490600c83613a98565b915061449b8261445a565b602082019050919050565b600060208201905081810360008301526144bf81614483565b9050919050565b7f454554206f776e6572206f6e6c79000000000000000000000000000000000000600082015250565b60006144fc600e83613a98565b9150614507826144c6565b602082019050919050565b6000602082019050818103600083015261452b816144ef565b9050919050565b60006040820190506145476000830185613188565b81810360208301526145598184613b62565b90509392505050565b600061456d8261317e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361459f5761459e613e8a565b5b600182019050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614606602683613a98565b9150614611826145aa565b604082019050919050565b60006020820190508181036000830152614635816145f9565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000614672602083613a98565b915061467d8261463c565b602082019050919050565b600060208201905081810360008301526146a181614665565b9050919050565b7f696e737566662062616c20520000000000000000000000000000000000000000600082015250565b60006146de600c83613a98565b91506146e9826146a8565b602082019050919050565b6000602082019050818103600083015261470d816146d1565b9050919050565b7f657468207478206661696c205200000000000000000000000000000000000000600082015250565b600061474a600d83613a98565b915061475582614714565b602082019050919050565b600060208201905081810360008301526147798161473d565b9050919050565b7f696e737566662062616c20470000000000000000000000000000000000000000600082015250565b60006147b6600c83613a98565b91506147c182614780565b602082019050919050565b600060208201905081810360008301526147e5816147a9565b9050919050565b7f657468207478206661696c204700000000000000000000000000000000000000600082015250565b6000614822600d83613a98565b915061482d826147ec565b602082019050919050565b6000602082019050818103600083015261485181614815565b9050919050565b7f6b3231207478206661696c205200000000000000000000000000000000000000600082015250565b600061488e600d83613a98565b915061489982614858565b602082019050919050565b600060208201905081810360008301526148bd81614881565b9050919050565b7f6b3231207478206661696c204700000000000000000000000000000000000000600082015250565b60006148fa600d83613a98565b9150614905826148c4565b602082019050919050565b60006020820190508181036000830152614929816148ed565b9050919050565b6000819050919050565b600061495561495061494b84614930565b613f59565b613656565b9050919050565b6149658161493a565b82525050565b6000604082019050614980600083018561495c565b61498d60208301846140b4565b9392505050565b6000819050919050565b60006149b96149b46149af84614994565b613f59565b613656565b9050919050565b6149c98161499e565b82525050565b60006040820190506149e460008301856149c0565b6149f160208301846140b4565b9392505050565b7f746f416464726573735f6f75744f66426f756e64730000000000000000000000600082015250565b6000614a2e601583613a98565b9150614a39826149f8565b602082019050919050565b60006020820190508181036000830152614a5d81614a21565b905091905056fea264697066735822122097322684ce52b24c3aba124c018f822e1612e6accf89749a977a356c6cf87d8764736f6c634300080e0033

Verified Source Code Partial Match

Compiler: v0.8.14+commit.80d49f37 EVM: london Optimization: No
iGUA.sol 21 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/** @title GUA Interface
  * @author @0xAnimist
  * @notice A collaboration between Cai Guo-Qiang and Kanon
  */
interface iGUA {
  function getData(uint256 _tokenId) external view returns(bytes memory, bytes32 seed, bool queried, string memory encrypted);

  //function getGifs() external view returns(bytes[] memory);

  function tokenAPI(uint256 _tokenId) external view returns(string memory);

  function mint(address _owner, bytes32 _queryhash, uint256 _rand, string memory _encrypted) external returns(uint256 tokenId, bytes32 seed);

  function publishQuery(uint256 _tokenId, string memory _query) external returns (bool published);

  function redeemFortune(uint256 _tokenId, bytes32 _queryhash, uint256 _rand, string memory _encrypted) external returns(bool success);
}//end
BytesLib.sol 526 lines
// SPDX-License-Identifier: Unlicense
/*
 * @title Solidity Bytes Arrays Utils
 * @author Gonçalo Sá <[email protected]>
 *
 * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
 *      The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
 */
pragma solidity >=0.8.0 <0.9.0;


library BytesLib {
    function concat(
        bytes memory _preBytes,
        bytes memory _postBytes
    )
        internal
        pure
        returns (bytes memory)
    {
        bytes memory tempBytes;

        assembly {
            // Get a location of some free memory and store it in tempBytes as
            // Solidity does for memory variables.
            tempBytes := mload(0x40)

            // Store the length of the first bytes array at the beginning of
            // the memory for tempBytes.
            let length := mload(_preBytes)
            mstore(tempBytes, length)

            // Maintain a memory counter for the current write location in the
            // temp bytes array by adding the 32 bytes for the array length to
            // the starting location.
            let mc := add(tempBytes, 0x20)
            // Stop copying when the memory counter reaches the length of the
            // first bytes array.
            let end := add(mc, length)

            for {
                // Initialize a copy counter to the start of the _preBytes data,
                // 32 bytes into its memory.
                let cc := add(_preBytes, 0x20)
            } lt(mc, end) {
                // Increase both counters by 32 bytes each iteration.
                mc := add(mc, 0x20)
                cc := add(cc, 0x20)
            } {
                // Write the _preBytes data into the tempBytes memory 32 bytes
                // at a time.
                mstore(mc, mload(cc))
            }

            // Add the length of _postBytes to the current length of tempBytes
            // and store it as the new length in the first 32 bytes of the
            // tempBytes memory.
            length := mload(_postBytes)
            mstore(tempBytes, add(length, mload(tempBytes)))

            // Move the memory counter back from a multiple of 0x20 to the
            // actual end of the _preBytes data.
            mc := end
            // Stop copying when the memory counter reaches the new combined
            // length of the arrays.
            end := add(mc, length)

            for {
                let cc := add(_postBytes, 0x20)
            } lt(mc, end) {
                mc := add(mc, 0x20)
                cc := add(cc, 0x20)
            } {
                mstore(mc, mload(cc))
            }

            // Update the free-memory pointer by padding our last write location
            // to 32 bytes: add 31 bytes to the end of tempBytes to move to the
            // next 32 byte block, then round down to the nearest multiple of
            // 32. If the sum of the length of the two arrays is zero then add
            // one before rounding down to leave a blank 32 bytes (the length block with 0).
            mstore(0x40, and(
              add(add(end, iszero(add(length, mload(_preBytes)))), 31),
              not(31) // Round down to the nearest 32 bytes.
            ))
        }

        return tempBytes;
    }

    function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {
        assembly {
            // Read the first 32 bytes of _preBytes storage, which is the length
            // of the array. (We don't need to use the offset into the slot
            // because arrays use the entire slot.)
            let fslot := sload(_preBytes.slot)
            // Arrays of 31 bytes or less have an even value in their slot,
            // while longer arrays have an odd value. The actual length is
            // the slot divided by two for odd values, and the lowest order
            // byte divided by two for even values.
            // If the slot is even, bitwise and the slot with 255 and divide by
            // two to get the length. If the slot is odd, bitwise and the slot
            // with -1 and divide by two.
            let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
            let mlength := mload(_postBytes)
            let newlength := add(slength, mlength)
            // slength can contain both the length and contents of the array
            // if length < 32 bytes so let's prepare for that
            // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
            switch add(lt(slength, 32), lt(newlength, 32))
            case 2 {
                // Since the new array still fits in the slot, we just need to
                // update the contents of the slot.
                // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
                sstore(
                    _preBytes.slot,
                    // all the modifications to the slot are inside this
                    // next block
                    add(
                        // we can just add to the slot contents because the
                        // bytes we want to change are the LSBs
                        fslot,
                        add(
                            mul(
                                div(
                                    // load the bytes from memory
                                    mload(add(_postBytes, 0x20)),
                                    // zero all bytes to the right
                                    exp(0x100, sub(32, mlength))
                                ),
                                // and now shift left the number of bytes to
                                // leave space for the length in the slot
                                exp(0x100, sub(32, newlength))
                            ),
                            // increase length by the double of the memory
                            // bytes length
                            mul(mlength, 2)
                        )
                    )
                )
            }
            case 1 {
                // The stored value fits in the slot, but the combined value
                // will exceed it.
                // get the keccak hash to get the contents of the array
                mstore(0x0, _preBytes.slot)
                let sc := add(keccak256(0x0, 0x20), div(slength, 32))

                // save new length
                sstore(_preBytes.slot, add(mul(newlength, 2), 1))

                // The contents of the _postBytes array start 32 bytes into
                // the structure. Our first read should obtain the `submod`
                // bytes that can fit into the unused space in the last word
                // of the stored array. To get this, we read 32 bytes starting
                // from `submod`, so the data we read overlaps with the array
                // contents by `submod` bytes. Masking the lowest-order
                // `submod` bytes allows us to add that value directly to the
                // stored value.

                let submod := sub(32, slength)
                let mc := add(_postBytes, submod)
                let end := add(_postBytes, mlength)
                let mask := sub(exp(0x100, submod), 1)

                sstore(
                    sc,
                    add(
                        and(
                            fslot,
                            0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00
                        ),
                        and(mload(mc), mask)
                    )
                )

                for {
                    mc := add(mc, 0x20)
                    sc := add(sc, 1)
                } lt(mc, end) {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } {
                    sstore(sc, mload(mc))
                }

                mask := exp(0x100, sub(mc, end))

                sstore(sc, mul(div(mload(mc), mask), mask))
            }
            default {
                // get the keccak hash to get the contents of the array
                mstore(0x0, _preBytes.slot)
                // Start copying to the last used word of the stored array.
                let sc := add(keccak256(0x0, 0x20), div(slength, 32))

                // save new length
                sstore(_preBytes.slot, add(mul(newlength, 2), 1))

                // Copy over the first `submod` bytes of the new data as in
                // case 1 above.
                let slengthmod := mod(slength, 32)
                let mlengthmod := mod(mlength, 32)
                let submod := sub(32, slengthmod)
                let mc := add(_postBytes, submod)
                let end := add(_postBytes, mlength)
                let mask := sub(exp(0x100, submod), 1)

                sstore(sc, add(sload(sc), and(mload(mc), mask)))

                for {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } lt(mc, end) {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } {
                    sstore(sc, mload(mc))
                }

                mask := exp(0x100, sub(mc, end))

                sstore(sc, mul(div(mload(mc), mask), mask))
            }
        }
    }

    function slice(
        bytes memory _bytes,
        uint256 _start,
        uint256 _length
    )
        internal
        pure
        returns (bytes memory)
    {
        require(_length + 31 >= _length, "slice_overflow");
        require(_bytes.length >= _start + _length, "slice_outOfBounds");

        bytes memory tempBytes;

        assembly {
            switch iszero(_length)
            case 0 {
                // Get a location of some free memory and store it in tempBytes as
                // Solidity does for memory variables.
                tempBytes := mload(0x40)

                // The first word of the slice result is potentially a partial
                // word read from the original array. To read it, we calculate
                // the length of that partial word and start copying that many
                // bytes into the array. The first word we copy will start with
                // data we don't care about, but the last `lengthmod` bytes will
                // land at the beginning of the contents of the new array. When
                // we're done copying, we overwrite the full first word with
                // the actual length of the slice.
                let lengthmod := and(_length, 31)

                // The multiplication in the next line is necessary
                // because when slicing multiples of 32 bytes (lengthmod == 0)
                // the following copy loop was copying the origin's length
                // and then ending prematurely not copying everything it should.
                let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
                let end := add(mc, _length)

                for {
                    // The multiplication in the next line has the same exact purpose
                    // as the one above.
                    let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
                } lt(mc, end) {
                    mc := add(mc, 0x20)
                    cc := add(cc, 0x20)
                } {
                    mstore(mc, mload(cc))
                }

                mstore(tempBytes, _length)

                //update free-memory pointer
                //allocating the array padded to 32 bytes like the compiler does now
                mstore(0x40, and(add(mc, 31), not(31)))
            }
            //if we want a zero-length slice let's just return a zero-length array
            default {
                tempBytes := mload(0x40)
                //zero out the 32 bytes slice we are about to return
                //we need to do it because Solidity does not garbage collect
                mstore(tempBytes, 0)

                mstore(0x40, add(tempBytes, 0x20))
            }
        }

        return tempBytes;
    }

    function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {
        require(_bytes.length >= _start + 20, "toAddress_outOfBounds");
        address tempAddress;

        assembly {
            tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
        }

        return tempAddress;
    }

    function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {
        require(_bytes.length >= _start + 1 , "toUint8_outOfBounds");
        uint8 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x1), _start))
        }

        return tempUint;
    }

    function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) {
        require(_bytes.length >= _start + 2, "toUint16_outOfBounds");
        uint16 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x2), _start))
        }

        return tempUint;
    }

    function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) {
        require(_bytes.length >= _start + 4, "toUint32_outOfBounds");
        uint32 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x4), _start))
        }

        return tempUint;
    }

    function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) {
        require(_bytes.length >= _start + 8, "toUint64_outOfBounds");
        uint64 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x8), _start))
        }

        return tempUint;
    }

    function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) {
        require(_bytes.length >= _start + 12, "toUint96_outOfBounds");
        uint96 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0xc), _start))
        }

        return tempUint;
    }

    function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) {
        require(_bytes.length >= _start + 16, "toUint128_outOfBounds");
        uint128 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x10), _start))
        }

        return tempUint;
    }

    function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) {
        require(_bytes.length >= _start + 32, "toUint256_outOfBounds");
        uint256 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x20), _start))
        }

        return tempUint;
    }

    function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {
        require(_bytes.length >= _start + 32, "toBytes32_outOfBounds");
        bytes32 tempBytes32;

        assembly {
            tempBytes32 := mload(add(add(_bytes, 0x20), _start))
        }

        return tempBytes32;
    }

    function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {
        bool success = true;

        assembly {
            let length := mload(_preBytes)

            // if lengths don't match the arrays are not equal
            switch eq(length, mload(_postBytes))
            case 1 {
                // cb is a circuit breaker in the for loop since there's
                //  no said feature for inline assembly loops
                // cb = 1 - don't breaker
                // cb = 0 - break
                let cb := 1

                let mc := add(_preBytes, 0x20)
                let end := add(mc, length)

                for {
                    let cc := add(_postBytes, 0x20)
                // the next line is the loop condition:
                // while(uint256(mc < end) + cb == 2)
                } eq(add(lt(mc, end), cb), 2) {
                    mc := add(mc, 0x20)
                    cc := add(cc, 0x20)
                } {
                    // if any of these checks fails then arrays are not equal
                    if iszero(eq(mload(mc), mload(cc))) {
                        // unsuccess:
                        success := 0
                        cb := 0
                    }
                }
            }
            default {
                // unsuccess:
                success := 0
            }
        }

        return success;
    }

    function equalStorage(
        bytes storage _preBytes,
        bytes memory _postBytes
    )
        internal
        view
        returns (bool)
    {
        bool success = true;

        assembly {
            // we know _preBytes_offset is 0
            let fslot := sload(_preBytes.slot)
            // Decode the length of the stored array like in concatStorage().
            let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
            let mlength := mload(_postBytes)

            // if lengths don't match the arrays are not equal
            switch eq(slength, mlength)
            case 1 {
                // slength can contain both the length and contents of the array
                // if length < 32 bytes so let's prepare for that
                // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
                if iszero(iszero(slength)) {
                    switch lt(slength, 32)
                    case 1 {
                        // blank the last byte which is the length
                        fslot := mul(div(fslot, 0x100), 0x100)

                        if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
                            // unsuccess:
                            success := 0
                        }
                    }
                    default {
                        // cb is a circuit breaker in the for loop since there's
                        //  no said feature for inline assembly loops
                        // cb = 1 - don't breaker
                        // cb = 0 - break
                        let cb := 1

                        // get the keccak hash to get the contents of the array
                        mstore(0x0, _preBytes.slot)
                        let sc := keccak256(0x0, 0x20)

                        let mc := add(_postBytes, 0x20)
                        let end := add(mc, mlength)

                        // the next line is the loop condition:
                        // while(uint256(mc < end) + cb == 2)
                        for {} eq(add(lt(mc, end), cb), 2) {
                            sc := add(sc, 1)
                            mc := add(mc, 0x20)
                        } {
                            if iszero(eq(sload(sc), mload(mc))) {
                                // unsuccess:
                                success := 0
                                cb := 0
                            }
                        }
                    }
                }
            }
            default {
                // unsuccess:
                success := 0
            }
        }

        return success;
    }


    function toHex(bytes memory buffer) public pure returns (string memory) {

        // Fixed buffer size for hexadecimal convertion
        bytes memory converted = new bytes(buffer.length * 2);

        bytes memory _base = "0123456789abcdef";

        for (uint256 i = 0; i < buffer.length; i++) {
            converted[i * 2] = _base[uint8(buffer[i]) / _base.length];
            converted[i * 2 + 1] = _base[uint8(buffer[i]) % _base.length];
        }

        return string(abi.encodePacked("0x", converted));
    }
}
BondingCurve.sol 302 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import "./BytesLib.sol";
import "./SignedWadMath.sol";
import "./iGUA.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";




interface iCurve {
  function getFee(bytes32[] memory _queryhash) external view returns (uint256 fee);
  function getNextMintPrice() external view returns(uint256 price);
  function getNextBurnPrice() external view returns(uint256 price);
  function getCount() external view returns(uint256);
  function getMintPrice(uint256 _x) external view returns(uint256 price);
  function getPosFeePercent18() external view returns(int256);
  function resetCurve(int256 k18_, int256 L18_, int256 b18_, int256 posFeePercent18_, uint256 _reserveBalance) external returns(uint256 newReserve);
  function incrementCount(uint256 _amount) external;
  function decrementCount() external;
  function getNextBurnReward() external view returns(uint256 reward);
}

/** @title BondingCurve Contract
  * @author @0xAnimist
  * @notice First Onchain GIF, collaboration between Cai Guo-Qiang and Kanon
  */
contract BondingCurve is ERC721Holder, Ownable {
  address public _guaContract;
  address public _eetContract;
  bool public _frozen;

  uint256 public _ethReserveBalance;
  uint256 public _k21ReserveBalance;

  address public _k21TokenAddress;

  address public _royaltyRecipient;
  address public _guardians;

  int256 public _posFeeSplitForReferrers18;//% in wad of referrers share of POS

  address public _ethCurve;
  address public _k21Curve;

  bool public _freezeCurves;

  mapping(address => uint256) public _ethPOSBalances;
  mapping(address => uint256) public _k21POSBalances;


  constructor(address ethCurve_, address k21Curve_, address k21TokenAddress_, address initialRecipient_) Ownable(){
    _ethCurve = ethCurve_;
    _k21Curve = k21Curve_;
    _royaltyRecipient = initialRecipient_;
    _guardians = initialRecipient_;
    _k21TokenAddress = k21TokenAddress_;

    _posFeeSplitForReferrers18 = SignedWadMath.wadDiv(15, 100);//0.15 (15%)
  }

  function _setPOSFeeSplit(int256 posFeeSplitForReferrers18_) internal {
    int256 rangeTop = SignedWadMath.wadDiv(50, 100);
    int256 rangeBottom = SignedWadMath.wadDiv(15, 100);
    require(posFeeSplitForReferrers18_ >= rangeBottom && posFeeSplitForReferrers18_ <= rangeTop, "out of range");

    _posFeeSplitForReferrers18 = posFeeSplitForReferrers18_;
  }

  function pay(address _payee, uint256 _amount, uint256 _tokenCount, address _currency, bytes calldata _mintPayload) external payable returns(bool success) {
    int256 amount = int256(_amount);

    if(_currency == address(0)){//ETH
      require(msg.value == _amount, "wrong amount");

      int256 posFee18 = SignedWadMath.wadMul(iCurve(_ethCurve).getPosFeePercent18(), amount);

      //calculate fee split
      uint256 referrerShareOfPOS = uint256(SignedWadMath.wadMul(posFee18, _posFeeSplitForReferrers18));

      uint256 royaltyRecipientShareOfPOS = uint256(posFee18) - referrerShareOfPOS;

      //_royaltyRecipient credited with half POS fee
      _ethPOSBalances[_royaltyRecipient] += royaltyRecipientShareOfPOS;

      //referrer credited with half POS fee (or guardians if no referrer)
      if(_mintPayload.length >= 20){//there is a referrer
        _ethPOSBalances[BytesLib.toAddress(_mintPayload, 0)] += referrerShareOfPOS;
      }else{//no referrer
        _ethPOSBalances[_guardians] += referrerShareOfPOS;
      }

      uint256 reserve = _amount - uint256(posFee18);

      _ethReserveBalance += reserve;

      iCurve(_ethCurve).incrementCount(_tokenCount);
    }else{//K21
      require(_k21TokenAddress == _currency, "only K21");
      bool sent = IERC20(_k21TokenAddress).transferFrom(_payee, address(this), _amount);
      require(sent, "K21 not sent");

      int256 posFee18 = SignedWadMath.wadMul(iCurve(_k21Curve).getPosFeePercent18(), amount);


      //calculate fee split
      uint256 referrerShareOfPOS = uint256(SignedWadMath.wadMul(posFee18, _posFeeSplitForReferrers18));

      uint256 royaltyRecipientShareOfPOS = uint256(posFee18) - referrerShareOfPOS;

      //_royaltyRecipient credited with half POS fee
      _k21POSBalances[_royaltyRecipient] += royaltyRecipientShareOfPOS;

      //referrer credited with half POS fee (or guardians if no referrer)
      if(_mintPayload.length >= 20){//there is a referrer
        _k21POSBalances[BytesLib.toAddress(_mintPayload, 0)] += referrerShareOfPOS;
      }else{//no referrer
        _k21POSBalances[_guardians] += referrerShareOfPOS;
      }

      uint256 reserve = _amount - uint256(posFee18);

      _k21ReserveBalance += reserve;

      iCurve(_k21Curve).incrementCount(_tokenCount);
    }

    success = true;
  }

  function resetCurve(address _currency, int256 k18_, int256 L18_, int256 b18_, int256 posFeePercent18_, int256 posFeeSplitForReferrers18_) external onlyOwner returns(bool success){
    int256 rangeTop = SignedWadMath.wadDiv(55, 100);
    int256 rangeBottom = SignedWadMath.wadDiv(8, 100);
    require(posFeePercent18_ >= rangeBottom && posFeePercent18_ <= rangeTop, "out of range");


    uint256 newReserve;
    if(_currency == address(0)){//EthCurve
      newReserve = iCurve(_ethCurve).resetCurve(k18_, L18_, b18_, posFeePercent18_, _ethReserveBalance);
    }else{//K21Curve
      newReserve = iCurve(_k21Curve).resetCurve(k18_, L18_, b18_, posFeePercent18_, _k21ReserveBalance);
    }

    success = _flush(_currency, newReserve);

    //update fee split for referrer
    _setPOSFeeSplit(posFeeSplitForReferrers18_);
  }

  function _flush(address _currency, uint256 _reserve) internal returns(bool success){
    if(_currency == address(0)){//EthCurve
      uint256 ethRelease = _ethReserveBalance - _reserve;
      if(ethRelease > 0){
        int256 ethRelease18 = int256(ethRelease);

        //calculate flush split
        uint256 guardiansShareOfFlush = uint256(SignedWadMath.wadMul(ethRelease18, _posFeeSplitForReferrers18));

        uint256 royaltyRecipientShareOfFlush = uint256(ethRelease18) - guardiansShareOfFlush;

        require(address(this).balance >= royaltyRecipientShareOfFlush, "insuff bal R");

        (bool sent1,) = _royaltyRecipient.call{value: royaltyRecipientShareOfFlush, gas: gasleft()}("");
        require(sent1, "eth tx fail R");

        require(address(this).balance >= guardiansShareOfFlush, "insuff bal G");
        (bool sent2,) = _guardians.call{value: guardiansShareOfFlush, gas: gasleft()}("");
        require(sent2, "eth tx fail G");

        _ethReserveBalance -= ethRelease;//== _reserve
      }
    }else{//K21Curve
      uint256 k21Release = _k21ReserveBalance - _reserve;
      if(k21Release > 0){
        int256 k21Release18 = int256(k21Release);

        //calculate flush split
        uint256 guardiansShareOfFlush = uint256(SignedWadMath.wadMul(k21Release18, _posFeeSplitForReferrers18));

        uint256 royaltyRecipientShareOfFlush = uint256(k21Release18) - guardiansShareOfFlush;

        bool sent1 = IERC20(_k21TokenAddress).transfer(_royaltyRecipient, royaltyRecipientShareOfFlush);
        require(sent1, "k21 tx fail R");
        bool sent2 = IERC20(_k21TokenAddress).transfer(_guardians, guardiansShareOfFlush);
        require(sent2, "k21 tx fail G");

        _k21ReserveBalance -= k21Release;//== _reserve
      }
    }

    success = true;
  }

  function getBalances(address _account) external view returns(uint256 ethBalance, uint256 k21Balance) {
    return (_ethPOSBalances[_account], _k21POSBalances[_account]);
  }

  function withdraw() external returns(bool success) {
    if(_ethPOSBalances[msg.sender] > 0){
      // Use transfer to send Ether to the msg.sender, and handle errors
      (bool transferSuccess, ) = payable(msg.sender).call{value: _ethPOSBalances[msg.sender], gas: gasleft()}("");
      require(transferSuccess, "Ether withdraw fail");

      _ethPOSBalances[msg.sender] = 0; // Update the balance to zero

      success = true;
    }
    if(_k21POSBalances[msg.sender] > 0){
      // Use transfer to send K21 to the msg.sender, and handle errors
      bool transferSuccess = IERC20(_k21TokenAddress).transfer(msg.sender, _k21POSBalances[msg.sender]);
      require(transferSuccess, "K21 withdraw fail");

      _k21POSBalances[msg.sender] = 0; // Update the balance to zero

      success = true;
    }
  }

  function setRoyaltyRecipientAddress(address royaltyRecipient_) external {
    require(msg.sender == _royaltyRecipient, "not auth");
    _royaltyRecipient = royaltyRecipient_;
  }

  function setGuardiansAddress(address guardians_) external {
    require(msg.sender == _guardians, "not auth");
    _guardians = guardians_;
  }

  function setDependencies(address guaContract_, address eetContract_, bool _freeze) external onlyOwner {
    require(!_frozen, "frozen");
    _guaContract = guaContract_;
    _eetContract = eetContract_;
    _frozen = _freeze;
  }

  //Because the bonding curve will be the holder of GUA tokens
  function publishQuery(uint256 _tokenId, string memory _query) external {
    require(msg.sender == IERC721(_eetContract).ownerOf(_tokenId), "EET owner only");
    iGUA(_guaContract).publishQuery(_tokenId, _query);
  }

  function setCurves(address ethCurve_, address k21Curve_, bool _freeze) external onlyOwner {
    require(!_freezeCurves, "frozen");

    _ethCurve = ethCurve_;
    _k21Curve = k21Curve_;

    _freezeCurves = _freeze;
  }

  function getFee(uint256 _totalFortunes, address _currency) public view returns (uint256 fee) {
    address curve;
    if(_currency == address(0)){
      curve = _ethCurve;
    }else {
      curve = _k21Curve;
    }

    uint256 count = iCurve(curve).getCount();
    count++;
    for(uint256 i = 0; i < _totalFortunes; i++){
      fee += iCurve(curve).getMintPrice(count++);
    }
  }

  function redeemFortune(uint256 _tokenId, bytes32 _queryhash, uint256 _rand, string memory _encrypted) external returns(bool success){
    require(IERC721(_eetContract).ownerOf(_tokenId) == msg.sender, "not EET owner");

    return iGUA(_guaContract).redeemFortune(_tokenId, _queryhash, _rand, _encrypted);
  }

  function burnTo(uint256 _tokenId, address _owner, address payable _msgSender, address _currency, bytes memory _burnPayload) external returns (bool rewarded) {
    require(msg.sender == _eetContract, "only EET");
    uint256 reward;
    if(_currency == address(0)){
      reward = iCurve(_ethCurve).getNextBurnReward();
      iCurve(_ethCurve).decrementCount();

      (bool sent,) = _msgSender.call{value: reward, gas: gasleft()}("");
      require(sent, "Eth reward fail");

      _ethReserveBalance -= reward;
    }else{
      reward = iCurve(_k21Curve).getNextBurnReward();
      iCurve(_k21Curve).decrementCount();

      require(_k21TokenAddress == _currency, "only K21");
      bool sent = IERC20(_k21TokenAddress).transfer(_msgSender, reward);
      require(sent, "K21 reward fail");

      _k21ReserveBalance -= reward;
    }

    rewarded = true;
  }

}//end
SignedWadMath.sol 236 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

/// @notice Signed 18 decimal fixed point (wad) arithmetic library.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SignedWadMath.sol)
/// @author Modified from Remco Bloemen (https://xn--2-umb.com/22/exp-ln/index.html)
library SignedWadMath{
  /// @dev Will not revert on overflow, only use where overflow is not possible.
  function toWadUnsafe(uint256 x) public pure returns (int256 r) {
      /// @solidity memory-safe-assembly
      assembly {
          // Multiply x by 1e18.
          r := mul(x, 1000000000000000000)
      }
  }

  /// @dev Takes an integer amount of seconds and converts it to a wad amount of days.
  /// @dev Will not revert on overflow, only use where overflow is not possible.
  /// @dev Not meant for negative second amounts, it assumes x is positive.
  function toDaysWadUnsafe(uint256 x) public pure returns (int256 r) {
      /// @solidity memory-safe-assembly
      assembly {
          // Multiply x by 1e18 and then divide it by 86400.
          r := div(mul(x, 1000000000000000000), 86400)
      }
  }

  /// @dev Takes a wad amount of days and converts it to an integer amount of seconds.
  /// @dev Will not revert on overflow, only use where overflow is not possible.
  /// @dev Not meant for negative day amounts, it assumes x is positive.
  function fromDaysWadUnsafe(int256 x) public pure returns (uint256 r) {
      /// @solidity memory-safe-assembly
      assembly {
          // Multiply x by 86400 and then divide it by 1e18.
          r := div(mul(x, 86400), 1000000000000000000)
      }
  }

  /// @dev Will not revert on overflow, only use where overflow is not possible.
  function unsafeWadMul(int256 x, int256 y) public pure returns (int256 r) {
      /// @solidity memory-safe-assembly
      assembly {
          // Multiply x by y and divide by 1e18.
          r := sdiv(mul(x, y), 1000000000000000000)
      }
  }

  /// @dev Will return 0 instead of reverting if y is zero and will
  /// not revert on overflow, only use where overflow is not possible.
  function unsafeWadDiv(int256 x, int256 y) public pure returns (int256 r) {
      /// @solidity memory-safe-assembly
      assembly {
          // Multiply x by 1e18 and divide it by y.
          r := sdiv(mul(x, 1000000000000000000), y)
      }
  }

  function wadMul(int256 x, int256 y) public pure returns (int256 r) {
      /// @solidity memory-safe-assembly
      assembly {
          // Store x * y in r for now.
          r := mul(x, y)

          // Equivalent to require(x == 0 || (x * y) / x == y)
          if iszero(or(iszero(x), eq(sdiv(r, x), y))) {
              revert(0, 0)
          }

          // Scale the result down by 1e18.
          r := sdiv(r, 1000000000000000000)
      }
  }

  function wadDiv(int256 x, int256 y) public pure returns (int256 r) {
      /// @solidity memory-safe-assembly
      assembly {
          // Store x * 1e18 in r for now.
          r := mul(x, 1000000000000000000)

          // Equivalent to require(y != 0 && ((x * 1e18) / 1e18 == x))
          if iszero(and(iszero(iszero(y)), eq(sdiv(r, 1000000000000000000), x))) {
              revert(0, 0)
          }

          // Divide r by y.
          r := sdiv(r, y)
      }
  }

  /// @dev Will not work with negative bases, only use when x is positive.
  function wadPow(int256 x, int256 y) public pure returns (int256) {
      // Equivalent to x to the power of y because x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)
      return wadExp((wadLn(x) * y) / 1e18); // Using ln(x) means x must be greater than 0.
  }

  function wadExp(int256 x) public pure returns (int256 r) {
      unchecked {
          // When the result is < 0.5 we return zero. This happens when
          // x <= floor(log(0.5e18) * 1e18) ~ -42e18
          if (x <= -42139678854452767551) return 0;

          // When the result is > (2**255 - 1) / 1e18 we can not represent it as an
          // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.
          if (x >= 135305999368893231589) revert("EXP_OVERFLOW");

          // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96
          // for more intermediate precision and a binary basis. This base conversion
          // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.
          x = (x << 78) / 5**18;

          // Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers
          // of two such that exp(x) = exp(x') * 2**k, where k is an integer.
          // Solving this gives k = round(x / log(2)) and x' = x - k * log(2).
          int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96;
          x = x - k * 54916777467707473351141471128;

          // k is in the range [-61, 195].

          // Evaluate using a (6, 7)-term rational approximation.
          // p is made monic, we'll multiply by a scale factor later.
          int256 y = x + 1346386616545796478920950773328;
          y = ((y * x) >> 96) + 57155421227552351082224309758442;
          int256 p = y + x - 94201549194550492254356042504812;
          p = ((p * y) >> 96) + 28719021644029726153956944680412240;
          p = p * x + (4385272521454847904659076985693276 << 96);

          // We leave p in 2**192 basis so we don't need to scale it back up for the division.
          int256 q = x - 2855989394907223263936484059900;
          q = ((q * x) >> 96) + 50020603652535783019961831881945;
          q = ((q * x) >> 96) - 533845033583426703283633433725380;
          q = ((q * x) >> 96) + 3604857256930695427073651918091429;
          q = ((q * x) >> 96) - 14423608567350463180887372962807573;
          q = ((q * x) >> 96) + 26449188498355588339934803723976023;

          /// @solidity memory-safe-assembly
          assembly {
              // Div in assembly because solidity adds a zero check despite the unchecked.
              // The q polynomial won't have zeros in the domain as all its roots are complex.
              // No scaling is necessary because p is already 2**96 too large.
              r := sdiv(p, q)
          }

          // r should be in the range (0.09, 0.25) * 2**96.

          // We now need to multiply r by:
          // * the scale factor s = ~6.031367120.
          // * the 2**k factor from the range reduction.
          // * the 1e18 / 2**96 factor for base conversion.
          // We do this all at once, with an intermediate result in 2**213
          // basis, so the final right shift is always by a positive amount.
          r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));
      }
  }

  function wadLn(int256 x) public pure returns (int256 r) {
      unchecked {
          require(x > 0, "UNDEFINED");

          // We want to convert x from 10**18 fixed point to 2**96 fixed point.
          // We do this by multiplying by 2**96 / 10**18. But since
          // ln(x * C) = ln(x) + ln(C), we can simply do nothing here
          // and add ln(2**96 / 10**18) at the end.

          /// @solidity memory-safe-assembly
          assembly {
              r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
              r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
              r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
              r := or(r, shl(4, lt(0xffff, shr(r, x))))
              r := or(r, shl(3, lt(0xff, shr(r, x))))
              r := or(r, shl(2, lt(0xf, shr(r, x))))
              r := or(r, shl(1, lt(0x3, shr(r, x))))
              r := or(r, lt(0x1, shr(r, x)))
          }

          // Reduce range of x to (1, 2) * 2**96
          // ln(2^k * x) = k * ln(2) + ln(x)
          int256 k = r - 96;
          x <<= uint256(159 - k);
          x = int256(uint256(x) >> 159);

          // Evaluate using a (8, 8)-term rational approximation.
          // p is made monic, we will multiply by a scale factor later.
          int256 p = x + 3273285459638523848632254066296;
          p = ((p * x) >> 96) + 24828157081833163892658089445524;
          p = ((p * x) >> 96) + 43456485725739037958740375743393;
          p = ((p * x) >> 96) - 11111509109440967052023855526967;
          p = ((p * x) >> 96) - 45023709667254063763336534515857;
          p = ((p * x) >> 96) - 14706773417378608786704636184526;
          p = p * x - (795164235651350426258249787498 << 96);

          // We leave p in 2**192 basis so we don't need to scale it back up for the division.
          // q is monic by convention.
          int256 q = x + 5573035233440673466300451813936;
          q = ((q * x) >> 96) + 71694874799317883764090561454958;
          q = ((q * x) >> 96) + 283447036172924575727196451306956;
          q = ((q * x) >> 96) + 401686690394027663651624208769553;
          q = ((q * x) >> 96) + 204048457590392012362485061816622;
          q = ((q * x) >> 96) + 31853899698501571402653359427138;
          q = ((q * x) >> 96) + 909429971244387300277376558375;
          /// @solidity memory-safe-assembly
          assembly {
              // Div in assembly because solidity adds a zero check despite the unchecked.
              // The q polynomial is known not to have zeros in the domain.
              // No scaling required because p is already 2**96 too large.
              r := sdiv(p, q)
          }

          // r is in the range (0, 0.125) * 2**96

          // Finalization, we need to:
          // * multiply by the scale factor s = 5.549…
          // * add ln(2**96 / 10**18)
          // * add k * ln(2)
          // * multiply by 10**18 / 2**96 = 5**18 >> 78

          // mul s * 5e18 * 2**96, base is now 5**18 * 2**192
          r *= 1677202110996718588342820967067443963516166;
          // add ln(2) * k * 5e18 * 2**192
          r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;
          // add ln(2**96 / 10**18) * 5e18 * 2**192
          r += 600920179829731861736702779321621459595472258049074101567377883020018308;
          // base conversion: mul 2**18 / 2**192
          r >>= 174;
      }
  }

  /// @dev Will return 0 instead of reverting if y is zero.
  function unsafeDiv(int256 x, int256 y) public pure returns (int256 r) {
      /// @solidity memory-safe-assembly
      assembly {
          // Divide x by y.
          r := sdiv(x, y)
      }
  }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../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.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

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

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

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

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

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

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * 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[EIP 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);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
ERC721Holder.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

import "../IERC721Receiver.sol";

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721Holder is IERC721Receiver {
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
}

Read Contract

_eetContract 0x19ff31b9 → address
_ethCurve 0xf7641e8f → address
_ethPOSBalances 0x1bd0d5cb → uint256
_ethReserveBalance 0x016428c6 → uint256
_freezeCurves 0xb851d601 → bool
_frozen 0x2d80edcc → bool
_guaContract 0xe0347e1c → address
_guardians 0xa67abbca → address
_k21Curve 0x0414f149 → address
_k21POSBalances 0xfb7a1892 → uint256
_k21ReserveBalance 0x6212d33a → uint256
_k21TokenAddress 0xa035d4f3 → address
_posFeeSplitForReferrers18 0x2057cf5b → int256
_royaltyRecipient 0x1525131c → address
getBalances 0xc84aae17 → uint256, uint256
getFee 0xdfcf048d → uint256
owner 0x8da5cb5b → address

Write Contract 13 functions

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

burnTo 0x40321e56
uint256 _tokenId
address _owner
address _msgSender
address _currency
bytes _burnPayload
returns: bool
onERC721Received 0x150b7a02
address
address
uint256
bytes
returns: bytes4
pay 0xd952411f
address _payee
uint256 _amount
uint256 _tokenCount
address _currency
bytes _mintPayload
returns: bool
publishQuery 0xdfb400dc
uint256 _tokenId
string _query
redeemFortune 0x0e758d25
uint256 _tokenId
bytes32 _queryhash
uint256 _rand
string _encrypted
returns: bool
renounceOwnership 0x715018a6
No parameters
resetCurve 0x576165fc
address _currency
int256 k18_
int256 L18_
int256 b18_
int256 posFeePercent18_
int256 posFeeSplitForReferrers18_
returns: bool
setCurves 0x6e6a7f86
address ethCurve_
address k21Curve_
bool _freeze
setDependencies 0x8ca86294
address guaContract_
address eetContract_
bool _freeze
setGuardiansAddress 0xb1b91cdd
address guardians_
setRoyaltyRecipientAddress 0xaf9009e0
address royaltyRecipient_
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
returns: bool

Recent Transactions

No transactions found for this address