Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x92374eAe47585db42A8D7779B2504B776c7cE0aE
Balance 0.004000 ETH
Nonce 1
Code Size 15557 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

15557 bytes
0x6080604052600436106102295760003560e01c8063896491d711610123578063bcf12416116100ab578063dce0b4e41161006f578063dce0b4e4146106e1578063dd1105f4146106f7578063e744092e1461070a578063e74b981b1461073a578063ec87621c1461075a57600080fd5b8063bcf124161461064e578063be4dc94f14610661578063ccbdb85c14610681578063d547741f146106a1578063d94a085f146106c157600080fd5b8063a217fddf116100f2578063a217fddf14610532578063a85c38ef14610547578063b3d40040146105f8578063b789bf5214610618578063b7d862251461062e57600080fd5b8063896491d7146104b257806390469a9d146104d257806391d14854146104f2578063a0a724391461051257600080fd5b80633f4ba83a116101b15780635c975abb116101755780635c975abb1461042357806375b238fc1461043b5780637b64ee8a1461045d57806381135ab41461047d5780638456cb591461049d57600080fd5b80633f4ba83a146103765780634178617f1461038b57806346904840146103ab578063514fcac7146103e357806357d8bdf01461040357600080fd5b806326e885e3116101f857806326e885e3146102e05780632772899c14610300578063277936be146103205780632f2ff15d1461033657806336568abe1461035657600080fd5b806301ffc9a71461023557806318cee8a41461026a5780631da4dd0d1461028c578063248a9ca3146102b057600080fd5b3661023057005b600080fd5b34801561024157600080fd5b50610255610250366004613634565b61077c565b60405190151581526020015b60405180910390f35b34801561027657600080fd5b5061028a61028536600461365e565b6107b3565b005b34801561029857600080fd5b506102a260065481565b604051908152602001610261565b3480156102bc57600080fd5b506102a26102cb36600461365e565b60009081526020819052604090206001015490565b3480156102ec57600080fd5b5061028a6102fb366004613693565b610832565b34801561030c57600080fd5b5061028a61031b36600461365e565b610866565b34801561032c57600080fd5b506102a260075481565b34801561034257600080fd5b5061028a6103513660046136ae565b610bb9565b34801561036257600080fd5b5061028a6103713660046136ae565b610be3565b34801561038257600080fd5b5061028a610c5d565b34801561039757600080fd5b5061028a6103a6366004613693565b610c80565b3480156103b757600080fd5b506003546103cb906001600160a01b031681565b6040516001600160a01b039091168152602001610261565b3480156103ef57600080fd5b5061028a6103fe36600461365e565b610d3b565b34801561040f57600080fd5b5061028a61041e36600461365e565b610eb8565b34801561042f57600080fd5b5060015460ff16610255565b34801561044757600080fd5b506102a2600080516020613c7083398151915281565b34801561046957600080fd5b5061028a61047836600461365e565b611154565b34801561048957600080fd5b5061028a61049836600461365e565b61170c565b3480156104a957600080fd5b5061028a611a45565b3480156104be57600080fd5b5061028a6104cd36600461365e565b611a65565b3480156104de57600080fd5b5061028a6104ed366004613693565b611d00565b3480156104fe57600080fd5b5061025561050d3660046136ae565b611db8565b34801561051e57600080fd5b5061028a61052d36600461365e565b611de1565b34801561053e57600080fd5b506102a2600081565b34801561055357600080fd5b506105df61056236600461365e565b600860208190526000918252604090912080546001820154600283015460038401546004850154600586015460068701546007880154988801546009890154600a8a0154600b909a0154989a6001600160a01b039889169a888a169a60ff600160a01b909a048a169a98891699979896909616969495919416908d565b6040516102619d9c9b9a9998979695949392919061371b565b34801561060457600080fd5b5061028a61061336600461365e565b611e35565b34801561062457600080fd5b506102a260045481565b34801561063a57600080fd5b5061028a61064936600461365e565b612007565b61028a61065c36600461365e565b612025565b34801561066d57600080fd5b5061028a61067c366004613693565b6123d8565b34801561068d57600080fd5b5061028a61069c36600461365e565b612408565b3480156106ad57600080fd5b5061028a6106bc3660046136ae565b61252a565b3480156106cd57600080fd5b5061028a6106dc36600461365e565b61254f565b3480156106ed57600080fd5b506102a260055481565b6102a26107053660046137aa565b6126a9565b34801561071657600080fd5b50610255610725366004613693565b60096020526000908152604090205460ff1681565b34801561074657600080fd5b5061028a610755366004613693565b613121565b34801561076657600080fd5b506102a2600080516020613c5083398151915281565b60006001600160e01b03198216637965db0b60e01b14806107ad57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600080516020613c708339815191526107cb816131be565b606482111561082c5760405162461bcd60e51b815260206004820152602260248201527f436f6d6d697373696f6e20726174652063616e6e6f7420657863656564203130604482015261302560f01b60648201526084015b60405180910390fd5b50600655565b600080516020613c7083398151915261084a816131be565b610862600080516020613c5083398151915283610bb9565b5050565b61087e600080516020613c5083398151915233611db8565b61089a5760405162461bcd60e51b815260040161082390613829565b6000818152600860205260408120548291036108c85760405162461bcd60e51b815260040161082390613860565b60008281526008602052604090206009015482904211156108fb5760405162461bcd60e51b81526004016108239061388e565b60008381526008602052604090206001600a82015460ff166003811115610924576109246136da565b146109415760405162461bcd60e51b8152600401610823906138b9565b60006002820154600160a01b900460ff166003811115610963576109636136da565b146109805760405162461bcd60e51b8152600401610823906138e5565b6000606460065483600401546109969190613927565b6109a0919061393e565b905060008183600401546109b49190613960565b60038401549091506001600160a01b0316610a46576003546040516001600160a01b039091169083156108fc029084906000818181858888f19350505050158015610a03573d6000803e3d6000fd5b5060028301546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610a40573d6000803e3d6000fd5b50610b77565b600383810154905460405163a9059cbb60e01b81526001600160a01b0392831692839263a9059cbb92610a8192909116908790600401613973565b6020604051808303816000875af1158015610aa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac4919061398c565b610ae05760405162461bcd60e51b8152600401610823906139ae565b600284015460405163a9059cbb60e01b81526001600160a01b038381169263a9059cbb92610b1692909116908690600401613973565b6020604051808303816000875af1158015610b35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b59919061398c565b610b755760405162461bcd60e51b8152600401610823906139e5565b505b600a8301805460ff1916600317905560405186907f02a7d4d9472af7118644884b9a0ee443540c0027e938dd0aa35be8ecbe946c0a90600090a2505050505050565b600082815260208190526040902060010154610bd4816131be565b610bde83836131c8565b505050565b6001600160a01b0381163314610c535760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610823565b610862828261324c565b600080516020613c70833981519152610c75816131be565b610c7d6132b1565b50565b600080516020613c70833981519152610c98816131be565b6001600160a01b038216610cee5760405162461bcd60e51b815260206004820181905260248201527f546f6b656e2063616e6e6f7420626520746865207a65726f20616464726573736044820152606401610823565b6001600160a01b038216600081815260096020526040808220805460ff19166001179055517f784c8f4dbf0ffedd6e72c76501c545a70f8b203b30a26ce542bf92ba87c248a49190a25050565b600081815260086020526040812054829103610d695760405162461bcd60e51b815260040161082390613860565b6000828152600860205260409020600901548290421115610d9c5760405162461bcd60e51b81526004016108239061388e565b600083815260086020526040902060018101546001600160a01b03163314610e105760405162461bcd60e51b815260206004820152602160248201527f4f6e6c792063726561746f722063616e2063616e63656c20746865206f7264656044820152603960f91b6064820152608401610823565b6000600a82015460ff166003811115610e2b57610e2b6136da565b14610e785760405162461bcd60e51b815260206004820152601860248201527f4f726465722063616e6e6f742062652063616e63656c656400000000000000006044820152606401610823565b600a8101805460ff1916600217905560405184907ff6b49baa7f8c0b1d5c3dcd3a872c9af080a32569f8643c4fd6ab2a55102ca78690600090a250505050565b600081815260086020526040812054829103610ee65760405162461bcd60e51b815260040161082390613860565b610eee613303565b60008281526008602052604090206002600a82015460ff166003811115610f1757610f176136da565b14610f5c5760405162461bcd60e51b815260206004820152601560248201527413dc99195c881a5cc81b9bdd08191958db1a5b9959605a1b6044820152606401610823565b60018101546001600160a01b03163314610fa95760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606401610823565b6004810154156111015760038101546001600160a01b031661100b57600181015460048201546040516001600160a01b039092169181156108fc0291906000818181858888f19350505050158015611005573d6000803e3d6000fd5b506110ac565b6003810154600182015460048084015460405163a9059cbb60e01b81526001600160a01b0394851694859463a9059cbb9461104b94929091169201613973565b6020604051808303816000875af115801561106a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108e919061398c565b6110aa5760405162461bcd60e51b8152600401610823906139e5565b505b600181015460048201546040519081526001600160a01b03909116907feaff4b37086828766ad3268786972c0cd24259d4c87a80f9d3963a3c3d999b0d9060200160405180910390a260006004820155611149565b60405162461bcd60e51b815260206004820152601e60248201527f4e6f20726566756e6461626c6520616d6f756e7420617661696c61626c6500006044820152606401610823565b506108626001600255565b61116c600080516020613c5083398151915233611db8565b6111885760405162461bcd60e51b815260040161082390613829565b6000818152600860205260408120548291036111b65760405162461bcd60e51b815260040161082390613860565b60008281526008602052604090206009015482904211156111e95760405162461bcd60e51b81526004016108239061388e565b60008381526008602052604090206001600a82015460ff166003811115611212576112126136da565b1461122f5760405162461bcd60e51b8152600401610823906138b9565b600280820154600160a01b900460ff166003811115611250576112506136da565b1461126d5760405162461bcd60e51b8152600401610823906138e5565b6000606460065483600401546112839190613927565b61128d919061393e565b905060008183600401546112a19190613960565b90506000606460065485600601546112b99190613927565b6112c3919061393e565b905060008185600601546112d79190613960565b60038601549091506001600160a01b0316611369576003546040516001600160a01b039091169085156108fc029086906000818181858888f19350505050158015611326573d6000803e3d6000fd5b5060028501546040516001600160a01b039091169084156108fc029085906000818181858888f19350505050158015611363573d6000803e3d6000fd5b506114d8565b600385810154905460405163a9059cbb60e01b81526001600160a01b0392831692839263a9059cbb926113a492909116908990600401613973565b6020604051808303816000875af11580156113c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113e7919061398c565b6114035760405162461bcd60e51b8152600401610823906139ae565b600286015460405163a9059cbb60e01b81526001600160a01b038381169263a9059cbb9261143992909116908890600401613973565b6020604051808303816000875af1158015611458573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147c919061398c565b6114d65760405162461bcd60e51b815260206004820152602560248201527f546f6b656e207472616e7366657220746f20636f756e74657270617274792066604482015264185a5b195960da1b6064820152608401610823565b505b60058501546001600160a01b0316611567576003546040516001600160a01b039091169083156108fc029084906000818181858888f19350505050158015611524573d6000803e3d6000fd5b5060018501546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015611561573d6000803e3d6000fd5b506116c8565b600585015460035460405163a9059cbb60e01b81526001600160a01b0392831692839263a9059cbb926115a292909116908790600401613973565b6020604051808303816000875af11580156115c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e5919061398c565b6116015760405162461bcd60e51b8152600401610823906139ae565b600186015460405163a9059cbb60e01b81526001600160a01b038381169263a9059cbb9261163792909116908690600401613973565b6020604051808303816000875af1158015611656573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167a919061398c565b6116c65760405162461bcd60e51b815260206004820181905260248201527f546f6b656e207472616e7366657220746f2063726561746f72206661696c65646044820152606401610823565b505b600a8501805460ff1916600317905560405188907f02a7d4d9472af7118644884b9a0ee443540c0027e938dd0aa35be8ecbe946c0a90600090a25050505050505050565b611724600080516020613c5083398151915233611db8565b6117405760405162461bcd60e51b815260040161082390613829565b60008181526008602052604081205482910361176e5760405162461bcd60e51b815260040161082390613860565b60008281526008602052604090206009015482904211156117a15760405162461bcd60e51b81526004016108239061388e565b60008381526008602052604090206001600a82015460ff1660038111156117ca576117ca6136da565b146117e75760405162461bcd60e51b8152600401610823906138b9565b60016002820154600160a01b900460ff166003811115611809576118096136da565b146118265760405162461bcd60e51b8152600401610823906138e5565b60006064600654836006015461183c9190613927565b611846919061393e565b9050600081836006015461185a9190613960565b60058401549091506001600160a01b03166118e6576003546040516001600160a01b039091169083156108fc029084906000818181858888f193505050501580156118a9573d6000803e3d6000fd5b5060018301546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610a40573d6000803e3d6000fd5b600583015460035460405163a9059cbb60e01b81526001600160a01b0392831692839263a9059cbb9261192192909116908790600401613973565b6020604051808303816000875af1158015611940573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611964919061398c565b6119805760405162461bcd60e51b8152600401610823906139ae565b600184015460405163a9059cbb60e01b81526001600160a01b038381169263a9059cbb926119b692909116908690600401613973565b6020604051808303816000875af11580156119d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f9919061398c565b610b755760405162461bcd60e51b815260206004820181905260248201527f546f6b656e207472616e7366657220746f2063726561746f72206661696c65646044820152606401610823565b600080516020613c70833981519152611a5d816131be565b610c7d61335a565b600081815260086020526040812054829103611a935760405162461bcd60e51b815260040161082390613860565b611a9b613303565b600082815260086020526040902060098101544211611afc5760405162461bcd60e51b815260206004820152601960248201527f4f7264657220686173206e6f74206578706972656420796574000000000000006044820152606401610823565b60018101546001600160a01b03163314611b675760405162461bcd60e51b815260206004820152602660248201527f4f6e6c792063726561746f722063616e207265636c61696d20657870697265646044820152651037b93232b960d11b6064820152608401610823565b600481015415611cbb5760038101546001600160a01b0316611bc957600181015460048201546040516001600160a01b039092169181156108fc0291906000818181858888f19350505050158015611bc3573d6000803e3d6000fd5b50611c6a565b6003810154600182015460048084015460405163a9059cbb60e01b81526001600160a01b0394851694859463a9059cbb94611c0994929091169201613973565b6020604051808303816000875af1158015611c28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4c919061398c565b611c685760405162461bcd60e51b8152600401610823906139e5565b505b600181015460048201546040519081526001600160a01b03909116907feaff4b37086828766ad3268786972c0cd24259d4c87a80f9d3963a3c3d999b0d9060200160405180910390a2600060048201555b600a8101805460ff1916600217905560405183907ff6b49baa7f8c0b1d5c3dcd3a872c9af080a32569f8643c4fd6ab2a55102ca78690600090a2506108626001600255565b600080516020613c70833981519152611d18816131be565b6001600160a01b038216611d6e5760405162461bcd60e51b815260206004820181905260248201527f546f6b656e2063616e6e6f7420626520746865207a65726f20616464726573736044820152606401610823565b6001600160a01b038216600081815260096020526040808220805460ff19169055517f4c910b69fe65a61f7531b9c5042b2329ca7179c77290aa7e2eb3afa3c8511fd39190a25050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600080516020613c70833981519152611df9816131be565b60078290556040518281527fe040ca5424a39180791e86a31e67403b33ae7faf728f566a5d4d6d9374832b869060200160405180910390a15050565b60008181526008602052604090206002015481906001600160a01b03163314611e705760405162461bcd60e51b815260040161082390613a14565b600082815260086020526040812054839103611e9e5760405162461bcd60e51b815260040161082390613860565b6000838152600860205260409020600901548390421115611ed15760405162461bcd60e51b81526004016108239061388e565b600084815260086020526040812090600a82015460ff166003811115611ef957611ef96136da565b14611f165760405162461bcd60e51b815260040161082390613a55565b60006002820154600160a01b900460ff166003811115611f3857611f386136da565b1480611f63575060036002820154600160a01b900460ff166003811115611f6157611f616136da565b145b611fc65760405162461bcd60e51b815260206004820152602e60248201527f54686973206f7264657220747970652072657175697265732066756e6473207460448201526d1bc818994819195c1bdcda5d195960921b6064820152608401610823565b600a8101805460ff1916600117905560405185907fe09badae90eb15bb2cfd6c00928d34ec8edc7f88721fd2608574e8aeb2ab170d90600090a25050505050565b600080516020613c7083398151915261201f816131be565b50600555565b60008181526008602052604090206002015481906001600160a01b031633146120605760405162461bcd60e51b815260040161082390613a14565b60008281526008602052604081205483910361208e5760405162461bcd60e51b815260040161082390613860565b60008381526008602052604090206009015483904211156120c15760405162461bcd60e51b81526004016108239061388e565b6120c9613303565b600084815260086020526040812090600a82015460ff1660038111156120f1576120f16136da565b1461210e5760405162461bcd60e51b815260040161082390613a55565b60016002820154600160a01b900460ff166003811115612130576121306136da565b148061215a5750600280820154600160a01b900460ff166003811115612158576121586136da565b145b6121c55760405162461bcd60e51b815260206004820152603660248201527f54686973206f72646572207479706520646f6573206e6f74207265717569726560448201527508199d5b991cc81d1bc818994819195c1bdcda5d195960521b6064820152608401610823565b60058101546001600160a01b031661222f578060060154341461222a5760405162461bcd60e51b815260206004820152601960248201527f496e636f72726563742045544820616d6f756e742073656e74000000000000006044820152606401610823565b61238d565b60058101546006820154604051636eb1769f60e11b81523360048201523060248201526001600160a01b0390921691829063dd62ed3e90604401602060405180830381865afa158015612286573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122aa9190613a80565b10156122f25760405162461bcd60e51b8152602060048201526017602482015276546f6b656e20616c6c6f77616e636520746f6f206c6f7760481b6044820152606401610823565b60068201546040516323b872dd60e01b815233600482015230602482015260448101919091526001600160a01b038216906323b872dd906064016020604051808303816000875af115801561234b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236f919061398c565b61238b5760405162461bcd60e51b8152600401610823906139e5565b505b600a8101805460ff1916600117905560405185907fe09badae90eb15bb2cfd6c00928d34ec8edc7f88721fd2608574e8aeb2ab170d90600090a2506123d26001600255565b50505050565b600080516020613c708339815191526123f0816131be565b610862600080516020613c508339815191528361252a565b60008181526008602052604090206002015481906001600160a01b031633146124435760405162461bcd60e51b815260040161082390613a14565b6000828152600860205260408120548391036124715760405162461bcd60e51b815260040161082390613860565b60008381526008602052604090206009015483904211156124a45760405162461bcd60e51b81526004016108239061388e565b600084815260086020526040812090600a82015460ff1660038111156124cc576124cc6136da565b146124e95760405162461bcd60e51b815260040161082390613a55565b600a8101805460ff1916600217905560405185907ff6b49baa7f8c0b1d5c3dcd3a872c9af080a32569f8643c4fd6ab2a55102ca78690600090a25050505050565b600082815260208190526040902060010154612545816131be565b610bde838361324c565b612567600080516020613c5083398151915233611db8565b6125835760405162461bcd60e51b815260040161082390613829565b6000818152600860205260408120548291036125b15760405162461bcd60e51b815260040161082390613860565b60008281526008602052604090206009015482904211156125e45760405162461bcd60e51b81526004016108239061388e565b60008381526008602052604090206001600a82015460ff16600381111561260d5761260d6136da565b1461262a5760405162461bcd60e51b8152600401610823906138b9565b60036002820154600160a01b900460ff16600381111561264c5761264c6136da565b146126695760405162461bcd60e51b8152600401610823906138e5565b600a8101805460ff1916600317905560405184907f02a7d4d9472af7118644884b9a0ee443540c0027e938dd0aa35be8ecbe946c0a90600090a250505050565b60006126b3613395565b6126bb613303565b6001600160a01b03891661271d5760405162461bcd60e51b815260206004820152602360248201527f436f756e74657270617274792063616e6e6f74206265207a65726f206164647260448201526265737360e81b6064820152608401610823565b6001600160a01b03891633036127895760405162461bcd60e51b815260206004820152602b60248201527f43726561746f7220616e6420636f756e74657270617274792063616e6e6f742060448201526a6265207468652073616d6560a81b6064820152608401610823565b60055460038960038111156127a0576127a06136da565b036127b5576007546127b29082613a99565b90505b803410156127fd5760405162461bcd60e51b8152602060048201526015602482015274125b9cdd59999a58da595b9d08199959481cd95b9d605a1b6044820152606401610823565b6001600160a01b0388161561286b576001600160a01b03881660009081526009602052604090205460ff1661286b5760405162461bcd60e51b8152602060048201526014602482015273151bdad95b881a5cc81b9bdd08185b1b1bddd95960621b6044820152606401610823565b6001600160a01b038616156128ec576001600160a01b03861660009081526009602052604090205460ff166128ec5760405162461bcd60e51b815260206004820152602160248201527f436f756e746572706172747920746f6b656e206973206e6f7420616c6c6f77656044820152601960fa1b6064820152608401610823565b6003546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015612926573d6000803e3d6000fd5b5060006129338234613960565b60048054919250600061294583613aac565b909155506000905061295a4262093a80613a99565b905060008b6003811115612970576129706136da565b03612d07576001600160a01b038a1615158061298c5750600082115b6129e35760405162461bcd60e51b815260206004820152602260248201527f43757272656e6379206d7573742062652076616c6964206f72204554482073656044820152611b9d60f21b6064820152608401610823565b60008911612a335760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606401610823565b60008611612a835760405162461bcd60e51b815260206004820152601960248201527f46696c65204944206d75737420626520737065636966696564000000000000006044820152606401610823565b8415612ae05760405162461bcd60e51b815260206004820152602660248201527f436f756e74657270617274792046696c652049442073686f756c64206e6f74206044820152651899481cd95d60d21b6064820152608401610823565b6001600160a01b038a16612b5057888214612b4b5760405162461bcd60e51b815260206004820152602560248201527f45544820616d6f756e74206d757374206d61746368207370656369666965642060448201526476616c756560d81b6064820152608401610823565b612ef8565b8115612bb45760405162461bcd60e51b815260206004820152602d60248201527f4554482073686f756c64206e6f742062652073656e7420666f7220746f6b656e60448201526c207472616e73616374696f6e7360981b6064820152608401610823565b604051636eb1769f60e11b81523360048201523060248201528a908a906001600160a01b0383169063dd62ed3e90604401602060405180830381865afa158015612c02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c269190613a80565b1015612c6e5760405162461bcd60e51b8152602060048201526017602482015276546f6b656e20616c6c6f77616e636520746f6f206c6f7760481b6044820152606401610823565b6040516323b872dd60e01b8152336004820152306024820152604481018b90526001600160a01b038216906323b872dd906064016020604051808303816000875af1158015612cc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce5919061398c565b612d015760405162461bcd60e51b8152600401610823906139e5565b50612ef8565b60018b6003811115612d1b57612d1b6136da565b03612db1576001600160a01b038816151580612d375750600087115b612d935760405162461bcd60e51b815260206004820152602760248201527f496e76616c696420636f756e74657270617274792063757272656e6379206f7260448201526608185b5bdd5b9d60ca1b6064820152608401610823565b8115612b4b5760405162461bcd60e51b815260040161082390613ac5565b60028b6003811115612dc557612dc56136da565b03612ea9576001600160a01b038a16151580612de957506001600160a01b03881615155b612e415760405162461bcd60e51b815260206004820152602360248201527f4174206c65617374206f6e652063757272656e6379206d7573742062652076616044820152621b1a5960ea1b6064820152608401610823565b600089118015612e515750600087115b612ae05760405162461bcd60e51b815260206004820152602360248201527f426f746820616d6f756e7473206d75737420626520677265617465722074686160448201526206e20360ec1b6064820152608401610823565b60038b6003811115612ebd57612ebd6136da565b03612ee0578115612b4b5760405162461bcd60e51b815260040161082390613ac5565b60405162461bcd60e51b8152600401610823906138e5565b604051806101a001604052806004548152602001336001600160a01b031681526020018d6001600160a01b031681526020018c6003811115612f3c57612f3c6136da565b81526020018b6001600160a01b031681526020018a8152602001896001600160a01b0316815260200188815260200187815260200186815260200182815260200160006003811115612f9057612f906136da565b8152602090810184905260045460009081526008825260409081902083518155918301516001830180546001600160a01b03199081166001600160a01b0393841617909155918401516002840180549384169190921690811782556060850151926001600160a81b03191617600160a01b836003811115613013576130136136da565b02179055506080820151600380830180546001600160a01b039384166001600160a01b03199182161790915560a0850151600485015560c08501516005850180549190941691161790915560e08301516006830155610100830151600783015561012083015160088301556101408301516009830155610160830151600a830180549192909160ff19169060019084908111156130b2576130b26136da565b021790555061018082015181600b01559050506004547f8267473c1006800224f491b45c617bcd55d52c4f379e56c079607a33825115b2338e8e6040516130fb93929190613b11565b60405180910390a260045493505050506131156001600255565b98975050505050505050565b600080516020613c70833981519152613139816131be565b6001600160a01b03821661319b5760405162461bcd60e51b8152602060048201526024808201527f46656520726563697069656e742063616e6e6f74206265207a65726f206164646044820152637265737360e01b6064820152608401610823565b50600380546001600160a01b0319166001600160a01b0392909216919091179055565b610c7d81336133dd565b6131d28282611db8565b610862576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556132083390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6132568282611db8565b15610862576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6132b9613436565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60028054036133545760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610823565b60028055565b613362613395565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336132e6565b60015460ff16156133db5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610823565b565b6133e78282611db8565b610862576133f48161347f565b6133ff836020613491565b604051602001613410929190613b64565b60408051601f198184030181529082905262461bcd60e51b825261082391600401613bd9565b60015460ff166133db5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610823565b60606107ad6001600160a01b03831660145b606060006134a0836002613927565b6134ab906002613a99565b67ffffffffffffffff8111156134c3576134c3613c0c565b6040519080825280601f01601f1916602001820160405280156134ed576020820181803683370190505b509050600360fc1b8160008151811061350857613508613c22565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061353757613537613c22565b60200101906001600160f81b031916908160001a905350600061355b846002613927565b613566906001613a99565b90505b60018111156135de576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061359a5761359a613c22565b1a60f81b8282815181106135b0576135b0613c22565b60200101906001600160f81b031916908160001a90535060049490941c936135d781613c38565b9050613569565b50831561362d5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610823565b9392505050565b60006020828403121561364657600080fd5b81356001600160e01b03198116811461362d57600080fd5b60006020828403121561367057600080fd5b5035919050565b80356001600160a01b038116811461368e57600080fd5b919050565b6000602082840312156136a557600080fd5b61362d82613677565b600080604083850312156136c157600080fd5b823591506136d160208401613677565b90509250929050565b634e487b7160e01b600052602160045260246000fd5b60048110610c7d57634e487b7160e01b600052602160045260246000fd5b613717816136f0565b9052565b8d81526001600160a01b038d811660208301528c1660408201526101a081016137438c6136f0565b606082018c90526001600160a01b038b8116608084015260a083018b9052891660c08301528760e083015286610100830152856101208301528461014083015261379161016083018561370e565b826101808301529e9d5050505050505050505050505050565b600080600080600080600080610100898b0312156137c757600080fd5b6137d089613677565b97506020890135600481106137e457600080fd5b96506137f260408a01613677565b95506060890135945061380760808a01613677565b979a969950949793969560a0850135955060c08501359460e001359350915050565b60208082526017908201527f43616c6c6572206973206e6f742061206d616e61676572000000000000000000604082015260600190565b60208082526014908201527313dc99195c88191bd95cc81b9bdd08195e1a5cdd60621b604082015260600190565b60208082526011908201527013dc99195c881a185cc8195e1c1a5c9959607a1b604082015260600190565b60208082526012908201527113dc99195c881b9bdd08185c1c1c9bdd995960721b604082015260600190565b602080825260129082015271496e76616c6964206f72646572207479706560701b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176107ad576107ad613911565b60008261395b57634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156107ad576107ad613911565b6001600160a01b03929092168252602082015260400190565b60006020828403121561399e57600080fd5b8151801515811461362d57600080fd5b6020808252601a908201527f436f6d6d697373696f6e207472616e73666572206661696c6564000000000000604082015260600190565b602080825260159082015274151bdad95b881d1c985b9cd9995c8819985a5b1959605a1b604082015260600190565b60208082526021908201527f4e6f7420617574686f72697a656420746f20617070726f76652f6465636c696e6040820152606560f81b606082015260800190565b6020808252601190820152704f72646572206e6f742070656e64696e6760781b604082015260600190565b600060208284031215613a9257600080fd5b5051919050565b808201808211156107ad576107ad613911565b600060018201613abe57613abe613911565b5060010190565b6020808252602c908201527f4554482073686f756c64206e6f742062652073656e7420647572696e67206f7260408201526b3232b91031b932b0ba34b7b760a11b606082015260800190565b6001600160a01b0384811682528316602082015260608101613b32836136f0565b826040830152949350505050565b60005b83811015613b5b578181015183820152602001613b43565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613b9c816017850160208801613b40565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613bcd816028840160208801613b40565b01602801949350505050565b6020815260008251806020840152613bf8816040850160208701613b40565b601f01601f19169190910160400192915050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600081613c4757613c47613911565b50600019019056fe241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a26469706673582212202300a498d2826687dfc6fa6f8262ea576355a55384026de7eb7a3ca7d335247c64736f6c634300081b0033

