Address Contract Verified
Address
0xfb3Dea227Fe53D6999c6933a07B57a64075Ca77D
Balance
0.003096 ETH
Nonce
1
Code Size
23223 bytes
Creator
0xB5eC77Fe...4321 at tx 0x5d13be84...0587f1
Indexed Transactions
0
Contract Bytecode
23223 bytes
0x60808060405260043610156100c6575b5036156100755760405162461bcd60e51b815260206004820152603160248201527f46756e6374696f6e206e6f7420666f756e642e20557365206372656174654465604482015270616c455448282920666f72206465616c7360781b6064820152608490fd5b60405162461bcd60e51b815260206004820152602360248201527f557365206372656174654465616c455448282920746f20637265617465206465604482015262616c7360e81b6064820152608490fd5b5f3560e01c90816301ffc9a7146145ed5750806303e210cf1461440657806306ba0473146143005780630993cdbe146142025780630a9eeded146140fb5780630c3054cd146140355780630db2ad8b14613fc95780631322ec8c14613fac578063172d4d1b14613f1857806317d8041914613efa5780631c1e42bf14613d9057806320476974146136a3578063248a9ca3146136775780632f2ff15d1461363b57806331ea1a39146135255780633487e08c14613383578063348a71a61461320157806336568abe146131ba57806339c28c62146130575780633b947d2b14612f5b5780633eff50e0146128e75780633f4ba83a1461289157806342f6fb29146128695780634450b47214612840578063459b860e146126f95780634d104adf146126bf5780634df07fe5146126a1578063539f51db1461268557806354fd4d5014612640578063564201f91461046a5780635be5eeea1461261c5780635c975abb146125fa5780635e72fc5d146125ae5780635ebf1d75146125805780635f9d8efb146124805780636035ceba1461245257806360e74f56146123e0578063636bf26d1461210057806367946dd81461207f578063741412661461203d5780637678734c146116fe5780637bf2bb101461167f5780637c6f73eb146115f25780637d41702e1461153d57806382fd5bac146112c75780638456cb591461126e57806385407c9a1461124b57806389a302711461121d57806390c4c34a1461119b57806391d1485414611153578063929b65781461113557806393144f501461111857806394592dd314610e4f57806395877f7814610e035780639791d49214610dd5578063a100d69d14610d85578063a217fddf14610d6b578063a4b2409e14610c7f578063a52dba3c14610ae1578063ad3b1b47146109ac578063afb069521461096e578063b5af090f14610941578063b64fefd9146108c0578063bd0bb4d31461088d578063c54e44eb1461085f578063d547741f14610821578063d55be8c614610805578063d65f203a146107d7578063d7a718681461079b578063d98906b11461077e578063e0d1732b14610721578063e61d47c514610665578063eadb3c9c14610628578063ed3b7e9f14610607578063f2bcd022146105df578063f5b541a6146105a5578063f7074219146104e8578063fa847836146104a2578063fcf666641461046a5763fd03088b14610442575f61000f565b34610466575f36600319011261046657604060105460115482519182526020820152f35b5f80fd5b34610466576020366003190112610466576001600160a01b0361048b614656565b165f526008602052602060405f2054604051908152f35b34610466576020366003190112610466576001600160a01b036104c3614656565b165f5260066020526040805f205460ff8251918181161515835260081c166020820152f35b346104665760203660031901126104665761059f600435610507614d30565b61050f614d53565b805f52600460205261057460405f20600a8101805461053360ff8260a01c16614d71565b61054533610540856149df565b614f2a565b60ff60a01b1916600560a01b17905560028101548154600390920154916001600160a01b039081169116614dce565b33817f30d900d810288dc5a4efe2f34b51f7e880938b498fb6b9b1748797a169ff21f95f80a3614ea7565b60018055005b34610466575f3660031901126104665760206040517f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9298152f35b34610466575f36600319011261046657600c546040516001600160a01b039091168152602090f35b34610466575f36600319011261046657602061ffff60095416604051908152f35b34610466575f366003190112610466576003545f19810190811161065157602090604051908152f35b634e487b7160e01b5f52601160045260245ffd5b346104665760203660031901126104665761067e614b27565b506004355f52600560205260c060405f2060405161069b816147dc565b815460018060a01b03811692838352602083019160ff8160a01c16835260ff604085019160a81c16815260ff60018301549160608601928352816001600160401b039560a06003886002890154169760808b01988952015498019788526040519889525116602088015251166040860152516060850152511660808301525160a0820152f35b346104665760203660031901126104665761073a6147cb565b610742614f65565b6103e861ffff82161161076c5763ffff00006009549160101b169063ffff00001916176009555f80f35b6040516358d620b360e01b8152600490fd5b34610466575f366003190112610466576020604051620151808152f35b34610466576020366003190112610466576004356107b7614f65565b80156107c65760105542601155005b60405162bfc92160e01b8152600490fd5b34610466575f36600319011261046657602060405173b1bb66c47dee78b91e8aeeb6e74e66e02ca345678152f35b34610466575f3660031901126104665760206040516103e88152f35b346104665760403660031901126104665761085d60043561084061466c565b90805f525f602052610858600160405f200154614fbb565b6150a9565b005b34610466575f36600319011261046657602060405173dac17f958d2ee523a2206206994597c13d831ec78152f35b34610466575f366003190112610466576108bc6108a861486a565b60405191829160208352602083019061473c565b0390f35b34610466576020366003190112610466576108d9614656565b6108e1614f65565b6001600160a01b0381165f818152600d602052604090206004015490919060101c6001600160401b03161561092f5761085d915f52600d60205260405f20600160ff1982541617905561554b565b604051630cb5cfe160e31b8152600490fd5b3461046657602036600319011261046657602061096461095f614656565b614d09565b6040519015158152f35b346104665760203660031901126104665761ffff61098a6147cb565b610992614f65565b166103e8811161076c5761ffff1960095416176009555f80f35b34610466576040366003190112610466576109c5614656565b602435906109d1614f65565b6109d9614d30565b6001600160a01b038181165f81815260086020526040902054939092908415610aa65780610aa05750835b8411610a67577eed5939179dc194223f0edd1517ecee2210b22da7f82c8e4b1795e93b9f06aa91610a5585602093865f526008855260405f20610a48838254614c24565b905583600c541690614dce565b600c541693604051908152a360018055005b60405162461bcd60e51b8152602060048201526011602482015270496e73756666696369656e74206665657360781b6044820152606490fd5b93610a04565b60405162461bcd60e51b81526020600482015260136024820152724e6f206665657320746f20776974686472617760681b6044820152606490fd5b3461046657604036600319011261046657610afa614656565b610b02614682565b610b0a614f65565b6001600160a01b038216908115610c425760ff169081151580610c37575b610b3190614b9a565b805f52600660205260ff60405f205416610bf25760ff610b9d9260405192610b58846147f7565b60018452602084019182525f526006602052610b8760405f2093511515849060ff801983541691151516179055565b51825461ff001916911660081b61ff0016179055565b60075490600160401b821015610bde57610bc082600161085d9401600755614707565b90919060018060a01b038084549260031b9316831b921b1916179055565b634e487b7160e01b5f52604160045260245ffd5b60405162461bcd60e51b815260206004820152601960248201527f537461626c65636f696e20616c726561647920657869737473000000000000006044820152606490fd5b506012821115610b28565b60405162461bcd60e51b8152602060048201526015602482015274496e76616c696420746f6b656e206164647265737360581b6044820152606490fd5b3461046657602036600319011261046657600435610c9b614d30565b610ca3614d53565b805f52600460205260405f20600a81019081549060ff8260a01c166008811015610d5757600181141580610d4c575b610d255750610cea90610ce533916149df565b614f15565b60ff60a81b1916600160a81b17905533907fd8420f97dab0b820e066ebfad617848c1eab2d260922358cc1d5cdcdc568d5725f80a360018055005b60405163f924664d60e01b8152604491610d439060048301906147be565b60016024820152fd5b506002811415610cd2565b634e487b7160e01b5f52602160045260245ffd5b34610466575f3660031901126104665760206040515f8152f35b3461046657602036600319011261046657600435600b5481101561046657602090600b5f527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90154604051908152f35b34610466576020366003190112610466576004355f52600a602052602061ffff60405f205416604051908152f35b3461046657602036600319011261046657610e1c614656565b610e24614f65565b6001600160a01b0316610e38811515614c31565b6001600160601b0360a01b600f541617600f555f80f35b34610466576060366003190112610466576004356024908135916001600160401b039081841680850361046657610e84614692565b92610e8d614d30565b5f85815260046020526040902080546001600160a01b039491908516610eb481151561489b565b33148015611109575b610ec6906148dd565b600a81019260ff845460a01c1660088110156110f657600181149081156110eb575b501561109a57610e109485811015908161108c575b50156110505786169384101580611043575b1561100657600b0193845460401c16610fc25750805467ffffffffffffffff60b01b191660b087901b67ffffffffffffffff60b01b161790557fd18c0d7b3ea1351da6edc43673a8768cb967a552df945f01335771d80dd0d5e792610fb9929091815467ffffffffffffffff1916178155610f8a3382614988565b805460ff60e01b19169055604080516001600160401b0396871681529590911660208601523394918291820190565b0390a360018055005b60649060186040519162461bcd60e51b8352602060048401528201527f50726f706f73616c20616c72656164792070656e64696e6700000000000000006044820152fd5b60405162461bcd60e51b81526020600482015260168184015275496e76616c696420636f6e6669726d2077696e646f7760501b6044820152606490fd5b5062278d00841115610f0f565b60405162461bcd60e51b81526020600482015260158185015274496e76616c6964207375626d69742077696e646f7760581b6044820152606490fd5b62ed4e00915011158a610efd565b60405162461bcd60e51b8152602060048201528084018490527f496e76616c69642073746174757320666f7220646561646c696e652070726f706044820152631bdcd85b60e21b6064820152608490fd5b60029150148a610ee8565b83634e487b7160e01b5f5260216004525ffd5b50600181015485163314610ebd565b34610466575f366003190112610466576020601154604051908152f35b34610466575f366003190112610466576020604051633b9aca008152f35b346104665760403660031901126104665761116c61466c565b6004355f525f60205260405f209060018060a01b03165f52602052602060ff60405f2054166040519015158152f35b34610466576040366003190112610466576111b4614656565b6024359061ffff8216809203610466576111cc614f65565b6001600160a01b03165f818152600d602052604090206004015460101c6001600160401b03161561092f576103e8821161076c575f52600d602052600460405f20019061ffff198254161790555f80f35b34610466575f36600319011261046657602060405173a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488152f35b34610466576020366003190112610466576020610964611269614656565b61511b565b34610466575f36600319011261046657611286614f65565b61128e614d53565b600160ff1960025416176002557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b34610466576020366003190112610466575f6102e06040516112e881614812565b8281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e08201528261010082015282610120820152826101408201528261016082015282610180820152826101a0820152826101c0820152826101e08201528261020082015282610220820152826102408201528261026082015282610280820152826102a0820152826102c082015201526004355f52600460205261030061139960405f206149df565b6102e06040519160018060a01b03815116835260018060a01b03602082015116602084015260018060a01b036040820151166040840152606081015160608401526080810151608084015260a081015161ffff80911660a085015260c08201511660c084015260e081015160e08401526101008101516101008401526001600160401b03610120820151166101208401526001600160401b03610140820151166101408401526001600160401b03610160820151166101608401526001600160401b03610180820151166101808401526001600160401b036101a0820151166101a08401526001600160401b036101c0820151166101c08401526001600160401b036101e0820151166101e08401526001600160401b036102008201511661020084015260018060a01b03610220820151166102208401526114e56102408201516102408501906147be565b61026081015115156102608401526001600160401b03610280820151166102808401526001600160401b036102a0820151166102a084015260018060a01b036102c0820151166102c0840152015115156102e0820152f35b3461046657602036600319011261046657600435611559614d30565b611561614d53565b805f52600460205260405f2090600a820191600883549161158760ff8460a01c16614d71565b61159433610540836149df565b0154926001600160401b03916115ab838616614f42565b60ff60a01b1916600160a01b1790556040805193901c16825233917f314ba42b89005e45f141b530b3f8fb557b2070e3853b8d95facfb8549cec4a7690602090a360018055005b34610466575f36600319011261046657604051806007549182815260208091019260075f527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688915f905b82821061165f576108bc8561165381890382614849565b6040519182918261477a565b83546001600160a01b03168652948501946001938401939091019061163c565b34610466576020366003190112610466576001600160a01b036116a0614656565b165f52600d60205260c060405f206001600160401b0360ff8254169160018101549060028101546004600383015492015492604051951515865260208601526040850152606084015261ffff8116608084015260101c1660a0820152f35b346104665761010036600319011261046657611718614656565b61172061466c565b6117286146a8565b906001600160401b0360a4351660a43503610466576001600160401b0360c4351660c435036104665760e4356001600160a01b03811690036104665761176c614d30565b611774614d53565b6001600160a01b03811615611f735760018060a01b0381165f52600660205260405f20604051906117a4826147f7565b5460ff80821615918215845260081c166020830152611fec5760208101516118029163773594009160ff1660088111611e7657506117f36117ee60ff60206117fb94015116614c9b565b614cac565b604435614bd9565b1015614cbd565b6001600160a01b03831615611f735760643515611fda57610e10806001600160401b038416108015611fc5575b611f8557806001600160401b0360a43516108015611fae575b611f85576001600160401b0360c43516108015611f97575b611f8557336001600160a01b03841614611f73576040516323b872dd60e01b60208201523360248201523060448201526044356064820152606481528060a08101106001600160401b0360a083011117610bde5760a081016040526118ce906001600160a01b038316615855565b600354916118db8361553d565b600355815f60e4356001600160a01b0316611f13575b6001600160a01b0382165f908152600660205260408082209051889291611917826147f7565b5460ff80821615159182845260081c1660208301525f14611e94576001600160401b0392916119706377359400859360ff60208201511660088111155f14611e7657506117f36117ee60ff60206117fb94015116614c9b565b60095482906001600160a01b03871615611e68576001600160a01b0387165f908152600d602052604090206004015461ffff9081165b816119b38c864216614942565b936119c060a43586614942565b966119cd60c43589614942565b99604080519e8f926119de84614812565b33845260018060a01b0316602084015260018060a01b03169101528c606060443591015260808d01521660a08b01521660c089015260643560e08901525f6101008901521661012087015216610140850152166101608301526001600160401b0383166101808301526001600160401b0360a435166101a08301526001600160401b0360c435166101c08301526001600160401b0342166101e08301525f61020083015260018060a01b03166102208201525f6102408201525f6102608201525f6102808201525f6102a08201525f6102c08201525f6102e0820152835f52600460205260405f2060018060a01b038251166001600160601b0360a01b8254161781556001810160018060a01b036020840151166001600160601b0360a01b8254161790556002810160018060a01b036040840151166001600160601b0360a01b8254161790556060820151600382015560808201516004820155611b756005820161ffff60a08501511661ffff1982541617815561ffff60c08501511663ffff000082549160101b169063ffff00001916179055565b60e08201516006820155610100820151600782015561012082015160088201805467ffffffffffffffff19166001600160401b03928316178155610140840151611bc092169061491a565b611bdb6001600160401b03610160840151166008830161495d565b6101808201516008820180546001600160c01b031660c09290921b6001600160c01b031916919091179055611c81600982016001600160401b036101a0850151166001600160401b0319825416178155611c436001600160401b036101c0860151168261491a565b611c5b6001600160401b036101e0860151168261495d565b61020084015181546001600160c01b031660c09190911b6001600160c01b031916179055565b610220820151600a820180546001600160a01b0319166001600160a01b0392909216919091179055610240820151956008871015610d5757611d9f86936102e0600b85611cf460209c600a7f26eba422e79370cb5e1b2e3334dcb8de7ce02260b605de540c0f0bae7ef704a099016149bb565b610260840151600a8201805460ff60a81b191691151560a81b60ff60a81b16919091179055610280840151600a8201805467ffffffffffffffff60b01b191660b09290921b67ffffffffffffffff60b01b1691909117905501916001600160401b036102a0820151166001600160401b0319845416178355611d8360018060a01b036102c08301511684614988565b0151815460ff60e01b191690151560e01b60ff60e01b16179055565b825f52600487526001600160401b0360405f209461ffff60056004880154970154611dc861486a565b976040519960018060a01b03168a526044358c8b015260408a015281811660608a015260101c16608088015260643560a08801521660c08601526001600160401b0360a4351660e08601526001600160401b0360c4351661010086015260018060a01b0360e4351661012086015261016061014086015260018060a01b03169380611e59339561016083019061473c565b0390a460018055604051908152f35b61ffff808260101c166119a6565b611e8f91506117ee611e8791614c88565b604435614c1a565b6117fb565b5050509050611ea1615814565b908115611ede576001600160401b03868184611ed96377359400670de0b6b3a7640000611ed18b99604435614bd9565b041015614cbd565b611970565b60405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420707269636560981b6044820152606490fd5b5050611f2060e43561511b565b15611f2e578160e4356118f1565b60405162461bcd60e51b815260206004820152601f60248201527f5072656665727265642061726269746572206973206e6f7420616374697665006044820152606490fd5b60405163e6c4247b60e01b8152600490fd5b60405163b11cd48160e01b8152600490fd5b5062278d006001600160401b0360c4351611611860565b5062ed4e006001600160401b0360a4351611611848565b5062278d006001600160401b0384161161182f565b6040516392a3c43160e01b8152600490fd5b60405162461bcd60e51b815260206004820152602360248201527f546f6b656e206973206e6f74206120737570706f7274656420737461626c656360448201526237b4b760e91b6064820152608490fd5b3461046657602036600319011261046657600435600e54811015610466576120666020916146be565b905460405160039290921b1c6001600160a01b03168152f35b34610466575f3660031901126104665760405180600e5491828152602080910192600e5f527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd915f905b8282106120e0576108bc8561165381890382614849565b83546001600160a01b0316865294850194600193840193909101906120c9565b346104665761210e36614640565b612116614d30565b61211e614d53565b815f52600460205260405f2091600a83019283549060ff8260a01c169460088610159283610d575760019687811415806123d2575b6123ab5783546001600160a01b03959086163314158061239c575b61238b57610d57576002148061237b575b6122eb575b600b830190815490858260401c166122c7575b505081549290508383161561227057508054831691506121b68261511b565b1561221a575b805460ff60a01b1916600360a01b179055165f908152600d60205260409020830180546121e89061553d565b90556040519182527f7ab71b430e1c8a5ceb166189a725f797de4594dbf7b4493262e82e99f183eb6d60203393a38055005b60405162461bcd60e51b815260206004820152602860248201527f5072652d73656c65637465642061726269746572206973206e6f206c6f6e6765604482015267722061637469766560c01b6064820152608490fd5b6122c29061227c61568b565b9385851680916001600160601b0360a01b161784555f52600d602052600561ffff600460405f2001541691019063ffff000082549160101b169063ffff00001916179055565b6121bc565b67ffffffffffffffff60b01b191683556001600160e81b0319169055868080612197565b6001600160401b0380600885015460801c1661230f600986015460c01c8092614c6f565b6202a300818416101561236d57677fffffffffffffff612336918b1c16915b834216614c6f565b908281168383161061234a57505050612184565b6024929161235791614c6f565b604051631806d23b60e11b815291166004820152fd5b50612336620151809161232e565b50600983015460c01c151561217f565b6040516282b42960e81b8152600490fd5b5085898601541633141561216e565b60405163f924664d60e01b81526044916123c99060048301906147be565b60026024820152fd5b505f94506002811415612153565b34610466576020366003190112610466576123f9614656565b5f6020604051612408816147f7565b828152015260018060a01b03165f5260066020526040805f2060ff82519161242f836147f7565b54816020818316151594858152019160081c168152835192835251166020820152f35b34610466575f36600319011261046657602060405173bf3a2c7c9bc27e3143df965ffa80e421f54456788152f35b346104665760203660031901126104665760043561249c614d30565b6124a4614d53565b805f52600460205260405f2090600a82019182549260ff8460a01c16936008851015610d5757600285036125635761059f94506124e433610ce5856149df565b6124fd6001600160401b03600885015460801c16614f42565b60ff60a01b1916600160a21b17905560018101805483917fccc2f4f9903c15c16b3fe18956f58becad7fc1e3267c7652b847c3d71e61a1e0916020916003916001600160a01b03919061255290831687615157565b5416940154604051908152a3614ea7565b60405163f924664d60e01b81526044906123c960048201886147be565b34610466575f366003190112610466576020604051735f4ec3df9cbd43714fe2740f5e3616155c5b84198152f35b34610466576020366003190112610466576125c7614656565b6125cf614f65565b6001600160a01b03166125e3811515614c31565b6001600160601b0360a01b600c541617600c555f80f35b34610466575f36600319011261046657602060ff600254166040519015158152f35b34610466575f36600319011261046657602061ffff60095460101c16604051908152f35b34610466575f366003190112610466576108bc60405161265f816147f7565b6005815264312e302e3360d81b602082015260405191829160208352602083019061473c565b34610466575f3660031901126104665760206040516102588152f35b34610466575f366003190112610466576020604051631dcd65008152f35b34610466575f3660031901126104665760206040517fbb08418a67729a078f87bbc8d02a770929bb68f5bfdf134ae2ead6ed38e2f4ae8152f35b3461046657602036600319011261046657600435612715614d30565b805f52600460205260405f209061272b826149df565b6102408101516008811015610d57576002149081612828575b501561281657600a8201805460ff60a01b1916600160a21b17905560018201805461059f93916003916001600160a01b03919061278390831686615157565b541691015490825f80516020615a628339815191526127c16127a361486a565b6040519586526007602087015260806040870152608086019061473c565b936b706f6e6420696e2074696d6560a01b604082870396876060850152602c81527f4175746f2d72656c65617365202d20627579657220646964206e6f742072657360208201520152606033950190a4614ea7565b604051633376277360e11b8152600490fd5b6001600160401b039150610160015116421183612744565b346104665760203660031901126104665760043560075481101561046657612066602091614707565b34610466575f36600319011261046657600f546040516001600160a01b039091168152602090f35b34610466575f366003190112610466576128a9614f65565b6128b161566c565b60ff19600254166002557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60c0366003190112610466576128fb614656565b612903614692565b906001600160401b036064351660643503610466576129206146a8565b60a435926001600160a01b03841684036104665761293c614d30565b612944614d53565b6001600160a01b03831615611f735766038d7ea4c680003410612f495760243515611fda57610e10806001600160401b038316108015612f34575b611f8557806001600160401b0360643516108015612f1d575b611f85576001600160401b038316108015612f08575b611f8557336001600160a01b03841614611f7357600354926129cf8461553d565b600355805f6001600160a01b038716612ef1575b5f80805260066020526040517f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8612a19826147f7565b5460ff80821615159182845260081c1660208301525f14612eb45790612a7663773594006001600160401b039360ff60208201511660088111155f14612e9d5750612a706117ee60ff60206117fb94015116614c9b565b34614bd9565b6009548290889082906001600160a01b03871615612e8f576001600160a01b0387165f908152600d602052604090206004015461ffff9081165b81612abd8d864216614942565b93612ad4612acd60643587614942565b9788614942565b9860806040519e8f90612ae682614812565b33825260018060a01b031660208201525f604082015234606082015201521660a08c01521660c08a015260243560e08a01525f6101008a01521661012088015216610140860152166101608401526001600160401b0384166101808401526001600160401b03606435166101a08401526001600160401b0385166101c08401526001600160401b0342166101e08401525f61020084015260018060a01b03166102208301525f6102408301525f6102608301525f6102808301525f6102a08301525f6102c08301525f6102e0830152845f52600460205260405f209060018060a01b038351166001600160601b0360a01b8354161782556001820160018060a01b036020850151166001600160601b0360a01b8254161790556002820160018060a01b036040850151166001600160601b0360a01b8254161790556060830151600383015560808301516004830155612c716005830161ffff60a08601511661ffff1982541617815561ffff60c08601511663ffff000082549160101b169063ffff00001916179055565b60e08301516006830155610100830151600783015561012083015160088301805467ffffffffffffffff19166001600160401b03928316178155610140850151612cbc92169061491a565b612cd76001600160401b03610160850151166008840161495d565b6101808301516008830180546001600160c01b031660c09290921b6001600160c01b031916919091179055612d7d600983016001600160401b036101a0860151166001600160401b0319825416178155612d3f6001600160401b036101c0870151168261491a565b612d576001600160401b036101e0870151168261495d565b61020085015181546001600160c01b031660c09190911b6001600160c01b031916179055565b610220830151600a830180546001600160a01b0319166001600160a01b0392909216919091179055610240830151966008881015610d5757612df087946102e0600b86611cf460209d600a7f26eba422e79370cb5e1b2e3334dcb8de7ce02260b605de540c0f0bae7ef704a09a016149bb565b835f52600488526001600160401b0360405f209681600560048a01549901549761ffff612e1b61486a565b996040519b5f8d528c8f3491015260408d015281811660608d015260101c1660808b015260243560a08b01521660c0890152816064351660e08901521661010087015260018060a01b031661012086015261016061014086015260018060a01b03169380611e59339561016083019061473c565b61ffff808260101c16612ab0565b611e8f91506117ee612eae91614c88565b34614c1a565b50509050612ec0615814565b908115611ede576001600160401b0382612eec6377359400670de0b6b3a7640000611ed1889734614bd9565b612a76565b5050612efc8561511b565b15611f2e5780856129e3565b5062278d006001600160401b038316116129ae565b5062ed4e006001600160401b036064351611612998565b5062278d006001600160401b0383161161297f565b60405163162908e360e11b8152600490fd5b3461046657602036600319011261046657612f74614656565b612f7c614f65565b60018060a01b0380911690815f526006602052612f9f60ff60405f205416614b57565b5f828152600660205260408120805460ff191690555b600780548083101561085d57839085612fcd85614707565b939054600394851b1c1614612fe757505050600101612fb5565b90929194505f19938482019182116106515761301593613009610bc093614707565b9054911b1c1691614707565b8154801561304357019061304061302b83614707565b81549060018060a01b039060031b1b19169055565b55005b634e487b7160e01b5f52603160045260245ffd5b3461046657602036600319011261046657600435613073614d30565b61307b61566c565b613083614f65565b805f52600460205260405f2090600a82019182549260ff8460a01c166008811015610d5757600781141590816131ae575b50156131755760ff60a01b19909316600560a01b179092556002820154825460038401805461059f9591936001600160a01b03936130f89291908516908516614dce565b5416905490825f80516020615a6283398151915261313561311761486a565b6040519586526005602087015260806040870152608086019061473c565b937f456d657267656e63792072656c6561736520647572696e672070617573650000602082870396876060850152601e81520152604033950190a4614ea7565b60405162461bcd60e51b8152602060048201526011602482015270105b1c9958591e48199a5b985b1a5e9959607a1b6044820152606490fd5b600491501415856130b4565b34610466576040366003190112610466576131d361466c565b336001600160a01b038216036131ef5761085d906004356150a9565b60405163334bd91960e11b8152600490fd5b346104665760203660031901126104665760043561321d614d30565b613225614d53565b805f52600460205260405f2090600a82019182549260ff8460a81c161561334a5760ff8460a01c16936008851015610d575760018514158061333f575b6133225761059f945061327833610540856149df565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b039390926132b19291908516908516614dce565b5416905490825f80516020615a628339815191526132d061311761486a565b93681959081c99599d5b9960ba1b604082870396876060850152602981527f4d757475616c2061677265656d656e74202d2073656c6c657220617070726f7660208201520152606033950190a4614ea7565b60405163f924664d60e01b8152604490610d4360048201886147be565b506002851415613262565b60405162461bcd60e51b8152602060048201526011602482015270139bc81c99599d5b99081c995c5d595cdd607a1b6044820152606490fd5b346104665760203660031901126104665761339c614656565b6133a4614f65565b6001600160a01b038181165f818152600d60205260409020600401549192909160101c6001600160401b03161561092f57815f52600d60205260405f209260019360026001820154910154036134e0575f845b613453575b8361340684614ffa565b50805f52600d6020525f60046040822082815582600182015582600282015582600382015501557fb7a0f68489d6e103758c5896f7f700d18e1e9213039ef12daf1c81a88b1ce6715f80a2005b600e8054808310156134d95783908661346b856146be565b939054600394851b1c1614613485575050508401846133f7565b909291939596505f1995868201918211610651576134b5936134a9610bc0936146be565b9054911b1c16916146be565b8054928315613043576134069301906134d061302b836146be565b558291846133fc565b50506133fc565b60405162461bcd60e51b815260206004820152601960248201527f41726269746572206861732070656e64696e67206361736573000000000000006044820152606490fd5b346104665760203660031901126104665761059f600435613544614d30565b61354c614d53565b805f52600460205260405f20600a8101805461356d60ff8260a01c16614da8565b61357a33610ce5856149df565b6135936001600160401b03600885015460401c16614dbc565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b039390926135cc9291908516908516614dce565b5416905490825f80516020615a628339815191526135eb61311761486a565b93663232b634bb32b960c91b604082870396876060850152602781527f5375626d69742074696d656f7574202d2073656c6c657220646964206e6f742060208201520152606033950190a4614ea7565b346104665760403660031901126104665761085d60043561365a61466c565b90805f525f602052613672600160405f200154614fbb565b6155f6565b34610466576020366003190112610466576004355f525f6020526020600160405f200154604051908152f35b34610466576080366003190112610466576004356136bf614682565b9060443560ff81168103610466576064356136d8614d30565b6136e0614d53565b825f52600460205260405f20600a81019283549560ff8760a01c166008811015610d575760038103613d69575060ff169360ff8216850160ff81116106515760ff6064911603613d5757335f8181527fee57cd81e84075558e8fcc182a1f4393f91fc97f963a136e66b7f949a62f319f60205260409020546001600160a01b0389169091149060ff16811580613d4f575b61238b5781613d46575b50613cf4575b600596600360a11b9060ff60a01b19161790556001600160401b03600380840154936137be61271095869261ffff9b8c91015460101c1690614bd9565b04604051926137cc846147dc565b3384526020840190888252604085019160ff8716835260608601908982526080870193834216855260a088019586528c5f52600560205260405f209760018060a01b0390511688549260ff60a01b905160a01b169160ff60a81b905160a81b169269ffffffffffffffffffff60b01b161717178655516001860155600285019151166001600160401b031982541617905551910155600460205260405f206003810154968361387f82600954168a614bd9565b049760048301548015155f14613c1057633b9aca00670de0b6b3a76400006138a7838d614bd9565b0410613bff575b5f9560ff600a86015460a01c16936008851015610d575760068c9514613a77575b5050506138e06138e5928692614c24565b614c24565b600282019160018060a01b038354165f52600860205260405f20948554998a01809a116106515761059f9960ff965580151580613a61575b613a3d575b506064870361399c57549154613944926001600160a01b039081169116614dce565b335f52600d602052600260405f200161395d815461553d565b90556040519384521660208301526040820152817f943c9c113661af578bbf2cbbfb531582e552aa48ab9002da7f837049687ecee860603393a3614ea7565b8385166064036139c95791546001909201546139c4926001600160a01b039182169116614dce565b613944565b6139e060646139d88985614bd9565b048093614c24565b9180613a1c575b50816139f6575b505050613944565b9154600190920154613a14926001600160a01b039182169116614dce565b8680806139ee565b83548254613a3792916001600160a01b039182169116614dce565b896139e7565b8354600a830154613a5b92916001600160a01b039182169116614dce565b89613922565b50600a8201546001600160a01b0316151561391d565b613a8d91929750600586015460101c1683614bd9565b04948015613ae257631dcd6500670de0b6b3a7640000613aad8389614bd9565b0410613ac8575b506138e06138e59286925b928194506138cf565b6138e5929550613ada6138e091614c03565b959250613ab4565b5060018060a01b036002840154165f52600660205260405f20602060ff60405192613b0c846147f7565b548181161515845260081c1691019080825260088111155f14613be45750613b43613b3d6117ee60ff845116614c9b565b87614bd9565b905b631dcd6500809210613b62575b50506138e06138e5928692613abf565b805191965091925060ff1660088111613bb757506117ee60ff613b86925116614c9b565b908115613ba3576138e06138e5928a96049586925b925092613b52565b634e487b7160e01b5f52601260045260245ffd5b613bc891506117ee90959295614c88565b808202918204036106515787936138e06138e592958692613b9b565b613bf36117ee613bf992614c88565b87614c1a565b90613b45565b9850613c0a89614bec565b986138ae565b60018060a01b036002850154165f52600660205260405f20602060ff60405192613c39846147f7565b548181161515845260081c1691019080825260088111155f14613cd95750613c70613c6a6117ee60ff845116614c9b565b8c614bd9565b905b633b9aca00809210613c86575b50506138ae565b8051929b50909160ff1660088111613cba57506117ee60ff613ca9925116614c9b565b908115613ba35704985b8a80613c7f565b613cc891506117ee90614c88565b808202918204036106515798613cb3565b613ce86117ee613cee92614c88565b8c614c1a565b90613c72565b613cfd3361511b565b6137815760405162461bcd60e51b815260206004820152601c60248201527f4172626974657220686173206265656e206465616374697661746564000000006044820152606490fd5b9050158861377b565b508015613771565b60405163648564d360e01b8152600490fd5b60405163f924664d60e01b8152604491613d879060048301906147be565b60036024820152fd5b3461046657602036600319011261046657613da9614656565b613db1614f65565b6001600160a01b03811690811561092f57815f52600d6020526001600160401b039081600460405f20015460101c16613ee85761ffff918260095460101c169042169260405190613e01826147dc565b60018252600460208301925f8452604081015f81526060820190605082526080830196875260a08301958987528a5f52600d602052613e5360405f2094511515859060ff801983541691151516179055565b5160018401555160028301555160038201550192511669ffffffffffffffff00008354925160101b169169ffffffffffffffffffff191617179055600e5491600160401b831015610bde57613ede82613ed9602094610bc08760017f3e9e037f5ae1b02104d124fd8f1783111cdf05db0bf2f9b784b2c8d3d866ebf49901600e556146be565b61554b565b50604051908152a2005b6040516301934db960e01b8152600490fd5b34610466575f36600319011261046657602060405163773594008152f35b346104665760403660031901126104665761085d613f34614656565b613f3c614682565b90613f45614f65565b6001600160a01b03165f81815260066020526040902054613f689060ff16614b57565b613f7f60ff83168015159081613fa0575b50614b9a565b5f52600660205260405f209061ff0082549160081b169061ff001916179055565b60129150111585613f79565b34610466575f366003190112610466576020601054604051908152f35b3461046657602036600319011261046657613fe2614656565b613fea614f65565b6001600160a01b0381165f818152600d602052604090206004015490919060101c6001600160401b03161561092f5761085d915f52600d60205260405f2060ff198154169055614ffa565b346104665760203660031901126104665761404e614656565b614056614b27565b5060018060a01b03165f52600d60205260c060405f2060a06040519161407b836147dc565b60ff815416151592838152600182015490602081019182526002830154926040820193845260046003820154916060840192835201549361ffff93608084019385871685526001600160401b03978891019660101c16865260405197885251602088015251604087015251606086015251166080840152511660a0820152f35b346104665761410936614640565b614111614d30565b614119614d53565b815f52600460205260405f2090600a82019061413b60ff835460a01c16614da8565b61414833610540856149df565b600883016001600160401b039061416482825460401c16614f42565b8215611fda576141ec6141e686846040978760077f9e9c1d76a37a54669f8a78e425540f992456de1e11f2e7304bd440057eff2ddf9b015560098242169301906141cb8483908154906001600160401b0360c01b9060c01b169060018060c01b0316179055565b805460ff60a01b1916600160a11b17905554881c1690614942565b8261495d565b5460801c1682519182526020820152a260018055005b346104665760203660031901126104665761059f600435614221614d30565b805f52600460205260405f20600a8101805461424260ff8260a01c16614da8565b61424f33610ce5856149df565b6142686001600160401b03600885015460401c16614dbc565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b039390926142a19291908516908516614dce565b5416905490825f80516020615a628339815191526142c061311761486a565b937f4175746f2d726566756e64202d207375626d69742074696d656f757400000000602082870396876060850152601c81520152604033950190a4614ea7565b346104665760203660031901126104665761059f60043561431f614d30565b614327614d53565b805f52600460205260405f20600a8101805461434860ff8260a01c16614d71565b61435e6001600160401b03600885015416614dbc565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b039390926143979291908516908516614dce565b5416905490825f80516020615a628339815191526143b661311761486a565b93661c995cdc1bdb9960ca1b604082870396876060850152602781527f4163636570742074696d656f7574202d2073656c6c657220646964206e6f742060208201520152606033950190a4614ea7565b3461046657602036600319011261046657600435614422614d30565b5f81815260046020526040902080546001600160a01b0390811692919061444a84151561489b565b600b820193845491808360401c1680156145b257331461457757614478913314908115614567575b506148dd565b600a8201906001600160401b03946144ad8680855460b01c169360098701946001600160401b0319865416178555168361491a565b60ff835460a01c16926008841015610d57577fe12de98e87a382da6cc4514671078d865a496fc92dc794a038f9f8c6e7ffbdfd946002610fb99514614542575b508154815467ffffffffffffffff60b01b19169091556001600160e81b031916600160e01b17905554604080518683166001600160401b03908116825292821c90961690911660208601523394918291820190565b61456190600861455a8a875460401c168b4216614942565b910161495d565b876144ed565b9050600184015416331486614472565b60405162461bcd60e51b815260206004820152601360248201527243616e6e6f742073656c662d617070726f766560681b6044820152606490fd5b60405162461bcd60e51b81526020600482015260136024820152724e6f2070726f706f73616c2070656e64696e6760681b6044820152606490fd5b34610466576020366003190112610466576004359063ffffffff60e01b821680920361046657602091637965db0b60e01b811490811561462f575b5015158152f35b6301ffc9a760e01b14905083614628565b6040906003190112610466576004359060243590565b600435906001600160a01b038216820361046657565b602435906001600160a01b038216820361046657565b6024359060ff8216820361046657565b604435906001600160401b038216820361046657565b608435906001600160401b038216820361046657565b600e548110156146f357600e5f527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd01905f90565b634e487b7160e01b5f52603260045260245ffd5b6007548110156146f35760075f527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68801905f90565b91908251928382525f5b848110614766575050825f602080949584010152601f8019910116010190565b602081830181015184830182015201614746565b60209060206040818301928281528551809452019301915f5b8281106147a1575050505090565b83516001600160a01b031685529381019392810192600101614793565b906008821015610d575752565b6004359061ffff8216820361046657565b60c081019081106001600160401b03821117610bde57604052565b604081019081106001600160401b03821117610bde57604052565b61030081019081106001600160401b03821117610bde57604052565b608081019081106001600160401b03821117610bde57604052565b90601f801991011681019081106001600160401b03821117610bde57604052565b60405190614877826147f7565b60158252743cb13d1734b790169022b9b1b937bb902630bcb2b960591b6020830152565b156148a257565b60405162461bcd60e51b81526020600482015260136024820152721119585b08191bd95cc81b9bdd08195e1a5cdd606a1b6044820152606490fd5b156148e457565b60405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606490fd5b9067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b9190916001600160401b038080941691160191821161065157565b805467ffffffffffffffff60801b191660809290921b67ffffffffffffffff60801b16919091179055565b805468010000000000000000600160e01b03191660409290921b68010000000000000000600160e01b0316919091179055565b906008811015610d5757815460ff60a01b191660a09190911b60ff60a01b16179055565b906040516149ec81614812565b809260018060a01b038082541683528060018301541660208401528060028301541660408401526003820154606084015260048201546080840152600582015461ffff9081811660a086015260101c1660c0840152600682015460e0840152600782015461010084015260088201546001600160401b0390818116610120860152818160401c16610140860152818160801c1661016086015260c01c61018085015260098301548181166101a0860152818160401c166101c0860152818160801c166101e086015260c01c610200850152600a8301549180831661022086015260ff8360a01c16926008841015610d57576102e09483600b9260ff966102408a0152868160a81c1615156102608a015260b01c1661028088015201549182166102a08601528160401c166102c085015260e01c161515910152565b60405190614b34826147dc565b5f60a0838281528260208201528260408201528260608201528260808201520152565b15614b5e57565b60405162461bcd60e51b815260206004820152601460248201527314dd18589b1958dbda5b881b9bdd08199bdd5b9960621b6044820152606490fd5b15614ba157565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c696420646563696d616c7360801b6044820152606490fd5b8181029291811591840414171561065157565b8015613ba3576b033b2e3c9fd0803ce80000000490565b8015613ba3576b019d971e4fe8401e740000000490565b8115613ba3570490565b9190820391821161065157565b15614c3857565b60405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606490fd5b6001600160401b03918216908216039190821161065157565b60ff6007199116019060ff821161065157565b60ff166008039060ff821161065157565b60ff16604d811161065157600a0a90565b15614cc457565b60405162461bcd60e51b815260206004820152601d60248201527f4465616c20616d6f756e742062656c6f7720243230206d696e696d756d0000006044820152606490fd5b6001600160a01b03168015614d2a575f52600660205260ff60405f20541690565b50600190565b600260015414614d41576002600155565b604051633ee5aeb560e01b8152600490fd5b60ff60025416614d5f57565b60405163d93c066560e01b8152600490fd5b6008811015610d575780614d825750565b60405163f924664d60e01b8152604491614da09060048301906147be565b5f6024820152fd5b6008811015610d575760018103610d255750565b6001600160401b031642111561281657565b8215614ea2576001600160a01b039081169081614e6d5750505f80809381935af13d15614e68573d6001600160401b038111610bde5760405190614e1c601f8201601f191660200183614849565b81525f60203d92013e5b15614e2d57565b60405162461bcd60e51b8152602060048201526013602482015272115512081d1c985b9cd9995c8819985a5b1959606a1b6044820152606490fd5b614e26565b92614ea0936040519363a9059cbb60e01b6020860152166024840152604483015260448252614e9b8261482e565b615855565b565b505050565b5f5260046020525f600b6040822082815582600182015582600282015582600382015582600482015582600582015582600682015582600782015582600882015582600982015582600a820155015560056020525f6003604082208281558260018201558260028201550155565b516001600160a01b0390811691160361238b57565b602001516001600160a01b0390811691160361238b57565b6001600160401b03164211614f5357565b60405163387b2e5560e11b8152600490fd5b335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1615614f9d57565b60405163e2517d3f60e01b81523360048201525f6024820152604490fd5b805f525f60205260405f20335f5260205260ff60405f20541615614fdc5750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b6001600160a01b03165f8181527f89777fffb7045c97177d1161cd08d871365cb73d0b18f242761255a7718434cf60205260409020547fbb08418a67729a078f87bbc8d02a770929bb68f5bfdf134ae2ead6ed38e2f4ae919060ff16156150a357815f525f60205260405f20815f5260205260405f2060ff19815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b50505f90565b90815f525f60205260405f209060018060a01b031690815f5260205260ff60405f2054165f146150a357815f525f60205260405f20815f5260205260405f2060ff19815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b6001600160a01b03165f908152600d60205260409020805460ff169081615140575090565b6001600160401b0391506004015460101c16151590565b9190915f5260046020818152604090815f209460038601546127109061ffff9082615186836009541683614bd9565b0490878a015480151590815f1461544357633b9aca00670de0b6b3a76400006151af8387614bd9565b0410615432575b5f94600a8d019660ff9182895460a01c16600881101561541f578f90600614615284575b505050505050826138e0836151ee93614c24565b9660028a0196600860018060a01b0397888a54165f52525f209081549283018093116152715750559596614ea09684929080151580615265575b61524c575b505082821615615242575050915b5416614dce565b541692905061523b565b61525e91848089541691541690614dce565b5f8061522d565b50838254161515615228565b601190634e487b7160e01b5f525260245ffd5b61529b9293949598506005015460101c1685614bd9565b0494156152f15750631dcd6500670de0b6b3a76400006152bb8387614bd9565b04106152d5575b50826138e0836151ee935b935f8e6151da565b829350906138e06152e86151ee93614c03565b945050906152c2565b60028c01546001600160a01b03165f90815260068952899020895192508890829061531b856147f7565b548181161515855260081c1692019180835260088111155f14615404575061535161534b6117ee83855116614c9b565b86614bd9565b915b631dcd6500809310615371575b505050826138e0836151ee936152cd565b9080929394955081511660088111155f146153c65750615396916117ee915116614c9b565b9081156153b357916138e06151ee928594049485925b9350615360565b601289634e487b7160e01b5f525260245ffd5b6153d592506117ee9150614c88565b808202918204036153f15782916138e06151ee929485926153ac565b601188634e487b7160e01b5f525260245ffd5b6154136117ee61541992614c88565b86614c1a565b91615353565b60218e634e487b7160e01b5f525260245ffd5b925061543d83614bec565b926151b6565b60018060a01b0360028d0154165f5260068852885f208860ff8b5192615468846147f7565b548181161515845260081c1691019080825260088111155f14615528575061549961534b6117ee60ff845116614c9b565b905b633b9aca008092106154af575b50506151b6565b8051929550909160ff16600881116154f657506117ee60ff6154d2925116614c9b565b9081156154e35704925b5f806154a8565b60128b634e487b7160e01b5f525260245ffd5b61550491506117ee90614c88565b8082029182040361551557926154dc565b60118a634e487b7160e01b5f525260245ffd5b6154136117ee61553792614c88565b9061549b565b5f1981146106515760010190565b6001600160a01b03165f8181527f89777fffb7045c97177d1161cd08d871365cb73d0b18f242761255a7718434cf60205260409020547fbb08418a67729a078f87bbc8d02a770929bb68f5bfdf134ae2ead6ed38e2f4ae919060ff166150a357815f525f60205260405f20815f5260205260405f20600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b90815f525f60205260405f209060018060a01b031690815f5260205260ff60405f205416155f146150a357815f525f60205260405f20815f5260205260405f20600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b60ff600254161561567957565b604051638dfc202b60e01b8152600490fd5b600e545f91825b8281106157cc57508215615792576040926040519060209160208101904282524460408201523360601b6060820152605481526156ce8161482e565b51902006935f945f5b8581106157235760405162461bcd60e51b815260206004820152601860248201527f417262697465722073656c656374696f6e206661696c656400000000000000006044820152606490fd5b61572c816146be565b60018060a01b03809254600392831b1c165f52600d865260ff855f205416615759575b50506001016156d7565b838993991461577757505061576f60019161553d565b96905f61574f565b959793509550505061578991506146be565b9054911b1c1690565b60405162461bcd60e51b81526020600482015260126024820152714e6f2061637469766520617262697465727360701b6044820152606490fd5b6157d5816146be565b60018060a01b0391549060031b1c165f52600d60205260ff60405f205416615800575b600101615692565b9261580c60019161553d565b9390506157f8565b601154801515908161583f575b506158395761582e6158d1565b806010554260115590565b60105490565b610258915061584e9042614c24565b105f615821565b905f602091828151910182855af1156158af575f513d6158a657506001600160a01b0381163b155b6158845750565b604051635274afe760e01b81526001600160a01b039091166004820152602490fd5b6001141561587d565b6040513d5f823e3d90fd5b519069ffffffffffffffffffff8216820361046657565b600f546001600160a01b03168015615a4a5760a060049160405192838092633fabe5a360e21b82525afa805f925f926159f4575b5061591b5760405162bfc92160e01b8152600490fd5b5f8213156159af57801561597457615936610e109142614c24565b101561593f5790565b60405162461bcd60e51b815260206004820152600d60248201526c141c9a58d9481d1bdbc81bdb19609a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601360248201527250726963652064617461206973207374616c6560681b6044820152606490fd5b60405162461bcd60e51b815260206004820152601760248201527f496e76616c69642070726963652066726f6d20666565640000000000000000006044820152606490fd5b9250905060a0823d60a011615a42575b81615a1160a09383614849565b8101031261046657615a22826158ba565b506020820151615a396080606085015194016158ba565b5091905f615905565b3d9150615a04565b506010548015615a575790565b50643a352944009056fef2939da9344d885aca2f5f28e06d6a2f38fc3646202731fdc9730008761a3ed8a26469706673582212207f56edc3aa3bc610e1e962286dfbf614b9cf8007d7ec100eb4a26d90f568c59b64736f6c63430008180033
Verified Source Code Full Match
Compiler: v0.8.24+commit.e11b9ed9
EVM: shanghai
Optimization: Yes (200 runs)
YBZCore.sol 1744 lines
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; /** * @title YBZ.io - Decentralized Escrow Platform * @notice "Trustless. Transparent. Guaranteed." * @dev Main entry point for YBZ.io escrow system. * Code is Law. Immutable Code is Reliable Law. * * @author YBZ.io Team * @custom:website https://ybz.io * @custom:security-contact [email protected] * @custom:version 1.0.3 * @custom:date 2025-10-18 */ import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol"; import "./interfaces/IYBZCore.sol"; import "./libraries/DealValidation.sol"; contract YBZCore is AccessControl, ReentrancyGuard, Pausable, IYBZCore { using SafeERC20 for IERC20; using DealValidation for *; // ============ Roles ============ bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); bytes32 public constant ARBITER_ROLE = keccak256("ARBITER_ROLE"); // ============ Hardcoded Addresses (Ethereum Mainnet Only) ============ /// @notice Chainlink ETH/USD price feed (Mainnet) address public constant CHAINLINK_ETH_USD = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419; /// @notice USDT address (Mainnet) address public constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7; /// @notice USDC address (Mainnet) address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; /// @notice Initial arbiters (hardcoded) address public constant ARBITER_1 = 0xB1BB66C47DEE78b91E8AEEb6E74e66e02CA34567; address public constant ARBITER_2 = 0xBf3a2c7c9bC27e3143dF965fFa80E421f5445678; // ============ State Variables ============ /// @notice Deal counter uint256 private _dealIdCounter; /// @notice Stablecoin configuration struct StablecoinInfo { bool isActive; // Whether this stablecoin is supported uint8 decimals; // Token decimals (6 for USDT/USDC, 18 for DAI) } /// @notice All deals mapping(uint256 => Deal) private _deals; /// @notice Dispute resolutions mapping(uint256 => DisputeResolution) private _resolutions; /// @notice Supported stablecoins registry (replaces tokenWhitelist for ERC20) /// @dev address(0) is reserved for ETH (not a stablecoin) mapping(address => StablecoinInfo) public stablecoins; /// @notice List of all registered stablecoin addresses address[] public stablecoinList; /// @notice Accumulated platform fees by token (treasury balance) /// @dev token => accumulated fee amount mapping(address => uint256) public accumulatedFees; // ============ Fee Management (Integrated) ============ /// @notice Default platform fee in basis points (100 = 1%) uint16 public defaultPlatformFeeBps; /// @notice Default arbiter fee in basis points (100 = 1%) uint16 public defaultArbiterFeeBps; /// @notice Maximum fee in basis points (1000 = 10%) uint16 public constant MAX_FEE_BPS = 1000; /// @notice Tiered fee structure: amount threshold => fee in bps mapping(uint256 => uint16) public tieredPlatformFees; /// @notice Array of tier thresholds for iteration uint256[] public tierThresholds; // ============ Treasury (Integrated) ============ /// @notice Withdrawal destination address address public withdrawalAddress; // ============ Arbitration (Integrated) ============ /// @notice Arbiter information struct ArbiterInfo { bool isActive; uint256 totalCases; uint256 resolvedCases; uint256 reputation; // 0-100 score (not used currently) uint16 arbiterFeeBps; // Individual arbiter fee in basis points (can be adjusted by admin) uint64 registeredAt; } /// @notice Registered arbiters mapping(address => ArbiterInfo) public arbiters; /// @notice List of all arbiter addresses address[] public arbiterList; // ============ Price Oracle (Integrated - Chainlink) ============ /// @notice Chainlink ETH/USD price feed interface AggregatorV3Interface public ethUsdPriceFeed; /// @notice Cached ETH price (8 decimals) uint256 public cachedEthPrice; /// @notice Price cache timestamp uint256 public priceCacheTime; /// @notice Price cache duration (10 minutes) uint256 public constant PRICE_CACHE_DURATION = 10 minutes; /// @notice Minimum deal amount in USD (8 decimals: 2000_0000_0000 = $20.00) uint256 public constant MIN_DEAL_AMOUNT_USD = 20_0000_0000; // $20.00 /// @notice Minimum platform fee in USD (8 decimals: 1000_0000_0000 = $10.00) uint256 public constant MIN_FEE_USD = 10_0000_0000; // $10.00 /// @notice Minimum arbiter fee in USD (8 decimals: 5_0000_0000 = $5.00) uint256 public constant MIN_ARBITER_FEE_USD = 5_0000_0000; // $5.00 /// @notice Maximum dispute cooldown period (24 hours) /// @dev Actual cooldown is dynamic: min(24 hours, confirmWindow / 2) /// @dev This prevents buyers from being locked out of disputes in short-term deals uint64 public constant MAX_DISPUTE_COOLDOWN = 24 hours; /// @notice Platform brand message for event marketing /// @dev Displayed in blockchain explorers for brand exposure string public constant PLATFORM_MESSAGE = "ybz.io - Escrow Layer"; // ============ Events ============ // Core Events (from IYBZCore interface) // Fee Management Events event FeeWithdrawn(address indexed token, address indexed recipient, uint256 amount); // Arbitration Events (important business operations) event ArbiterRegistered(address indexed arbiter, uint64 timestamp); event ArbiterRemoved(address indexed arbiter); // ============ Errors ============ error DisputeCooldownActive(uint64 remainingTime); error InvalidFee(); error InvalidThreshold(); error TierAlreadyExists(); error TierNotFound(); error ArbiterNotFound(); error ArbiterAlreadyExists(); error ArbiterInactive(); error InsufficientBalance(); error InvalidPrice(); // ============ Constructor ============ /** * @notice Constructs the unified escrow contract * @param admin Admin address * @param withdrawalAddr Initial withdrawal address for fees * @dev Everything else is auto-configured (Chainlink, stablecoins, arbiters) */ constructor( address admin, address withdrawalAddr ) { require(admin != address(0), "Invalid admin"); require(withdrawalAddr != address(0), "Invalid withdrawal address"); // Grant roles _grantRole(DEFAULT_ADMIN_ROLE, admin); _grantRole(OPERATOR_ROLE, admin); // Initialize fee structure defaultPlatformFeeBps = 100; // 1% defaultArbiterFeeBps = 100; // 1% // Initialize treasury withdrawalAddress = withdrawalAddr; // Auto-configure Chainlink price feed and stablecoins for mainnet if (block.chainid == 1) { // Ethereum Mainnet - Auto-configure everything ethUsdPriceFeed = AggregatorV3Interface(CHAINLINK_ETH_USD); // Register hardcoded arbiters (mainnet only) _registerArbiterInternal(ARBITER_1); _registerArbiterInternal(ARBITER_2); // Auto-register USDT stablecoins[USDT] = StablecoinInfo({ isActive: true, decimals: 6 }); stablecoinList.push(USDT); // Auto-register USDC stablecoins[USDC] = StablecoinInfo({ isActive: true, decimals: 6 }); stablecoinList.push(USDC); } // For other networks (testnet/localhost), use setManualPrice() for testing _dealIdCounter = 1; // Start from 1 } // ============ Deal Creation ============ /** * @notice Creates a new ETH escrow deal * @param seller Seller address * @param termsHash IPFS hash of deal terms * @param acceptWindow Time window for seller to accept (seconds) * @param submitWindow Time window for seller to submit work (seconds) * @param confirmWindow Time window for buyer to confirm (seconds) * @param preferredArbiter Optional: pre-select arbiter (must be active, or address(0) for random) * @return dealId New deal identifier */ function createDealETH( address seller, bytes32 termsHash, uint64 acceptWindow, uint64 submitWindow, uint64 confirmWindow, address preferredArbiter ) external payable override nonReentrant whenNotPaused returns (uint256 dealId) { // Validate inputs DealValidation.validateCreateDeal( seller, msg.value, termsHash, acceptWindow, submitWindow, confirmWindow ); if (msg.sender == seller) revert DealValidation.InvalidAddress(); // Create deal dealId = _createDeal( msg.sender, seller, address(0), // ETH msg.value, termsHash, acceptWindow, submitWindow, confirmWindow, preferredArbiter ); // Get created deal data for event Deal storage newDeal = _deals[dealId]; emit DealCreated( dealId, msg.sender, seller, address(0), msg.value, newDeal.creationPriceUSD, newDeal.platformFeeBps, newDeal.arbiterFeeBps, termsHash, acceptWindow, submitWindow, confirmWindow, preferredArbiter, PLATFORM_MESSAGE ); } /** * @notice Creates a new ERC20 escrow deal (USDT/USDC only) * @param seller Seller address * @param token Token address (must be USDT or USDC) * @param amount Token amount * @param termsHash IPFS hash of deal terms * @param acceptWindow Time window for seller to accept (seconds) * @param submitWindow Time window for seller to submit work (seconds) * @param confirmWindow Time window for buyer to confirm (seconds) * @param preferredArbiter Optional: pre-select arbiter (must be active, or address(0) for random) * @return dealId New deal identifier * @dev Only stablecoins (USDT/USDC) are supported for ERC20 deals */ function createDealERC20( address seller, address token, uint256 amount, bytes32 termsHash, uint64 acceptWindow, uint64 submitWindow, uint64 confirmWindow, address preferredArbiter ) external override nonReentrant whenNotPaused returns (uint256 dealId) { // Validate token is a supported stablecoin if (token == address(0)) revert DealValidation.InvalidAddress(); StablecoinInfo memory stablecoin = stablecoins[token]; require(stablecoin.isActive, "Token is not a supported stablecoin"); // ===== Early USD Amount Check for Stablecoins (Gas Optimization) ===== // Stablecoins are 1:1 USD, convert to 8 decimals for comparison // Formula: amount * 10^(8 - tokenDecimals) // Example: 100 USDT (6 decimals) = 100000000 → 10000000000 (8 decimals) = $100 uint256 dealAmountUSD; if (stablecoin.decimals <= 8) { dealAmountUSD = amount * (10 ** (8 - stablecoin.decimals)); } else { dealAmountUSD = amount / (10 ** (stablecoin.decimals - 8)); } // Check minimum deal amount ($20 USD) require(dealAmountUSD >= MIN_DEAL_AMOUNT_USD, "Deal amount below $20 minimum"); // Minimum fee ($10) will be enforced in _releaseFunds: // - If amount * 2% < $10 → charge $10 // - If amount * 2% >= $10 → charge 2% // This way $20-$500 orders are accepted but pay $10 minimum // ===== End Early Check ===== if (seller == address(0)) revert DealValidation.InvalidAddress(); if (termsHash == bytes32(0)) revert DealValidation.InvalidTermsHash(); if (acceptWindow < DealValidation.MIN_ACCEPT_WINDOW || acceptWindow > DealValidation.MAX_ACCEPT_WINDOW) { revert DealValidation.InvalidTimeWindow(); } if (submitWindow < DealValidation.MIN_SUBMIT_WINDOW || submitWindow > DealValidation.MAX_SUBMIT_WINDOW) { revert DealValidation.InvalidTimeWindow(); } if (confirmWindow < DealValidation.MIN_CONFIRM_WINDOW || confirmWindow > DealValidation.MAX_CONFIRM_WINDOW) { revert DealValidation.InvalidTimeWindow(); } if (msg.sender == seller) revert DealValidation.InvalidAddress(); // Transfer tokens to contract IERC20(token).safeTransferFrom(msg.sender, address(this), amount); // Create deal dealId = _createDeal( msg.sender, seller, token, amount, termsHash, acceptWindow, submitWindow, confirmWindow, preferredArbiter ); // Get created deal data for event Deal storage newDeal = _deals[dealId]; emit DealCreated( dealId, msg.sender, seller, token, amount, newDeal.creationPriceUSD, newDeal.platformFeeBps, newDeal.arbiterFeeBps, termsHash, acceptWindow, submitWindow, confirmWindow, preferredArbiter, PLATFORM_MESSAGE ); } /** * @notice Internal deal creation logic */ function _createDeal( address buyer, address seller, address token, uint256 amount, bytes32 termsHash, uint64 acceptWindow, uint64 submitWindow, uint64 confirmWindow, address preferredArbiter ) internal returns (uint256 dealId) { dealId = _dealIdCounter++; // ============ Arbiter Validation ============ address assignedArbiter = address(0); // If user pre-selects an arbiter, validate it if (preferredArbiter != address(0)) { require( _isActiveArbiter(preferredArbiter), "Preferred arbiter is not active" ); assignedArbiter = preferredArbiter; } // If address(0), arbiter will be randomly assigned during dispute // ============ USD Amount Validation ============ uint256 creationPriceUSD = 0; // Check if token is a stablecoin (registered in our system) StablecoinInfo memory stablecoin = stablecoins[token]; if (stablecoin.isActive) { // ===== Stablecoin (USDT/USDC/DAI): Simple validation ===== // Already validated in createDealERC20 (early check) // Just confirm minimum deal amount using dynamic decimals uint256 dealAmountUSD; if (stablecoin.decimals <= 8) { dealAmountUSD = amount * (10 ** (8 - stablecoin.decimals)); } else { dealAmountUSD = amount / (10 ** (stablecoin.decimals - 8)); } require(dealAmountUSD >= MIN_DEAL_AMOUNT_USD, "Deal amount below $20 minimum"); // Fee will be enforced in _releaseFunds: max(amount * 2%, $10) // No rejection here - always accept if >= $20 // creationPriceUSD = 0 for stablecoins } else { // ===== ETH: Query price ONCE and save (with 10-min cache) ===== // Get ETH price and update cache if needed // If cache valid (<10 min): returns cached price (cheap) // If cache expired: queries Chainlink and updates cache (expensive, but helps next user) creationPriceUSD = _getEthPriceUSD(); require(creationPriceUSD > 0, "Invalid price"); // Calculate USD values using this single price query uint256 dealAmountUSD = (amount * creationPriceUSD) / 1e18; // Check minimum deal amount ($20 USD) require(dealAmountUSD >= MIN_DEAL_AMOUNT_USD, "Deal amount below $20 minimum"); } // ============ End USD Validation ============ // Get fee rates uint16 platformFeeBps = _getPlatformFeeBps(amount); // Get arbiter fee rate: use assigned arbiter's rate if pre-selected, otherwise default uint16 arbiterFeeBps; if (assignedArbiter != address(0)) { arbiterFeeBps = arbiters[assignedArbiter].arbiterFeeBps; } else { arbiterFeeBps = defaultArbiterFeeBps; } // Calculate deadlines uint64 now64 = uint64(block.timestamp); uint64 acceptDeadline = now64 + acceptWindow; uint64 submitDeadline = acceptDeadline + submitWindow; uint64 confirmDeadline = submitDeadline + confirmWindow; _deals[dealId] = Deal({ buyer: buyer, seller: seller, token: token, amount: amount, creationPriceUSD: creationPriceUSD, platformFeeBps: platformFeeBps, arbiterFeeBps: arbiterFeeBps, termsHash: termsHash, deliveryHash: bytes32(0), acceptDeadline: acceptDeadline, submitDeadline: submitDeadline, confirmDeadline: confirmDeadline, acceptWindow: acceptWindow, submitWindow: submitWindow, confirmWindow: confirmWindow, createdAt: now64, submittedAt: 0, arbiter: assignedArbiter, status: DealStatus.Created, refundRequested: false, // Deadline proposal fields proposedSubmitWindow: 0, proposedConfirmWindow: 0, proposedBy: address(0), proposalAccepted: false }); } // ============ Deal Workflow ============ /** * @notice Seller accepts the deal * @param dealId Deal identifier */ function acceptDeal(uint256 dealId) external override nonReentrant whenNotPaused { Deal storage deal = _deals[dealId]; // Validations DealValidation.requireStatus(deal.status, DealStatus.Created); DealValidation.requireAuthorized(deal, msg.sender, false); DealValidation.requireDeadlineNotPassed(deal.acceptDeadline); // Update status deal.status = DealStatus.Accepted; emit DealAccepted(dealId, msg.sender, deal.submitDeadline); } /** * @notice Seller rejects the deal * @param dealId Deal identifier * @dev Only seller can reject, must be in Created status, refunds buyer */ function rejectDeal(uint256 dealId) external override nonReentrant whenNotPaused { Deal storage deal = _deals[dealId]; // Validations DealValidation.requireStatus(deal.status, DealStatus.Created); DealValidation.requireAuthorized(deal, msg.sender, false); // Update status deal.status = DealStatus.Cancelled; // Refund buyer (full amount, no fees) _transferFunds(deal.token, deal.buyer, deal.amount); emit DealRejected(dealId, msg.sender); // Clean up storage _closeDeal(dealId); } /** * @notice Seller submits work * @param dealId Deal identifier * @param deliveryHash IPFS hash of delivery proof */ function submitWork(uint256 dealId, bytes32 deliveryHash) external override nonReentrant whenNotPaused { Deal storage deal = _deals[dealId]; // Validations DealValidation.requireStatus(deal.status, DealStatus.Accepted); DealValidation.requireAuthorized(deal, msg.sender, false); DealValidation.requireDeadlineNotPassed(deal.submitDeadline); if (deliveryHash == bytes32(0)) revert DealValidation.InvalidTermsHash(); // Update deal deal.deliveryHash = deliveryHash; deal.submittedAt = uint64(block.timestamp); deal.status = DealStatus.Submitted; // Recalculate confirmDeadline based on actual submission time // This gives buyer full confirmWindow starting from NOW deal.confirmDeadline = uint64(block.timestamp) + deal.confirmWindow; emit WorkSubmitted(dealId, deliveryHash, deal.confirmDeadline); } /** * @notice Buyer approves and releases payment * @param dealId Deal identifier */ function approveDeal(uint256 dealId) external override nonReentrant whenNotPaused { Deal storage deal = _deals[dealId]; // Validations DealValidation.requireStatus(deal.status, DealStatus.Submitted); DealValidation.requireAuthorized(deal, msg.sender, true); DealValidation.requireDeadlineNotPassed(deal.confirmDeadline); // Mark as approved deal.status = DealStatus.Approved; // Release funds _releaseFunds(dealId, deal.seller, 100, 0); emit DealApproved(dealId, deal.seller, deal.amount); // Clean up storage _closeDeal(dealId); } /** * @notice Raises a dispute * @param dealId Deal identifier * @param evidenceHash IPFS hash of evidence * @dev Requires 24-hour cooldown after work submission to prevent malicious disputes */ function raiseDispute(uint256 dealId, bytes32 evidenceHash) external override nonReentrant whenNotPaused { Deal storage deal = _deals[dealId]; // Can dispute in Accepted or Submitted states if (deal.status != DealStatus.Accepted && deal.status != DealStatus.Submitted) { revert DealValidation.InvalidStatus(deal.status, DealStatus.Submitted); } // Only buyer or seller can raise dispute if (msg.sender != deal.buyer && msg.sender != deal.seller) { revert DealValidation.Unauthorized(); } // Enforce dynamic cooldown period after work submission if (deal.status == DealStatus.Submitted && deal.submittedAt > 0) { // Calculate cooldown based on total confirm time (fixed at submission) // cooldown = min(24h, confirmWindow / 2) uint64 totalConfirmTime = deal.confirmDeadline - deal.submittedAt; uint64 cooldownPeriod = totalConfirmTime < (MAX_DISPUTE_COOLDOWN * 2) ? totalConfirmTime / 2 : MAX_DISPUTE_COOLDOWN; uint64 timeSinceSubmission = uint64(block.timestamp) - deal.submittedAt; if (timeSinceSubmission < cooldownPeriod) { uint64 remainingTime = cooldownPeriod - timeSinceSubmission; revert DisputeCooldownActive(remainingTime); } } // Clear any pending deadline proposal when dispute is raised if (deal.proposedBy != address(0)) { deal.proposedBy = address(0); deal.proposedSubmitWindow = 0; deal.proposedConfirmWindow = 0; deal.proposalAccepted = false; } // Select arbiter: use preferred arbiter if set, otherwise random address arbiter; if (deal.arbiter != address(0)) { // User pre-selected arbiter during deal creation arbiter = deal.arbiter; // Verify arbiter is still active require(_isActiveArbiter(arbiter), "Pre-selected arbiter is no longer active"); } else { // No preferred arbiter, select randomly arbiter = _selectRandomArbiter(); deal.arbiter = arbiter; // Update arbiter fee to match selected arbiter's rate deal.arbiterFeeBps = arbiters[arbiter].arbiterFeeBps; } deal.status = DealStatus.Disputed; // Register dispute (update arbiter stats) _registerDispute(dealId, msg.sender, arbiter); emit DisputeRaised(dealId, msg.sender, evidenceHash); } /** * @notice Resolves a dispute (arbiter only) * @param dealId Deal identifier * @param buyerRatio Buyer's share (0-100) * @param sellerRatio Seller's share (0-100) * @param evidenceHash Resolution evidence hash */ function resolveDispute( uint256 dealId, uint8 buyerRatio, uint8 sellerRatio, bytes32 evidenceHash ) external override nonReentrant whenNotPaused { Deal storage deal = _deals[dealId]; // Validations DealValidation.requireStatus(deal.status, DealStatus.Disputed); DealValidation.validateResolutionRatio(buyerRatio, sellerRatio); // Check if sender is authorized to resolve dispute bool isAssignedArbiter = (msg.sender == deal.arbiter); bool isOperator = hasRole(OPERATOR_ROLE, msg.sender); if (!isAssignedArbiter && !isOperator) { revert DealValidation.Unauthorized(); } // If arbiter is resolving, verify they are still active // This prevents deactivated arbiters from resolving disputes // Operators can always resolve (emergency override) if (isAssignedArbiter && !isOperator) { require( _isActiveArbiter(msg.sender), "Arbiter has been deactivated" ); } // Mark as resolved deal.status = DealStatus.Resolved; // Record resolution _resolutions[dealId] = DisputeResolution({ arbiter: msg.sender, buyerRatio: buyerRatio, sellerRatio: sellerRatio, evidenceHash: evidenceHash, resolvedAt: uint64(block.timestamp), arbiterFee: (deal.amount * deal.arbiterFeeBps) / 10000 }); // Release funds according to ratio _releaseFunds(dealId, address(0), buyerRatio, sellerRatio); // Update arbiter statistics _resolveDisputeRecord(msg.sender); emit DisputeResolved(dealId, msg.sender, buyerRatio, sellerRatio, evidenceHash); // Clean up _closeDeal(dealId); } /** * @notice Auto-cancel if seller doesn't accept in time * @param dealId Deal identifier * @dev Anyone can trigger after acceptDeadline */ function autoCancel(uint256 dealId) external override nonReentrant whenNotPaused { Deal storage deal = _deals[dealId]; // Must be in Created status DealValidation.requireStatus(deal.status, DealStatus.Created); // Accept deadline must have passed DealValidation.requireDeadlinePassed(deal.acceptDeadline); // Update status deal.status = DealStatus.Cancelled; // Refund buyer (full amount, no fees) _transferFunds(deal.token, deal.buyer, deal.amount); emit DealFinalized( dealId, deal.buyer, msg.sender, deal.amount, DealStatus.Cancelled, PLATFORM_MESSAGE, "Accept timeout - seller did not respond" ); // Clean up storage _closeDeal(dealId); } /** * @notice Cancel deal if seller accepted but didn't submit work * @param dealId Deal identifier * @dev Only buyer can trigger after submitDeadline */ function cancelDeal(uint256 dealId) external override nonReentrant whenNotPaused { Deal storage deal = _deals[dealId]; // Must be in Accepted status DealValidation.requireStatus(deal.status, DealStatus.Accepted); // Only buyer can cancel DealValidation.requireAuthorized(deal, msg.sender, true); // Submit deadline must have passed DealValidation.requireDeadlinePassed(deal.submitDeadline); deal.status = DealStatus.Cancelled; // Refund buyer _transferFunds(deal.token, deal.buyer, deal.amount); emit DealFinalized( dealId, deal.buyer, msg.sender, deal.amount, DealStatus.Cancelled, PLATFORM_MESSAGE, "Submit timeout - seller did not deliver" ); _closeDeal(dealId); } /** * @notice Auto-refund (buyer can trigger after submit deadline) * @param dealId Deal identifier * @dev Removed whenNotPaused to allow fund release during pause */ function autoRefund(uint256 dealId) external override nonReentrant { Deal storage deal = _deals[dealId]; DealValidation.requireStatus(deal.status, DealStatus.Accepted); DealValidation.requireAuthorized(deal, msg.sender, true); DealValidation.requireDeadlinePassed(deal.submitDeadline); deal.status = DealStatus.Cancelled; // Refund buyer _transferFunds(deal.token, deal.buyer, deal.amount); emit DealFinalized( dealId, deal.buyer, msg.sender, deal.amount, DealStatus.Cancelled, PLATFORM_MESSAGE, "Auto-refund - submit timeout" ); _closeDeal(dealId); } /** * @notice Buyer requests mutual refund (e.g., seller can't fulfill) * @param dealId Deal identifier * @dev Seller can approve with approveRefund() */ function requestRefund(uint256 dealId) external override nonReentrant whenNotPaused { Deal storage deal = _deals[dealId]; // Can request refund in Accepted or Submitted states if (deal.status != DealStatus.Accepted && deal.status != DealStatus.Submitted) { revert DealValidation.InvalidStatus(deal.status, DealStatus.Accepted); } // Only buyer can request refund DealValidation.requireAuthorized(deal, msg.sender, true); // Mark as refund requested deal.refundRequested = true; emit RefundRequested(dealId, msg.sender); } /** * @notice Seller approves buyer's refund request * @param dealId Deal identifier * @dev Triggers full refund to buyer (no fees) */ function approveRefund(uint256 dealId) external override nonReentrant whenNotPaused { Deal storage deal = _deals[dealId]; // Must have refund request pending require(deal.refundRequested, "No refund request"); // Can approve refund in Accepted or Submitted states if (deal.status != DealStatus.Accepted && deal.status != DealStatus.Submitted) { revert DealValidation.InvalidStatus(deal.status, DealStatus.Accepted); } // Only seller can approve DealValidation.requireAuthorized(deal, msg.sender, false); // Update status deal.status = DealStatus.Cancelled; // Full refund to buyer (no fees - mutual agreement) _transferFunds(deal.token, deal.buyer, deal.amount); emit DealFinalized( dealId, deal.buyer, msg.sender, deal.amount, DealStatus.Cancelled, PLATFORM_MESSAGE, "Mutual agreement - seller approved refund" ); _closeDeal(dealId); } /** * @notice Emergency fund release during contract pause * @param dealId Deal identifier * @dev Only admin can trigger, refunds to buyer as safest option */ function emergencyRelease(uint256 dealId) external override nonReentrant whenPaused onlyRole(DEFAULT_ADMIN_ROLE) { Deal storage deal = _deals[dealId]; // Can only release if not already finalized require( deal.status != DealStatus.Closed && deal.status != DealStatus.Approved, "Already finalized" ); deal.status = DealStatus.Cancelled; // Emergency refund to buyer (safest option during emergency) _transferFunds(deal.token, deal.buyer, deal.amount); emit DealFinalized( dealId, deal.buyer, msg.sender, deal.amount, DealStatus.Cancelled, PLATFORM_MESSAGE, "Emergency release during pause" ); _closeDeal(dealId); } /** * @notice Auto-release (anyone can trigger after confirm deadline) * @param dealId Deal identifier * @dev Removed whenNotPaused to allow fund release during pause */ function autoRelease(uint256 dealId) external override nonReentrant { Deal storage deal = _deals[dealId]; if (!DealValidation.canAutoRelease(deal)) { revert DealValidation.DeadlineNotReached(); } deal.status = DealStatus.Approved; // Release to seller _releaseFunds(dealId, deal.seller, 100, 0); emit DealFinalized( dealId, deal.seller, msg.sender, deal.amount, DealStatus.Closed, PLATFORM_MESSAGE, "Auto-release - buyer did not respond in time" ); _closeDeal(dealId); } // ============ Deadline Management ============ /** * @notice Propose new deadline windows for a deal * @param dealId Deal identifier * @param newSubmitWindow New submit window in seconds * @param newConfirmWindow New confirm window in seconds * @dev Only buyer or seller can propose, must be in valid status */ function proposeNewDeadline( uint256 dealId, uint64 newSubmitWindow, uint64 newConfirmWindow ) external override nonReentrant { Deal storage deal = _deals[dealId]; // Validate deal exists require(deal.buyer != address(0), "Deal does not exist"); // Only buyer or seller can propose require( msg.sender == deal.buyer || msg.sender == deal.seller, "Not authorized" ); // Can only propose in active states require( deal.status == DealStatus.Accepted || deal.status == DealStatus.Submitted, "Invalid status for deadline proposal" ); // Validate new windows require( newSubmitWindow >= DealValidation.MIN_SUBMIT_WINDOW && newSubmitWindow <= DealValidation.MAX_SUBMIT_WINDOW, "Invalid submit window" ); require( newConfirmWindow >= DealValidation.MIN_CONFIRM_WINDOW && newConfirmWindow <= DealValidation.MAX_CONFIRM_WINDOW, "Invalid confirm window" ); // Cannot propose if already has pending proposal require(deal.proposedBy == address(0), "Proposal already pending"); // Store proposal deal.proposedSubmitWindow = newSubmitWindow; deal.proposedConfirmWindow = newConfirmWindow; deal.proposedBy = msg.sender; deal.proposalAccepted = false; emit DeadlineProposed(dealId, msg.sender, newSubmitWindow, newConfirmWindow); } /** * @notice Accept deadline proposal from the other party * @param dealId Deal identifier * @dev Only the non-proposer can accept */ function acceptDeadlineProposal(uint256 dealId) external override nonReentrant { Deal storage deal = _deals[dealId]; // Validate deal exists require(deal.buyer != address(0), "Deal does not exist"); // Must have pending proposal require(deal.proposedBy != address(0), "No proposal pending"); // Cannot self-approve require(msg.sender != deal.proposedBy, "Cannot self-approve"); // Must be the other party require( msg.sender == deal.buyer || msg.sender == deal.seller, "Not authorized" ); // Update windows deal.submitWindow = deal.proposedSubmitWindow; deal.confirmWindow = deal.proposedConfirmWindow; // Recalculate deadlines if deal is in Submitted status if (deal.status == DealStatus.Submitted) { deal.confirmDeadline = uint64(block.timestamp) + deal.confirmWindow; } // Clear proposal deal.proposedBy = address(0); deal.proposedSubmitWindow = 0; deal.proposedConfirmWindow = 0; deal.proposalAccepted = true; emit DeadlineUpdated(dealId, deal.submitWindow, deal.confirmWindow, msg.sender); } /** * @notice Releases funds with fee distribution * @param dealId Deal identifier * @param primaryRecipient Primary recipient (if ratio is 100/0) * @param buyerRatio Buyer's share (0-100) * @param sellerRatio Seller's share (0-100) */ function _releaseFunds( uint256 dealId, address primaryRecipient, uint8 buyerRatio, uint8 sellerRatio ) internal { Deal storage deal = _deals[dealId]; // Calculate platform fee (percentage) uint256 platformFee = _calculatePlatformFee(deal.amount); // Enforce minimum fee ($10 USD) if (deal.creationPriceUSD > 0) { // ===== ETH: Use creation time price ===== // Calculate fee USD value using CREATION time price uint256 feeUSD = (platformFee * deal.creationPriceUSD) / 1e18; // If fee < $10, adjust to minimum if (feeUSD < MIN_FEE_USD) { // Calculate minimum fee in ETH: ($10 * 1e18) / price platformFee = (MIN_FEE_USD * 1e18) / deal.creationPriceUSD; } } else { // ===== Stablecoin: 1:1 USD ===== // Get stablecoin decimals for dynamic conversion StablecoinInfo memory stablecoin = stablecoins[deal.token]; // Convert fee to USD (token decimals → 8 decimals) uint256 feeUSD; if (stablecoin.decimals <= 8) { feeUSD = platformFee * (10 ** (8 - stablecoin.decimals)); } else { feeUSD = platformFee / (10 ** (stablecoin.decimals - 8)); } // If fee < $10, adjust to minimum if (feeUSD < MIN_FEE_USD) { // Convert $10 (8 decimals) to token decimals if (stablecoin.decimals <= 8) { platformFee = MIN_FEE_USD / (10 ** (8 - stablecoin.decimals)); } else { platformFee = MIN_FEE_USD * (10 ** (stablecoin.decimals - 8)); } } } uint256 arbiterFee = 0; // Charge arbiter fee only if disputed if (deal.status == DealStatus.Resolved) { // Use the arbiter's individual fee rate stored in the deal arbiterFee = (deal.amount * deal.arbiterFeeBps) / 10000; // Enforce minimum arbiter fee ($5 USD) if (deal.creationPriceUSD > 0) { // ===== ETH: Use creation time price ===== // Calculate arbiter fee USD value using CREATION time price uint256 arbiterFeeUSD = (arbiterFee * deal.creationPriceUSD) / 1e18; // If fee < $5, adjust to minimum if (arbiterFeeUSD < MIN_ARBITER_FEE_USD) { // Calculate minimum fee in ETH: ($5 * 1e18) / price arbiterFee = (MIN_ARBITER_FEE_USD * 1e18) / deal.creationPriceUSD; } } else { // ===== Stablecoin: 1:1 USD ===== // Get stablecoin decimals for dynamic conversion StablecoinInfo memory stablecoin = stablecoins[deal.token]; // Convert arbiter fee to USD (token decimals → 8 decimals) uint256 arbiterFeeUSD; if (stablecoin.decimals <= 8) { arbiterFeeUSD = arbiterFee * (10 ** (8 - stablecoin.decimals)); } else { arbiterFeeUSD = arbiterFee / (10 ** (stablecoin.decimals - 8)); } // If fee < $5, adjust to minimum if (arbiterFeeUSD < MIN_ARBITER_FEE_USD) { // Convert $5 (8 decimals) to token decimals if (stablecoin.decimals <= 8) { arbiterFee = MIN_ARBITER_FEE_USD / (10 ** (8 - stablecoin.decimals)); } else { arbiterFee = MIN_ARBITER_FEE_USD * (10 ** (stablecoin.decimals - 8)); } } } } uint256 netAmount = deal.amount - platformFee - arbiterFee; // Accumulate platform fee in contract (gas optimization) accumulatedFees[deal.token] += platformFee; // Send arbiter fee if applicable if (arbiterFee > 0 && deal.arbiter != address(0)) { _transferFunds(deal.token, deal.arbiter, arbiterFee); } // Distribute net amount if (buyerRatio == 100) { // Full refund to buyer or single recipient address recipient = primaryRecipient != address(0) ? primaryRecipient : deal.buyer; _transferFunds(deal.token, recipient, netAmount); } else if (sellerRatio == 100) { // Full payment to seller _transferFunds(deal.token, deal.seller, netAmount); } else { // Split according to ratio uint256 buyerAmount = (netAmount * buyerRatio) / 100; uint256 sellerAmount = netAmount - buyerAmount; if (buyerAmount > 0) { _transferFunds(deal.token, deal.buyer, buyerAmount); } if (sellerAmount > 0) { _transferFunds(deal.token, deal.seller, sellerAmount); } } } /** * @notice Transfers funds (ETH or ERC20) * @param token Token address (address(0) for ETH) * @param to Recipient address * @param amount Amount to transfer */ function _transferFunds(address token, address to, uint256 amount) internal { if (amount == 0) return; if (token == address(0)) { // Transfer ETH (bool success, ) = to.call{value: amount}(""); require(success, "ETH transfer failed"); } else { // Transfer ERC20 IERC20(token).safeTransfer(to, amount); } } /** * @notice Closes a deal and releases storage * @param dealId Deal identifier * @dev Deletes storage to get gas refund and prevent state bloat * @dev All events are preserved on-chain for audit trail */ function _closeDeal(uint256 dealId) internal { // Release storage to get gas refund (~15,000 gas) delete _deals[dealId]; delete _resolutions[dealId]; // Note: Events are preserved on-chain for historical audit // Storage cleanup doesn't affect event-based data retrieval } // ============ Admin Functions ============ /** * @notice Adds a stablecoin to the supported list * @param token Stablecoin address (USDT, USDC, DAI, etc.) * @param decimals Token decimals (6 for USDT/USDC, 18 for DAI) * @dev Only admin can add stablecoins. Each stablecoin is assumed to be 1:1 USD pegged */ function addStablecoin(address token, uint8 decimals) external onlyRole(DEFAULT_ADMIN_ROLE) { require(token != address(0), "Invalid token address"); require(decimals > 0 && decimals <= 18, "Invalid decimals"); require(!stablecoins[token].isActive, "Stablecoin already exists"); stablecoins[token] = StablecoinInfo({ isActive: true, decimals: decimals }); stablecoinList.push(token); } /** * @notice Removes a stablecoin from the supported list * @param token Stablecoin address to remove * @dev Only admin can remove. This will prevent new deals but won't affect existing ones */ function removeStablecoin(address token) external onlyRole(DEFAULT_ADMIN_ROLE) { require(stablecoins[token].isActive, "Stablecoin not found"); stablecoins[token].isActive = false; // Remove from array for (uint256 i = 0; i < stablecoinList.length; i++) { if (stablecoinList[i] == token) { stablecoinList[i] = stablecoinList[stablecoinList.length - 1]; stablecoinList.pop(); break; } } } /** * @notice Updates a stablecoin's decimals (in case of error correction) * @param token Stablecoin address * @param decimals New decimals value */ function updateStablecoinDecimals(address token, uint8 decimals) external onlyRole(DEFAULT_ADMIN_ROLE) { require(stablecoins[token].isActive, "Stablecoin not found"); require(decimals > 0 && decimals <= 18, "Invalid decimals"); stablecoins[token].decimals = decimals; } // ============ Fee Management (Admin) ============ /** * @notice Update default platform fee rate */ function updatePlatformFee(uint16 newFeeBps) external onlyRole(DEFAULT_ADMIN_ROLE) { if (newFeeBps > MAX_FEE_BPS) revert InvalidFee(); defaultPlatformFeeBps = newFeeBps; } /** * @notice Update default arbiter fee rate * @dev This is the default rate for new arbiters and non-pre-selected arbiters */ function updateDefaultArbiterFee(uint16 newFeeBps) external onlyRole(DEFAULT_ADMIN_ROLE) { if (newFeeBps > MAX_FEE_BPS) revert InvalidFee(); defaultArbiterFeeBps = newFeeBps; } // ============ Arbitration Management (Admin) ============ /** * @notice Register a new arbiter */ function registerArbiter(address arbiter) external onlyRole(DEFAULT_ADMIN_ROLE) { _registerArbiterInternal(arbiter); } /** * @notice Deactivate an arbiter */ function deactivateArbiter(address arbiter) external onlyRole(DEFAULT_ADMIN_ROLE) { if (arbiters[arbiter].registeredAt == 0) revert ArbiterNotFound(); arbiters[arbiter].isActive = false; _revokeRole(ARBITER_ROLE, arbiter); } /** * @notice Activate an arbiter */ function activateArbiter(address arbiter) external onlyRole(DEFAULT_ADMIN_ROLE) { if (arbiters[arbiter].registeredAt == 0) revert ArbiterNotFound(); arbiters[arbiter].isActive = true; _grantRole(ARBITER_ROLE, arbiter); } /** * @notice Remove arbiter from registry */ function removeArbiter(address arbiter) external onlyRole(DEFAULT_ADMIN_ROLE) { if (arbiters[arbiter].registeredAt == 0) revert ArbiterNotFound(); require( arbiters[arbiter].totalCases == arbiters[arbiter].resolvedCases, "Arbiter has pending cases" ); // Remove from array for (uint256 i = 0; i < arbiterList.length; i++) { if (arbiterList[i] == arbiter) { arbiterList[i] = arbiterList[arbiterList.length - 1]; arbiterList.pop(); break; } } _revokeRole(ARBITER_ROLE, arbiter); delete arbiters[arbiter]; emit ArbiterRemoved(arbiter); } /** * @notice Update individual arbiter's fee rate * @param arbiter Arbiter address * @param feeBps New fee rate in basis points (e.g., 100 = 1%, 150 = 1.5%) * @dev Allows admin to incentivize good arbiters or penalize poor ones */ function updateArbiterFee(address arbiter, uint16 feeBps) external onlyRole(DEFAULT_ADMIN_ROLE) { if (arbiters[arbiter].registeredAt == 0) revert ArbiterNotFound(); if (feeBps > MAX_FEE_BPS) revert InvalidFee(); arbiters[arbiter].arbiterFeeBps = feeBps; } /** * @notice Get all arbiters */ function getAllArbiters() external view returns (address[] memory) { return arbiterList; } /** * @notice Check if a... // [truncated — 61235 bytes total]
DealValidation.sol 154 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "../interfaces/IYBZCore.sol";
/**
* @title DealValidation
* @notice Library for deal validation and state transition checks
* @dev Gas-optimized validation logic extracted to library
*/
library DealValidation {
/// @notice Minimum time windows (in seconds)
/// @dev Flexible limits to accommodate various industries
uint64 public constant MIN_ACCEPT_WINDOW = 1 hours; // Min: 1 hour (quick response)
uint64 public constant MIN_SUBMIT_WINDOW = 1 hours; // Min: 1 hour (small tasks like translation)
uint64 public constant MIN_CONFIRM_WINDOW = 1 hours; // Min: 1 hour (quick verification)
/// @notice Maximum time windows (in seconds)
/// @dev Max limits prevent indefinite locks
uint64 public constant MAX_ACCEPT_WINDOW = 30 days; // Max: 30 days
uint64 public constant MAX_SUBMIT_WINDOW = 180 days; // Max: 6 months (supply chain, custom manufacturing)
uint64 public constant MAX_CONFIRM_WINDOW = 30 days; // Max: 30 days
/// @notice Minimum deal amount (to prevent spam)
uint256 public constant MIN_DEAL_AMOUNT = 0.001 ether;
/// @notice Maximum fee in basis points (10%)
uint16 public constant MAX_FEE_BPS = 1000;
// ============ Errors ============
error InvalidAmount();
error InvalidAddress();
error InvalidTimeWindow();
error InvalidTermsHash();
error InvalidStatus(IYBZCore.DealStatus current, IYBZCore.DealStatus required);
error Unauthorized();
error DeadlinePassed();
error DeadlineNotReached();
error InvalidRatio();
// ============ Validation Functions ============
/**
* @notice Validates deal creation parameters
* @param seller Seller address
* @param amount Deal amount
* @param termsHash Terms hash
* @param acceptWindow Accept time window
* @param submitWindow Submit time window
* @param confirmWindow Confirm time window
*/
function validateCreateDeal(
address seller,
uint256 amount,
bytes32 termsHash,
uint64 acceptWindow,
uint64 submitWindow,
uint64 confirmWindow
) internal pure {
if (seller == address(0)) revert InvalidAddress();
if (amount < MIN_DEAL_AMOUNT) revert InvalidAmount();
if (termsHash == bytes32(0)) revert InvalidTermsHash();
if (acceptWindow < MIN_ACCEPT_WINDOW || acceptWindow > MAX_ACCEPT_WINDOW) {
revert InvalidTimeWindow();
}
if (submitWindow < MIN_SUBMIT_WINDOW || submitWindow > MAX_SUBMIT_WINDOW) {
revert InvalidTimeWindow();
}
if (confirmWindow < MIN_CONFIRM_WINDOW || confirmWindow > MAX_CONFIRM_WINDOW) {
revert InvalidTimeWindow();
}
}
/**
* @notice Validates state transition
* @param currentStatus Current deal status
* @param requiredStatus Required status for operation
*/
function requireStatus(
IYBZCore.DealStatus currentStatus,
IYBZCore.DealStatus requiredStatus
) internal pure {
if (currentStatus != requiredStatus) {
revert InvalidStatus(currentStatus, requiredStatus);
}
}
/**
* @notice Checks if caller is authorized for the deal
* @param deal Deal struct
* @param caller Caller address
* @param isBuyerRequired True if buyer authorization required
*/
function requireAuthorized(
IYBZCore.Deal memory deal,
address caller,
bool isBuyerRequired
) internal pure {
address authorized = isBuyerRequired ? deal.buyer : deal.seller;
if (caller != authorized) revert Unauthorized();
}
/**
* @notice Checks if deadline has passed
* @param deadline Deadline timestamp
*/
function requireDeadlinePassed(uint64 deadline) internal view {
if (block.timestamp <= deadline) revert DeadlineNotReached();
}
/**
* @notice Checks if deadline has not passed
* @param deadline Deadline timestamp
*/
function requireDeadlineNotPassed(uint64 deadline) internal view {
if (block.timestamp > deadline) revert DeadlinePassed();
}
/**
* @notice Validates dispute resolution ratios
* @param buyerRatio Buyer ratio (0-100)
* @param sellerRatio Seller ratio (0-100)
*/
function validateResolutionRatio(
uint8 buyerRatio,
uint8 sellerRatio
) internal pure {
if (buyerRatio + sellerRatio != 100) revert InvalidRatio();
}
/**
* @notice Checks if deal can be auto-cancelled (Created status only)
* @param deal Deal struct
* @dev Now only for Created status, Accepted uses cancelDeal()
*/
function canAutoCancel(IYBZCore.Deal memory deal) internal view returns (bool) {
// Can auto-cancel if Created and accept deadline passed
return deal.status == IYBZCore.DealStatus.Created &&
block.timestamp > deal.acceptDeadline;
}
/**
* @notice Checks if deal can be auto-released
* @param deal Deal struct
*/
function canAutoRelease(IYBZCore.Deal memory deal) internal view returns (bool) {
return deal.status == IYBZCore.DealStatus.Submitted &&
block.timestamp > deal.confirmDeadline;
}
}
IYBZCore.sol 226 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/**
* @title IYBZCore
* @notice Interface for YBZ Escrow Core Contract
* @dev Defines the core escrow functionality and data structures
*/
interface IYBZCore {
/// @notice Deal lifecycle status
enum DealStatus {
Created, // Deal created, waiting for seller acceptance
Accepted, // Seller accepted, waiting for work submission
Submitted, // Work submitted, waiting for buyer confirmation
Disputed, // Dispute raised, waiting for arbitration
Approved, // Deal approved, funds released
Cancelled, // Deal cancelled (timeout or manual cancellation)
Resolved, // Dispute resolved by arbitrator
Closed // Deal completed and storage cleaned
}
/// @notice Main deal structure
struct Deal {
address buyer; // Buyer address
address seller; // Seller address
address token; // Token address (address(0) for ETH)
uint256 amount; // Total amount locked
uint256 creationPriceUSD; // Token price in USD at creation (8 decimals, for ETH only)
uint16 platformFeeBps; // Platform fee in basis points
uint16 arbiterFeeBps; // Arbiter fee in basis points (only charged if disputed)
bytes32 termsHash; // IPFS hash of deal terms
bytes32 deliveryHash; // IPFS hash of delivery proof
uint64 acceptDeadline; // Deadline for seller to accept
uint64 submitDeadline; // Deadline for seller to submit work
uint64 confirmDeadline; // Deadline for buyer to confirm (recalculated on submission)
uint64 acceptWindow; // Time window for accept (stored for reference)
uint64 submitWindow; // Time window for submit (stored for reference)
uint64 confirmWindow; // Time window for confirm (used to recalculate deadline)
uint64 createdAt; // Creation timestamp
uint64 submittedAt; // Work submission timestamp (0 if not submitted)
address arbiter; // Assigned arbiter address
DealStatus status; // Current deal status
bool refundRequested; // Buyer requested mutual refund
// Deadline proposal fields
uint64 proposedSubmitWindow; // Proposed new submit window
uint64 proposedConfirmWindow; // Proposed new confirm window
address proposedBy; // Who proposed the change
bool proposalAccepted; // Whether proposal was accepted
}
/// @notice Dispute resolution data
struct DisputeResolution {
address arbiter; // Arbiter who resolved the dispute
uint8 buyerRatio; // Percentage to buyer (0-100)
uint8 sellerRatio; // Percentage to seller (0-100)
bytes32 evidenceHash; // IPFS hash of arbitration evidence
uint64 resolvedAt; // Resolution timestamp
uint256 arbiterFee; // Fee paid to arbiter
}
// ============ Events ============
event DealCreated(
uint256 indexed dealId,
address indexed buyer,
address indexed seller,
address token,
uint256 amount,
uint256 creationPriceUSD,
uint16 platformFeeBps,
uint16 arbiterFeeBps,
bytes32 termsHash,
uint64 acceptWindow,
uint64 submitWindow,
uint64 confirmWindow,
address preferredArbiter,
string platform
);
event DealAccepted(
uint256 indexed dealId,
address indexed seller,
uint64 submitDeadline
);
event WorkSubmitted(
uint256 indexed dealId,
bytes32 deliveryHash,
uint64 confirmDeadline
);
event DealApproved(
uint256 indexed dealId,
address indexed seller,
uint256 amount
);
event DisputeRaised(
uint256 indexed dealId,
address indexed initiator,
bytes32 evidenceHash
);
event DisputeResolved(
uint256 indexed dealId,
address indexed arbiter,
uint8 buyerRatio,
uint8 sellerRatio,
bytes32 evidenceHash
);
event DealCancelled(
uint256 indexed dealId,
address indexed initiator,
string reason
);
event DealFinalized(
uint256 indexed dealId,
address indexed recipient,
address indexed initiator,
uint256 amount,
DealStatus finalStatus,
string platform,
string reason
);
event RefundRequested(
uint256 indexed dealId,
address indexed buyer
);
event DeadlineProposed(
uint256 indexed dealId,
address indexed proposer,
uint64 newSubmitWindow,
uint64 newConfirmWindow
);
event DeadlineUpdated(
uint256 indexed dealId,
uint64 submitWindow,
uint64 confirmWindow,
address indexed acceptedBy
);
event DealRejected(
uint256 indexed dealId,
address indexed seller
);
// ============ Core Functions ============
function createDealETH(
address seller,
bytes32 termsHash,
uint64 acceptWindow,
uint64 submitWindow,
uint64 confirmWindow,
address preferredArbiter
) external payable returns (uint256 dealId);
function createDealERC20(
address seller,
address token,
uint256 amount,
bytes32 termsHash,
uint64 acceptWindow,
uint64 submitWindow,
uint64 confirmWindow,
address preferredArbiter
) external returns (uint256 dealId);
function acceptDeal(uint256 dealId) external;
function rejectDeal(uint256 dealId) external;
function submitWork(uint256 dealId, bytes32 deliveryHash) external;
function approveDeal(uint256 dealId) external;
function raiseDispute(uint256 dealId, bytes32 evidenceHash) external;
function resolveDispute(
uint256 dealId,
uint8 buyerRatio,
uint8 sellerRatio,
bytes32 evidenceHash
) external;
function autoCancel(uint256 dealId) external;
function cancelDeal(uint256 dealId) external;
function autoRefund(uint256 dealId) external;
function requestRefund(uint256 dealId) external;
function approveRefund(uint256 dealId) external;
function autoRelease(uint256 dealId) external;
function emergencyRelease(uint256 dealId) external;
// ============ Deadline Management ============
function proposeNewDeadline(
uint256 dealId,
uint64 newSubmitWindow,
uint64 newConfirmWindow
) external;
function acceptDeadlineProposal(uint256 dealId) external;
// ============ View Functions ============
function getDeal(uint256 dealId) external view returns (Deal memory);
function getDisputeResolution(uint256 dealId) external view returns (DisputeResolution memory);
function dealCount() external view returns (uint256);
function isTokenWhitelisted(address token) external view returns (bool);
}
AggregatorV3Interface.sol 20 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// solhint-disable-next-line interface-starts-with-i
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function getRoundData(
uint80 _roundId
) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}
SafeERC20.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
Pausable.sol 112 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
ReentrancyGuard.sol 87 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
AccessControl.sol 207 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {IERC165, ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
ERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IAccessControl.sol 98 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)
pragma solidity >=0.8.4;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted to signal this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";
Read Contract
ARBITER_1 0xd65f203a → address
ARBITER_2 0x6035ceba → address
ARBITER_ROLE 0x4d104adf → bytes32
CHAINLINK_ETH_USD 0x5ebf1d75 → address
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MAX_DISPUTE_COOLDOWN 0xd98906b1 → uint64
MAX_FEE_BPS 0xd55be8c6 → uint16
MIN_ARBITER_FEE_USD 0x4df07fe5 → uint256
MIN_DEAL_AMOUNT_USD 0x17d80419 → uint256
MIN_FEE_USD 0x929b6578 → uint256
OPERATOR_ROLE 0xf5b541a6 → bytes32
PLATFORM_MESSAGE 0xbd0bb4d3 → string
PRICE_CACHE_DURATION 0x539f51db → uint256
USDC 0x89a30271 → address
USDT 0xc54e44eb → address
accumulatedFees 0xfcf66664 → uint256
arbiterList 0x74141266 → address
arbiters 0x7bf2bb10 → bool, uint256, uint256, uint256, uint16, uint64
cachedEthPrice 0x1322ec8c → uint256
dealCount 0xeadb3c9c → uint256
defaultArbiterFeeBps 0x5be5eeea → uint16
defaultPlatformFeeBps 0xed3b7e9f → uint16
ethUsdPriceFeed 0x42f6fb29 → address
getAccumulatedFees 0x564201f9 → uint256
getAllArbiters 0x67946dd8 → address[]
getArbiterInfo 0x0c3054cd → tuple
getCachedPrice 0xfd03088b → uint256, uint256
getDeal 0x82fd5bac → tuple
getDisputeResolution 0xe61d47c5 → tuple
getRoleAdmin 0x248a9ca3 → bytes32
getStablecoinInfo 0x60e74f56 → tuple
getSupportedStablecoins 0x7c6f73eb → address[]
hasRole 0x91d14854 → bool
isActiveArbiter 0x85407c9a → bool
isTokenWhitelisted 0xb5af090f → bool
paused 0x5c975abb → bool
priceCacheTime 0x93144f50 → uint256
stablecoinList 0x4450b472 → address
stablecoins 0xfa847836 → bool, uint8
supportsInterface 0x01ffc9a7 → bool
tierThresholds 0xa100d69d → uint256
tieredPlatformFees 0x9791d492 → uint16
version 0x54fd4d50 → string
withdrawalAddress 0xf2bcd022 → address
Write Contract 36 functions
These functions modify contract state and require a wallet transaction to execute.
acceptDeadlineProposal 0x03e210cf
uint256 dealId
acceptDeal 0x7d41702e
uint256 dealId
activateArbiter 0xb64fefd9
address arbiter
addStablecoin 0xa52dba3c
address token
uint8 decimals
approveDeal 0x5f9d8efb
uint256 dealId
approveRefund 0x348a71a6
uint256 dealId
autoCancel 0x06ba0473
uint256 dealId
autoRefund 0x0993cdbe
uint256 dealId
autoRelease 0x459b860e
uint256 dealId
cancelDeal 0x31ea1a39
uint256 dealId
createDealERC20 0x7678734c
address seller
address token
uint256 amount
bytes32 termsHash
uint64 acceptWindow
uint64 submitWindow
uint64 confirmWindow
address preferredArbiter
returns: uint256
createDealETH 0x3eff50e0
address seller
bytes32 termsHash
uint64 acceptWindow
uint64 submitWindow
uint64 confirmWindow
address preferredArbiter
returns: uint256
deactivateArbiter 0x0db2ad8b
address arbiter
emergencyRelease 0x39c28c62
uint256 dealId
grantRole 0x2f2ff15d
bytes32 role
address account
pause 0x8456cb59
No parameters
proposeNewDeadline 0x94592dd3
uint256 dealId
uint64 newSubmitWindow
uint64 newConfirmWindow
raiseDispute 0x636bf26d
uint256 dealId
bytes32 evidenceHash
registerArbiter 0x1c1e42bf
address arbiter
rejectDeal 0xf7074219
uint256 dealId
removeArbiter 0x3487e08c
address arbiter
removeStablecoin 0x3b947d2b
address token
renounceRole 0x36568abe
bytes32 role
address callerConfirmation
requestRefund 0xa4b2409e
uint256 dealId
resolveDispute 0x20476974
uint256 dealId
uint8 buyerRatio
uint8 sellerRatio
bytes32 evidenceHash
revokeRole 0xd547741f
bytes32 role
address account
setManualPrice 0xd7a71868
uint256 price
submitWork 0x0a9eeded
uint256 dealId
bytes32 deliveryHash
unpause 0x3f4ba83a
No parameters
updateArbiterFee 0x90c4c34a
address arbiter
uint16 feeBps
updateDefaultArbiterFee 0xe0d1732b
uint16 newFeeBps
updatePlatformFee 0xafb06952
uint16 newFeeBps
updatePriceFeed 0x95877f78
address newFeed
updateStablecoinDecimals 0x172d4d1b
address token
uint8 decimals
updateWithdrawalAddress 0x5e72fc5d
address newAddress
withdrawFees 0xad3b1b47
address token
uint256 amount
Recent Transactions
No transactions found for this address