Verified Source Code Full Match

Compiler: v0.8.27+commit.40a35a09 EVM: paris Optimization: Yes (200 runs)
AccessControl.sol 248 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../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 => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    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 override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @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 override 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 override 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 override 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 `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @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 Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
IAccessControl.sol 88 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @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 signaling this.
     *
     * _Available since v3.1._
     */
    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, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    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 `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../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 {
    /**
     * @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);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @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 {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @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 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

    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
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

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

pragma solidity ^0.8.0;

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

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 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);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}
SignedMath.sol 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}
Strings.sol 85 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}
EscrowID.sol 411 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

interface IERC20 {
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function balanceOf(address account) external view returns (uint256);
    function allowance(address owner, address spender) external view returns (uint256);
}

contract EscrowSwap is AccessControl, Pausable, ReentrancyGuard  {
    bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
    bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");

    enum OrderType { CurrencyFile, FileCurrency, CurrencyCurrency, FileFile }
    enum OrderStatus { Pending, Approved, Declined, Completed }

    struct Order {
        uint256 id;
        address creator;
        address counterparty;
        OrderType orderType;
        address currency;
        uint256 amount;
        address counterpartyCurrency;
        uint256 counterpartyAmount;
        uint256 fileId;
        uint256 counterpartyFileId;
        uint256 expiration;
        OrderStatus status;
        uint256 msgvalue;
    }

    address public feeRecipient;
    uint256 public orderCounter;
    uint256 public creationFee = 0.01 ether;
    uint256 public platformCommissionRate = 0; 
    uint256 public fileFileFee =0 ether;
    mapping(uint256 => Order) public orders;
    mapping(address => bool) public allowedTokens;

    event OrderPlaced(uint256 indexed id, address creator, address counterparty, OrderType orderType);
    event OrderApproved(uint256 indexed id);
    event OrderDeclined(uint256 indexed id);
    event OrderCompleted(uint256 indexed id);
    event FundsWithdrawn(address indexed user, uint256 amount);
    event TokenAdded(address indexed token);
    event TokenRemoved(address indexed token);
    event FileFileFeeUpdated(uint256 newFee);

    modifier onlyManager() {
            require(hasRole(MANAGER_ROLE, msg.sender), "Caller is not a manager");
            _;
        }

    modifier onlyCounterparty(uint256 _orderId) {
        require(msg.sender == orders[_orderId].counterparty, "Not authorized to approve/decline");
        _;
    }

    modifier orderExists(uint256 _orderId) {
        require(orders[_orderId].id != 0, "Order does not exist");
        _;
    }

    modifier notExpired(uint256 _orderId) {
    require(block.timestamp <= orders[_orderId].expiration, "Order has expired");
    _;
}

    constructor() {
        feeRecipient = msg.sender;

        // Grant the deployer the default admin role
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);

        // Grant the deployer the admin and manager roles
        _grantRole(ADMIN_ROLE, msg.sender);
        _grantRole(MANAGER_ROLE, msg.sender);
    }

function placeOrder(
    address _counterparty,
    OrderType _orderType,
    address _currency,
    uint256 _amount,
    address _counterpartyCurrency,
    uint256 _counterpartyAmount,
    uint256 _fileId,
    uint256 _counterpartyFileId
) external payable whenNotPaused nonReentrant returns (uint256) {
    require(_counterparty != address(0), "Counterparty cannot be zero address");
    require(msg.sender != _counterparty, "Creator and counterparty cannot be the same");
    
    uint256 totalFee = creationFee;
    if (_orderType == OrderType.FileFile) {
        totalFee += fileFileFee;
    }

    require(msg.value >= totalFee, "Insufficient fee sent");

    if (_currency != address(0)) {
        require(allowedTokens[_currency], "Token is not allowed");
    }
    if (_counterpartyCurrency != address(0)) {
        require(allowedTokens[_counterpartyCurrency], "Counterparty token is not allowed");
    }

    payable(feeRecipient).transfer(totalFee);
    uint256 userEth = msg.value - totalFee;
    orderCounter++;
    uint256 expirationTime = block.timestamp + 7 days;

    if (_orderType == OrderType.CurrencyFile) {
        require(_currency != address(0) || userEth > 0, "Currency must be valid or ETH sent");
        require(_amount > 0, "Amount must be greater than 0");
        require(_fileId > 0, "File ID must be specified");
        require(_counterpartyFileId == 0, "Counterparty File ID should not be set");

        if (_currency == address(0)) {
            require(userEth == _amount, "ETH amount must match specified value");
        } else {
            require(userEth == 0, "ETH should not be sent for token transactions");
            IERC20 token = IERC20(_currency);
            require(token.allowance(msg.sender, address(this)) >= _amount, "Token allowance too low");
            require(token.transferFrom(msg.sender, address(this), _amount), "Token transfer failed");
        }
    } else if (_orderType == OrderType.FileCurrency) {
        require(_counterpartyCurrency != address(0) || _counterpartyAmount > 0, "Invalid counterparty currency or amount");
        require(userEth == 0, "ETH should not be sent during order creation");
    } else if (_orderType == OrderType.CurrencyCurrency) {
        require(_currency != address(0) || _counterpartyCurrency != address(0), "At least one currency must be valid");
        require(_amount > 0 && _counterpartyAmount > 0, "Both amounts must be greater than 0");

        if (_currency == address(0)) {
            require(userEth == _amount, "ETH amount must match specified value");
        } else {
            require(userEth == 0, "ETH should not be sent for token transactions");
            IERC20 token = IERC20(_currency);
            require(token.allowance(msg.sender, address(this)) >= _amount, "Token allowance too low");
            require(token.transferFrom(msg.sender, address(this), _amount), "Token transfer failed");
        }
    } else if (_orderType == OrderType.FileFile) {
        require(userEth == 0, "ETH should not be sent during order creation");
    } else {
        revert("Invalid order type");
    }

    orders[orderCounter] = Order({
        id: orderCounter,
        creator: msg.sender,
        counterparty: _counterparty,
        orderType: _orderType,
        currency: _currency,
        amount: _amount,
        counterpartyCurrency: _counterpartyCurrency,
        counterpartyAmount: _counterpartyAmount,
        fileId: _fileId,
        counterpartyFileId: _counterpartyFileId,
        expiration: expirationTime,
        status: OrderStatus.Pending,
        msgvalue: userEth
    });

    emit OrderPlaced(orderCounter, msg.sender, _counterparty, _orderType);
    return orderCounter;
}


    function confirmOrderWithoutFunds(uint256 _orderId)
        external
        onlyCounterparty(_orderId)
        orderExists(_orderId)
        notExpired(_orderId)
    {
        Order storage order = orders[_orderId];
        require(order.status == OrderStatus.Pending, "Order not pending");
        require(
            order.orderType == OrderType.CurrencyFile ||
            order.orderType == OrderType.FileFile,
            "This order type requires funds to be deposited"
        );

        order.status = OrderStatus.Approved;
        emit OrderApproved(_orderId);
    }

    function depositCounterpartyFunds(uint256 _orderId) external payable onlyCounterparty(_orderId) orderExists(_orderId) notExpired(_orderId) nonReentrant{
        Order storage order = orders[_orderId];
        require(order.status == OrderStatus.Pending, "Order not pending");

        require(
            order.orderType == OrderType.FileCurrency || 
            order.orderType == OrderType.CurrencyCurrency,
            "This order type does not require funds to be deposited"
        );

        if (order.counterpartyCurrency == address(0)) {
            require(msg.value == order.counterpartyAmount, "Incorrect ETH amount sent");
        } else {
            IERC20 token = IERC20(order.counterpartyCurrency);
            require(token.allowance(msg.sender, address(this)) >= order.counterpartyAmount, "Token allowance too low");
            require(token.transferFrom(msg.sender, address(this), order.counterpartyAmount), "Token transfer failed");
        }

        order.status = OrderStatus.Approved;
        emit OrderApproved(_orderId);
    }

    function declineOrder(uint256 _orderId)
        external
        onlyCounterparty(_orderId)
        orderExists(_orderId)
        notExpired(_orderId)
    {
        Order storage order = orders[_orderId];
        require(order.status == OrderStatus.Pending, "Order not pending");
        order.status = OrderStatus.Declined;
        emit OrderDeclined(_orderId);
        }

        function finalizeCurrencyFile(uint256 _orderId) external onlyManager orderExists(_orderId) notExpired(_orderId) {
        Order storage order = orders[_orderId];
        require(order.status == OrderStatus.Approved, "Order not approved");
        require(order.orderType == OrderType.CurrencyFile, "Invalid order type");

        uint256 commission = (order.amount * platformCommissionRate) / 100;
        uint256 amountToTransfer = order.amount - commission;

        if (order.currency == address(0)) {
            payable(feeRecipient).transfer(commission);
            payable(order.counterparty).transfer(amountToTransfer);
        } else {
            IERC20 token = IERC20(order.currency);
            require(token.transfer(feeRecipient, commission), "Commission transfer failed");
            require(token.transfer(order.counterparty, amountToTransfer), "Token transfer failed");
        }

        order.status = OrderStatus.Completed;
        emit OrderCompleted(_orderId);
    }


    function finalizeFileCurrency(uint256 _orderId) external onlyManager orderExists(_orderId) notExpired(_orderId) {
        Order storage order = orders[_orderId];
        require(order.status == OrderStatus.Approved, "Order not approved");
        require(order.orderType == OrderType.FileCurrency, "Invalid order type");

        uint256 commission = (order.counterpartyAmount * platformCommissionRate) / 100;
        uint256 amountToTransfer = order.counterpartyAmount - commission;

        if (order.counterpartyCurrency == address(0)) {
            payable(feeRecipient).transfer(commission);
            payable(order.creator).transfer(amountToTransfer);
        } else {
            IERC20 token = IERC20(order.counterpartyCurrency);
            require(token.transfer(feeRecipient, commission), "Commission transfer failed");
            require(token.transfer(order.creator, amountToTransfer), "Token transfer to creator failed");
        }

        order.status = OrderStatus.Completed;
        emit OrderCompleted(_orderId);
    }

    function finalizeCurrencyCurrency(uint256 _orderId) external onlyManager orderExists(_orderId) notExpired(_orderId) {
    Order storage order = orders[_orderId];
    require(order.status == OrderStatus.Approved, "Order not approved");
    require(order.orderType == OrderType.CurrencyCurrency, "Invalid order type");

    // Calculate and deduct commission for both sides
    uint256 commissionCreator = (order.amount * platformCommissionRate) / 100;
    uint256 amountToTransferCreator = order.amount - commissionCreator;

    uint256 commissionCounterparty = (order.counterpartyAmount * platformCommissionRate) / 100;
    uint256 amountToTransferCounterparty = order.counterpartyAmount - commissionCounterparty;

    if (order.currency == address(0)) {
        payable(feeRecipient).transfer(commissionCreator);
        payable(order.counterparty).transfer(amountToTransferCreator);
    } else {
        IERC20 token = IERC20(order.currency);
        require(token.transfer(feeRecipient, commissionCreator), "Commission transfer failed");
        require(token.transfer(order.counterparty, amountToTransferCreator), "Token transfer to counterparty failed");
    }

    if (order.counterpartyCurrency == address(0)) {
        payable(feeRecipient).transfer(commissionCounterparty);
        payable(order.creator).transfer(amountToTransferCounterparty);
    } else {
        IERC20 token = IERC20(order.counterpartyCurrency);
        require(token.transfer(feeRecipient, commissionCounterparty), "Commission transfer failed");
        require(token.transfer(order.creator, amountToTransferCounterparty), "Token transfer to creator failed");
    }

    order.status = OrderStatus.Completed;
    emit OrderCompleted(_orderId);
}


    function finalizeFileFile(uint256 _orderId) external onlyManager orderExists(_orderId) notExpired(_orderId) {
        Order storage order = orders[_orderId];
        require(order.status == OrderStatus.Approved, "Order not approved");
        require(order.orderType == OrderType.FileFile, "Invalid order type");
        order.status = OrderStatus.Completed;
        emit OrderCompleted(_orderId);
    }

    function withdrawDeclinedFunds(uint256 _orderId) external orderExists(_orderId) nonReentrant {
        Order storage order = orders[_orderId];
        require(order.status == OrderStatus.Declined, "Order is not declined");
        require(msg.sender == order.creator, "Not authorized");

        if (order.amount > 0) {
            if (order.currency == address(0)) {
                payable(order.creator).transfer(order.amount);
            } else {
                IERC20 token = IERC20(order.currency);
                require(token.transfer(order.creator, order.amount), "Token transfer failed");
            }

            emit FundsWithdrawn(order.creator, order.amount);
            order.amount = 0;
        } else {
            revert("No refundable amount available");
        }
    }

    function cancelOrder(uint256 _orderId) external orderExists(_orderId) notExpired(_orderId) {
        Order storage order = orders[_orderId];

        require(msg.sender == order.creator, "Only creator can cancel the order");
        require(order.status == OrderStatus.Pending, "Order cannot be canceled");

        order.status = OrderStatus.Declined;

        emit OrderDeclined(_orderId);
    }

    function reclaimExpiredOrder(uint256 _orderId) external orderExists(_orderId) nonReentrant {
    Order storage order = orders[_orderId];
    require(block.timestamp > order.expiration, "Order has not expired yet");
    require(msg.sender == order.creator, "Only creator can reclaim expired order");

    if (order.amount > 0) {
        if (order.currency == address(0)) {
            payable(order.creator).transfer(order.amount);
        } else {
            IERC20 token = IERC20(order.currency);
            require(token.transfer(order.creator, order.amount), "Token transfer failed");
        }

        emit FundsWithdrawn(order.creator, order.amount);
        order.amount = 0;
    }

    order.status = OrderStatus.Declined;
    emit OrderDeclined(_orderId);
}


    function pause() external onlyRole(ADMIN_ROLE) {
        _pause();
    }

    function unpause() external onlyRole(ADMIN_ROLE) {
        _unpause();
    }

    function grantManagerRole(address account) external onlyRole(ADMIN_ROLE) {
        grantRole(MANAGER_ROLE, account);
    }

    function revokeManagerRole(address account) external onlyRole(ADMIN_ROLE) {
        revokeRole(MANAGER_ROLE, account);
    }

    function setCreationFee(uint256 _fee) external onlyRole(ADMIN_ROLE) {
        creationFee = _fee;
    }

    function setFeeRecipient(address _newRecipient) external onlyRole(ADMIN_ROLE) {
        require(_newRecipient != address(0), "Fee recipient cannot be zero address");
        feeRecipient = _newRecipient;
    }

    function addAllowedToken(address token) external onlyRole(ADMIN_ROLE) {
        require(token != address(0), "Token cannot be the zero address");
        allowedTokens[token] = true;
        emit TokenAdded(token);
    }

    function removeAllowedToken(address token) external onlyRole(ADMIN_ROLE) {
        require(token != address(0), "Token cannot be the zero address");
        allowedTokens[token] = false;
        emit TokenRemoved(token);
    }

    function setPlatformCommissionRate(uint256 _rate) external onlyRole(ADMIN_ROLE) {
    require(_rate <= 100, "Commission rate cannot exceed 100%");
    platformCommissionRate = _rate;
}

    function setFileFileFee(uint256 _fee) external onlyRole(ADMIN_ROLE) {
        fileFileFee = _fee;
        emit FileFileFeeUpdated(_fee);
    }
        receive() external payable {}
}

Read Contract

ADMIN_ROLE 0x75b238fc → bytes32
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MANAGER_ROLE 0xec87621c → bytes32
allowedTokens 0xe744092e → bool
creationFee 0xdce0b4e4 → uint256
feeRecipient 0x46904840 → address
fileFileFee 0x277936be → uint256
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
orderCounter 0xb789bf52 → uint256
orders 0xa85c38ef → uint256, address, address, uint8, address, uint256, address, uint256, uint256, uint256, uint256, uint8, uint256
paused 0x5c975abb → bool
platformCommissionRate 0x1da4dd0d → uint256
supportsInterface 0x01ffc9a7 → bool

Write Contract 24 functions

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

addAllowedToken 0x4178617f
address token
cancelOrder 0x514fcac7
uint256 _orderId
confirmOrderWithoutFunds 0xb3d40040
uint256 _orderId
declineOrder 0xccbdb85c
uint256 _orderId
depositCounterpartyFunds 0xbcf12416
uint256 _orderId
finalizeCurrencyCurrency 0x7b64ee8a
uint256 _orderId
finalizeCurrencyFile 0x2772899c
uint256 _orderId
finalizeFileCurrency 0x81135ab4
uint256 _orderId
finalizeFileFile 0xd94a085f
uint256 _orderId
grantManagerRole 0x26e885e3
address account
grantRole 0x2f2ff15d
bytes32 role
address account
pause 0x8456cb59
No parameters
placeOrder 0xdd1105f4
address _counterparty
uint8 _orderType
address _currency
uint256 _amount
address _counterpartyCurrency
uint256 _counterpartyAmount
uint256 _fileId
uint256 _counterpartyFileId
returns: uint256
reclaimExpiredOrder 0x896491d7
uint256 _orderId
removeAllowedToken 0x90469a9d
address token
renounceRole 0x36568abe
bytes32 role
address account
revokeManagerRole 0xbe4dc94f
address account
revokeRole 0xd547741f
bytes32 role
address account
setCreationFee 0xb7d86225
uint256 _fee
setFeeRecipient 0xe74b981b
address _newRecipient
setFileFileFee 0xa0a72439
uint256 _fee
setPlatformCommissionRate 0x18cee8a4
uint256 _rate
unpause 0x3f4ba83a
No parameters
withdrawDeclinedFunds 0x57d8bdf0
uint256 _orderId

Recent Transactions

No transactions found for this address