Address Contract Verified
Address
0x3A7F072141d048154749FA73d03cd1085D3fc6df
Balance
0 ETH
Nonce
1
Code Size
17274 bytes
Creator
0xd48e934F...2074 at tx 0x532a6ba2...a34029
Indexed Transactions
Index loading...
Contract Bytecode
17274 bytes
0x6080604052600436106102bf5760003560e01c80637cb2b79c1161016e578063d220496f116100cb578063e482eef41161007f578063eb66366111610064578063eb66366114610711578063ec56a37314610726578063f2fde38b1461075c576102f3565b8063e482eef4146106dc578063e63a391f146106fc576102f3565b8063d5c40421116100b0578063d5c404211461068f578063d72e481d146106b2578063e30c3978146106c7576102f3565b8063d220496f1461065a578063d3b5dc3b1461067a576102f3565b8063a3a992c611610122578063ca699f6d11610107578063ca699f6d14610605578063cb85809114610625578063d17958e314610645576102f3565b8063a3a992c6146105c5578063c7d316a9146105e5576102f3565b80638ee5074d116101535780638ee5074d146105655780639e9d6685146105855780639f2a5166146105a5576102f3565b80637cb2b79c146105305780638da5cb5b14610550576102f3565b80633fc8cef31161021c578063538ba7cc116101d05780635df45a37116101b55780635df45a37146104d95780636ac56103146104fb5780636b76aeca14610510576102f3565b8063538ba7cc146104b15780635609b22c146104c4576102f3565b80634781ca76116102015780634781ca76146104675780634da22a731461047c5780634e71e0c81461049c576102f3565b80633fc8cef31461043d578063439cc14a14610452576102f3565b80632329deb7116102735780632a709b14116102585780632a709b14146103db5780632c4dbed2146103fd5780633cab6dbb1461041d576102f3565b80632329deb71461038b57806323faa95d146103ad576102f3565b806306552ff3116102a457806306552ff31461032b578063176f832e1461034b5780631e7a51ac1461036b576102f3565b8063031212f0146102f85780630442839d14610300576102f3565b366102f35760085461010090046001600160a01b031633146102f157634e487b7160e01b600052600160045260246000fd5b005b600080fd5b6102f161077c565b34801561030c57600080fd5b50610315610861565b60405161032291906137f2565b60405180910390f35b34801561033757600080fd5b506102f16103463660046132c9565b61086a565b34801561035757600080fd5b506102f161036636600461350c565b610971565b34801561037757600080fd5b506102f161038636600461350c565b6109b5565b34801561039757600080fd5b506103a0610c09565b60405161032291906140a7565b3480156103b957600080fd5b506103cd6103c83660046133c9565b610c0f565b6040516103229291906137fd565b3480156103e757600080fd5b506103f06110f1565b604051610322919061371f565b34801561040957600080fd5b506102f161041836600461350c565b611100565b34801561042957600080fd5b506102f161043836600461350c565b611144565b34801561044957600080fd5b506103f06112a5565b34801561045e57600080fd5b506103a06112b9565b34801561047357600080fd5b506103a06112bf565b34801561048857600080fd5b506102f1610497366004613629565b6112c5565b3480156104a857600080fd5b506102f161130f565b6102f16104bf366004613524565b6113a8565b3480156104d057600080fd5b506103a0611700565b3480156104e557600080fd5b506104ee611706565b604051610322919061379a565b34801561050757600080fd5b506103f0611934565b34801561051c57600080fd5b506102f161052b36600461350c565b611943565b34801561053c57600080fd5b506102f161054b366004613291565b611a1f565b34801561055c57600080fd5b506103f0611a80565b34801561057157600080fd5b506102f1610580366004613291565b611a8f565b34801561059157600080fd5b506102f16105a0366004613629565b611af0565b3480156105b157600080fd5b506103a06105c0366004613291565b611f35565b3480156105d157600080fd5b506102f16105e03660046134a7565b611f47565b3480156105f157600080fd5b506102f1610600366004613629565b611f99565b34801561061157600080fd5b506102f161062036600461350c565b612020565b34801561063157600080fd5b506102f16106403660046135aa565b6123f7565b34801561065157600080fd5b506103a06126a1565b34801561066657600080fd5b506102f1610675366004613291565b6126a7565b34801561068657600080fd5b506103a0612708565b34801561069b57600080fd5b506106a461270e565b6040516103229291906140b0565b3480156106be57600080fd5b506102f1612718565b3480156106d357600080fd5b506103f0612a5a565b3480156106e857600080fd5b506102f16106f7366004613291565b612a69565b34801561070857600080fd5b506103a0612bf0565b34801561071d57600080fd5b506103f0612bf6565b34801561073257600080fd5b5061074661074136600461350c565b612c05565b6040516103229a9998979695949392919061380d565b34801561076857600080fd5b506102f1610777366004613291565b612c6a565b600a546001600160a01b0316610790612ccb565b6001600160a01b0316146107bf5760405162461bcd60e51b81526004016107b690613d4f565b60405180910390fd5b600860019054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561080f57600080fd5b505af1158015610823573d6000803e3d6000fd5b505060085461010090046001600160a01b03166000908152600d60205260408120805434955090935090915061085a908490614126565b9091555050565b60085460ff1681565b610872612ccb565b6001600160a01b0316610883611a80565b6001600160a01b0316146108a95760405162461bcd60e51b81526004016107b690613cbd565b600154600160a01b900460ff16156108d35760405162461bcd60e51b81526004016107b690613e9d565b600880546001600160a01b03958616610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909116179055600980549385166001600160a01b0319948516179055600b805492851692841692909217909155600a8054919093169116179055600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b179055565b610979612ccb565b6001600160a01b031661098a611a80565b6001600160a01b0316146109b05760405162461bcd60e51b81526004016107b690613cbd565b600555565b6000818152600c602052604090206002015481906001600160a01b03166109da612ccb565b6001600160a01b031614610a005760405162461bcd60e51b81526004016107b69061398f565b8160016000828152600c602052604090206009015460ff166005811115610a3757634e487b7160e01b600052602160045260246000fd5b14610a545760405162461bcd60e51b81526004016107b6906139ec565b6000838152600c6020526040812060058101546006909101546103e891610a7a91614275565b610a84919061413e565b6000858152600c602052604081206005015491925090610aa5908390614126565b6000868152600c6020526040902060098101805460ff1916600490811790915560085491015491925061010090046001600160a01b0390811691161415610b9a57600854604051632e1a7d4d60e01b81526101009091046001600160a01b031690632e1a7d4d90610b1a9084906004016140a7565b600060405180830381600087803b158015610b3457600080fd5b505af1158015610b48573d6000803e3d6000fd5b5050506000868152600c60205260408082206001015490516001600160a01b03909116925083156108fc0291849190818181858888f19350505050158015610b94573d6000803e3d6000fd5b50610bca565b6000858152600c602052604090206001810154600490910154610bca916001600160a01b03918216911683612ccf565b847fe982981cd8e1c2463182d6c4f655686cea868ca500ab735caa1f66c1478318b882604051610bfa91906140a7565b60405180910390a25050505050565b60075481565b600854600090819060ff16610c29575060009050806110ea565b60085461010090046001600160a01b0316610c4a57506000905060016110ea565b6008546001600160a01b03858116610100909204161415610c7157506000905060026110ea565b6009546008546040516308cd424f60e21b81526000926001600160a01b0390811692632335093c92610caf926101009092049091169060040161371f565b604080518083038186803b158015610cc657600080fd5b505afa158015610cda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfe91906134df565b50905080610d14576000600392509250506110ea565b60095460405163e486033960e01b815260009182916001600160a01b039091169063e486033990610d49908a9060040161371f565b60006040518083038186803b158015610d6157600080fd5b505afa158015610d75573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d9d9190810190613324565b90965094505050506001600160a01b03831615159050610dc75760006004945094505050506110ea565b600080836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610e0357600080fd5b505afa158015610e17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3b9190613662565b509350509250504283610e5057600654610e54565b6007545b610e5e9083614126565b1015610e7657600060059650965050505050506110ea565b60008213610e9057600060069650965050505050506110ea565b60095460085460405163e486033960e01b81526000926001600160a01b039081169263e486033992610ece926101009092049091169060040161371f565b60006040518083038186803b158015610ee657600080fd5b505afa158015610efa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f229190810190613324565b50945050505050600080826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610f6557600080fd5b505afa158015610f79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9d9190613662565b509350509250504260065482610fb39190614126565b1015610fce57600060079950995050505050505050506110ea565b60008213610feb57600060089950995050505050505050506110ea565b6000876001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561102657600080fd5b505afa15801561103a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061105e91906136b1565b61106990600a6141a4565b611073878e614275565b61107d919061413e565b90508261109282670de0b6b3a7640000614275565b61109c919061413e565b60085461010090046001600160a01b03166000908152600d6020526040902054909a508a11156110dc57600060099a509a505050505050505050506110ea565b60019a505050505050505050505b9250929050565b6009546001600160a01b031681565b611108612ccb565b6001600160a01b0316611119611a80565b6001600160a01b03161461113f5760405162461bcd60e51b81526004016107b690613cbd565b600455565b8060016000828152600c602052604090206009015460ff16600581111561117b57634e487b7160e01b600052602160045260246000fd5b146111985760405162461bcd60e51b81526004016107b6906139ec565b6000828152600c60205260409020600301546001600160a01b03161580156111da5750600b546001600160a01b03166111cf612ccb565b6001600160a01b0316145b8061120e57506000828152600c60205260409020600301546001600160a01b0316611203612ccb565b6001600160a01b0316145b8061124257506000828152600c60205260409020600201546001600160a01b0316611237612ccb565b6001600160a01b0316145b61125e5760405162461bcd60e51b81526004016107b690613cf2565b6000828152600c6020526040808220600901805460ff191660021790555183917f1f5684525b2811a02c895aaf5410849b43eaab89088d95220f6f97458254b0c191a25050565b60085461010090046001600160a01b031681565b60025481565b60045481565b6112cd612ccb565b6001600160a01b03166112de611a80565b6001600160a01b0316146113045760405162461bcd60e51b81526004016107b690613cbd565b600691909155600755565b611317612ccb565b6001600160a01b0316611328612a5a565b6001600160a01b03161461134e5760405162461bcd60e51b81526004016107b690613f72565b60018054600080546001600160a01b038084166001600160a01b031992831617808455919093169093556040519092909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3565b6000878152600c602052604081206009015460ff1660058111156113dc57634e487b7160e01b600052602160045260246000fd5b146113f95760405162461bcd60e51b81526004016107b690613a2f565b6009546040516308cd424f60e21b81526000916001600160a01b031690632335093c9061142a90889060040161371f565b604080518083038186803b15801561144157600080fd5b505afa158015611455573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147991906134df565b509050806114995760405162461bcd60e51b81526004016107b690614070565b6103e88211156114bb5760405162461bcd60e51b81526004016107b690613f15565b60008367ffffffffffffffff16116114e55760405162461bcd60e51b81526004016107b690613c29565b60006114fb4267ffffffffffffffff8616614126565b905060006103e8866002546115109190614275565b61151a919061413e565b905060006115288288614126565b6008549091506001600160a01b038981166101009092041614156115d3578034146115655760405162461bcd60e51b81526004016107b690613c86565b600860019054906101000a90046001600160a01b03166001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156115b557600080fd5b505af11580156115c9573d6000803e3d6000fd5b50505050506115f0565b6115f06115de612ccb565b6001600160a01b038a16903084612d57565b60008b8152600c6020526040902060098101805460ff19166001179055611615612ccb565b6001820180546001600160a01b03199081166001600160a01b03938416179091556002830180549091168d83161790558a161561166a576003810180546001600160a01b0319166001600160a01b038c161790555b6004810180546001600160a01b0319166001600160a01b038b16179055600581018890556002541561169f5760025460068201555b6007810184905585156116b457600881018690555b8b7ffc0022bd8885410cd6798a18c715a6adde9fa036f104bb02feb2a1e6c666a3fe8a8a8d886040516116ea9493929190613770565b60405180910390a2505050505050505050505050565b60035481565b60606000600960009054906101000a90046001600160a01b03166001600160a01b0316634ae213066040518163ffffffff1660e01b815260040160206040518083038186803b15801561175857600080fd5b505afa15801561176c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611790919061364a565b905060008167ffffffffffffffff8111156117bb57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156117f457816020015b6117e1613218565b8152602001906001900390816117d95790505b50905060005b8281101561192d576009546040517fe5df8b840000000000000000000000000000000000000000000000000000000081526000916001600160a01b03169063e5df8b849061184c9085906004016140a7565b60206040518083038186803b15801561186457600080fd5b505afa158015611878573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189c91906132ad565b9050808383815181106118bf57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b0392831690529082166000908152600d9091526040902054835184908490811061190c57634e487b7160e01b600052603260045260246000fd5b60209081029190910181015101525080611925816142d7565b9150506117fa565b5091505090565b600b546001600160a01b031681565b6000818152600c602052604090206001015481906001600160a01b0316611968612ccb565b6001600160a01b03161461198e5760405162461bcd60e51b81526004016107b690613b46565b8160016000828152600c602052604090206009015460ff1660058111156119c557634e487b7160e01b600052602160045260246000fd5b146119e25760405162461bcd60e51b81526004016107b6906139ec565b6004546000848152600c60205260409020600701544291611a0291614126565b10610a545760405162461bcd60e51b81526004016107b690613dac565b611a27612ccb565b6001600160a01b0316611a38611a80565b6001600160a01b031614611a5e5760405162461bcd60e51b81526004016107b690613cbd565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031690565b611a97612ccb565b6001600160a01b0316611aa8611a80565b6001600160a01b031614611ace5760405162461bcd60e51b81526004016107b690613cbd565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b6000828152600c602052604090206003015482906001600160a01b0316158015611b345750600b546001600160a01b0316611b29612ccb565b6001600160a01b0316145b80611b6857506000818152600c60205260409020600301546001600160a01b0316611b5d612ccb565b6001600160a01b0316145b611b845760405162461bcd60e51b81526004016107b69061402c565b8260026000828152600c602052604090206009015460ff166005811115611bbb57634e487b7160e01b600052602160045260246000fd5b14611bd85760405162461bcd60e51b81526004016107b69061394c565b6000848152600c6020526040902060050154831115611c095760405162461bcd60e51b81526004016107b690613ed4565b6000848152600c6020526040812060068101546005909101546103e891611c2f91614275565b611c39919061413e565b6000868152600c602052604081206005015491925090611c5a908690614294565b905060006103e860035483611c6f9190614275565b611c79919061413e565b90506000611c878284614294565b6005805460008b8152600c6020526040812090920154929350909186611cad8388614275565b611cb79190614275565b611cc1919061413e565b611ccb919061413e565b90506000611cd98287614294565b611ce3908a614126565b60008b8152600c6020526040902060098101805460ff1916600517905560085460049091015491925061010090046001600160a01b0390811691161415611e375760085461010090046001600160a01b0316632e1a7d4d611d448584614126565b6040518263ffffffff1660e01b8152600401611d6091906140a7565b600060405180830381600087803b158015611d7a57600080fd5b505af1158015611d8e573d6000803e3d6000fd5b5050505080600014611de35760008a8152600c60205260408082206001015490516001600160a01b039091169183156108fc02918491818181858888f19350505050158015611de1573d6000803e3d6000fd5b505b8215611e325760008a8152600c60205260408082206002015490516001600160a01b039091169185156108fc02918691818181858888f19350505050158015611e30573d6000803e3d6000fd5b505b611ea3565b8015611e6d5760008a8152600c602052604090206001810154600490910154611e6d916001600160a01b03918216911683612ccf565b8215611ea35760008a8152600c602052604090206002810154600490910154611ea3916001600160a01b03918216911685612ccf565b611ead8483614126565b60008b8152600c60209081526040808320600401546001600160a01b03168352600d90915281208054909190611ee4908490614126565b92505081905550897fa8c992a1363d1371ca22aa254d4e9b1a68dc7dcc41129bb3caf69ed0e6afac786003548386604051611f21939291906140be565b60405180910390a250505050505050505050565b600d6020526000908152604090205481565b611f4f612ccb565b6001600160a01b0316611f60611a80565b6001600160a01b031614611f865760405162461bcd60e51b81526004016107b690613cbd565b6008805460ff1916911515919091179055565b611fa1612ccb565b6001600160a01b0316611fb2611a80565b6001600160a01b031614611fd85760405162461bcd60e51b81526004016107b690613cbd565b600282905560038190556040517faf37034187441112398c97ad2254236bbcf8019afe440e07525239df8a12394b9061201490849084906140b0565b60405180910390a15050565b6000818152600c602052604090206001015481906001600160a01b0316612045612ccb565b6001600160a01b03161461206b5760405162461bcd60e51b81526004016107b690613b46565b8160016000828152600c602052604090206009015460ff1660058111156120a257634e487b7160e01b600052602160045260246000fd5b146120bf5760405162461bcd60e51b81526004016107b6906139ec565b6000838152600c60205260408120600501546003546103e8916120e191614275565b6120eb919061413e565b6000858152600c60205260408120600581015460069091015492935090916103e89161211691614275565b612120919061413e565b6000868152600c602052604081206005015491925090612141908490614294565b6000878152600c6020526040902060098101805460ff1916600317905560085460049091015491925061010090046001600160a01b039081169116141561223657600854604051632e1a7d4d60e01b81526101009091046001600160a01b031690632e1a7d4d906121b69084906004016140a7565b600060405180830381600087803b1580156121d057600080fd5b505af11580156121e4573d6000803e3d6000fd5b5050506000878152600c60205260408082206002015490516001600160a01b03909116925083156108fc0291849190818181858888f19350505050158015612230573d6000803e3d6000fd5b5061236b565b6000868152600c60205260409020600801541561233b576000868152600c60205260408120600801546103e89061226d9084614275565b612277919061413e565b6000888152600c60205260408120600281015460049091015492935090916122ac916001600160a01b03908116911684612d7e565b90508015612304576000888152600c60205260409020600201546122ff906001600160a01b03166122dd8486614294565b60008b8152600c60205260409020600401546001600160a01b03169190612ccf565b612334565b6000888152600c602052604090206002810154600490910154612334916001600160a01b03918216911685612ccf565b505061236b565b6000868152600c60205260409020600281015460049091015461236b916001600160a01b03918216911683612ccf565b6123758284614126565b6000878152600c60209081526040808320600401546001600160a01b03168352600d909152812080549091906123ac908490614126565b92505081905550857f9252f70ed196b4cc3a8d21114a1386823948b4b9e028c380c3288334f9b576b0600354836040516123e79291906140b0565b60405180910390a2505050505050565b6000828152600c602052604090206001015482906001600160a01b031661241c612ccb565b6001600160a01b0316146124425760405162461bcd60e51b81526004016107b690613b46565b8260016000828152600c602052604090206009015460ff16600581111561247957634e487b7160e01b600052602160045260246000fd5b146124965760405162461bcd60e51b81526004016107b6906139ec565b60006124ab846124a587612ead565b90612ede565b6000868152600c60205260409020600201549091506001600160a01b038083169116146124ea5760405162461bcd60e51b81526004016107b690613b05565b6000858152600c6020526040812060058101546006909101546103e89161251091614275565b61251a919061413e565b6000878152600c60205260408120600501549192509061253b908390614126565b6000888152600c6020526040902060098101805460ff1916600490811790915560085491015491925061010090046001600160a01b039081169116141561263057600854604051632e1a7d4d60e01b81526101009091046001600160a01b031690632e1a7d4d906125b09084906004016140a7565b600060405180830381600087803b1580156125ca57600080fd5b505af11580156125de573d6000803e3d6000fd5b5050506000888152600c60205260408082206001015490516001600160a01b03909116925083156108fc0291849190818181858888f1935050505015801561262a573d6000803e3d6000fd5b50612660565b6000878152600c602052604090206001810154600490910154612660916001600160a01b03918216911683612ccf565b867fe982981cd8e1c2463182d6c4f655686cea868ca500ab735caa1f66c1478318b88260405161269091906140a7565b60405180910390a250505050505050565b60065481565b6126af612ccb565b6001600160a01b03166126c0611a80565b6001600160a01b0316146126e65760405162461bcd60e51b81526004016107b690613cbd565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b60055481565b6002546003549091565b600a546001600160a01b031661272c612ccb565b6001600160a01b0316146127525760405162461bcd60e51b81526004016107b690613d4f565b600954604080517f6f16dac200000000000000000000000000000000000000000000000000000000815290516000926001600160a01b031691636f16dac29160048083019286929190829003018186803b1580156127af57600080fd5b505afa1580156127c3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526127eb91908101906133f4565b905060005b8151811015612a56576000600d600084848151811061281f57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020541115612a44576000600d600084848151811061287457634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205490506000600d60008585815181106128c557634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002081905550600860019054906101000a90046001600160a01b03166001600160a01b031683838151811061293057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b031614156129ed57600854604051632e1a7d4d60e01b81526101009091046001600160a01b031690632e1a7d4d9061297b9084906004016140a7565b600060405180830381600087803b15801561299557600080fd5b505af11580156129a9573d6000803e3d6000fd5b5050600a546040516001600160a01b03909116925083156108fc02915083906000818181858888f193505050501580156129e7573d6000803e3d6000fd5b50612a42565b600a548351612a42916001600160a01b0316908390869086908110612a2257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316612ccf9092919063ffffffff16565b505b80612a4e816142d7565b9150506127f0565b5050565b6001546001600160a01b031690565b600a546001600160a01b0316612a7d612ccb565b6001600160a01b031614612aa35760405162461bcd60e51b81526004016107b690613d4f565b600a546001600160a01b0316612acb5760405162461bcd60e51b81526004016107b690613bcc565b6001600160a01b0381166000908152600d6020526040902054612b005760405162461bcd60e51b81526004016107b690613e09565b6001600160a01b038082166000818152600d6020526040812080549190556008549092610100909104161415612bd657600854604051632e1a7d4d60e01b81526101009091046001600160a01b031690632e1a7d4d90612b649084906004016140a7565b600060405180830381600087803b158015612b7e57600080fd5b505af1158015612b92573d6000803e3d6000fd5b5050600a546040516001600160a01b03909116925083156108fc02915083906000818181858888f19350505050158015612bd0573d6000803e3d6000fd5b50612a56565b600a54612a56906001600160a01b03848116911683612ccf565b6103e881565b600a546001600160a01b031681565b600c60205260009081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460099099015497986001600160a01b03978816989688169795861696949095169492939192909160ff168a565b612c72612ccb565b6001600160a01b0316612c83611a80565b6001600160a01b031614612ca95760405162461bcd60e51b81526004016107b690613cbd565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b612d528363a9059cbb60e01b8484604051602401612cee929190613757565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612f7d565b505050565b612d78846323b872dd60e01b858585604051602401612cee93929190613733565b50505050565b6000806000612d8d8585610c0f565b9150915081612da157600092505050612ea6565b600854604051632e1a7d4d60e01b81526101009091046001600160a01b031690632e1a7d4d90612dd59084906004016140a7565b600060405180830381600087803b158015612def57600080fd5b505af1158015612e03573d6000803e3d6000fd5b50506040516001600160a01b038916925083156108fc02915083906000818181858888f19350505050158015612e3d573d6000803e3d6000fd5b5060085461010090046001600160a01b03166000908152600d602052604081208054839290612e6d908490614294565b90915550506001600160a01b0385166000908152600d602052604081208054869290612e9a908490614126565b90915550600193505050505b9392505050565b600081604051602001612ec091906136ee565b6040516020818303038152906040528051906020012090505b919050565b600080600080845160411415612f085750505060208201516040830151606084015160001a612f67565b845160401415612f4f5750505060408201516020830151907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81169060ff1c601b01612f67565b60405162461bcd60e51b81526004016107b690613915565b612f738682858561300c565b9695505050505050565b6000612fd2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166131029092919063ffffffff16565b805190915015612d525780806020019051810190612ff091906134c3565b612d525760405162461bcd60e51b81526004016107b690613fcf565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a082111561304e5760405162461bcd60e51b81526004016107b690613a66565b8360ff16601b148061306357508360ff16601c145b61307f5760405162461bcd60e51b81526004016107b690613b8a565b6000600186868686604051600081526020016040526040516130a4949392919061388d565b6020604051602081039080840390855afa1580156130c6573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166130f95760405162461bcd60e51b81526004016107b6906138de565b95945050505050565b60606131118484600085613119565b949350505050565b60608247101561313b5760405162461bcd60e51b81526004016107b690613aa8565b613144856131d9565b6131605760405162461bcd60e51b81526004016107b690613e66565b600080866001600160a01b0316858760405161317c91906136d2565b60006040518083038185875af1925050503d80600081146131b9576040519150601f19603f3d011682016040523d82523d6000602084013e6131be565b606091505b50915091506131ce8282866131df565b979650505050505050565b3b151590565b606083156131ee575081612ea6565b8251156131fe5782518084602001fd5b8160405162461bcd60e51b81526004016107b691906138ab565b604080518082019091526000808252602082015290565b600082601f83011261323f578081fd5b815161325261324d826140fe565b6140d4565b818152846020838601011115613266578283fd5b6131118260208301602087016142ab565b805169ffffffffffffffffffff81168114612ed957600080fd5b6000602082840312156132a2578081fd5b8135612ea68161431e565b6000602082840312156132be578081fd5b8151612ea68161431e565b600080600080608085870312156132de578283fd5b84356132e98161431e565b935060208501356132f98161431e565b925060408501356133098161431e565b915060608501356133198161431e565b939692955090935050565b60008060008060008060c0878903121561333c578182fd5b86516133478161431e565b602088015190965067ffffffffffffffff80821115613364578384fd5b6133708a838b0161322f565b96506040890151915080821115613385578384fd5b5061339289828a0161322f565b9450506060870151925060808701516133aa8161431e565b60a08801519092506133bb81614336565b809150509295509295509295565b600080604083850312156133db578182fd5b82356133e68161431e565b946020939093013593505050565b60006020808385031215613406578182fd5b825167ffffffffffffffff8082111561341d578384fd5b818501915085601f830112613430578384fd5b81518181111561344257613442614308565b83810291506134528483016140d4565b8181528481019084860184860187018a101561346c578788fd5b8795505b8386101561349a57805194506134858561431e565b84835260019590950194918601918601613470565b5098975050505050505050565b6000602082840312156134b8578081fd5b8135612ea681614336565b6000602082840312156134d4578081fd5b8151612ea681614336565b600080604083850312156134f1578081fd5b82516134fc81614336565b6020939093015192949293505050565b60006020828403121561351d578081fd5b5035919050565b600080600080600080600060e0888a03121561353e578485fd5b8735965060208801356135508161431e565b955060408801356135608161431e565b945060608801356135708161431e565b93506080880135925060a088013567ffffffffffffffff81168114613593578182fd5b8092505060c0880135905092959891949750929550565b600080604083850312156135bc578182fd5b82359150602083013567ffffffffffffffff8111156135d9578182fd5b8301601f810185136135e9578182fd5b80356135f761324d826140fe565b81815286602083850101111561360b578384fd5b81602084016020830137908101602001929092525090939092509050565b6000806040838503121561363b578182fd5b50508035926020909101359150565b60006020828403121561365b578081fd5b5051919050565b600080600080600060a08688031215613679578283fd5b61368286613277565b94506020860151935060408601519250606086015191506136a560808701613277565b90509295509295909350565b6000602082840312156136c2578081fd5b815160ff81168114612ea6578182fd5b600082516136e48184602087016142ab565b9190910192915050565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039485168152602081019390935292166040820152606081019190915260800190565b602080825282518282018190526000919060409081850190868401855b828110156137e557815180516001600160a01b031685528601518685015292840192908501906001016137b7565b5091979650505050505050565b901515815260200190565b9115158252602082015260400190565b8a81526001600160a01b038a81166020830152898116604083015288811660608301528716608082015260a0810186905260c0810185905260e08101849052610100810183905261014081016006831061387757634e487b7160e01b600052602160045260246000fd5b826101208301529b9a5050505050505050505050565b93845260ff9290921660208401526040830152606082015260800190565b60006020825282518060208401526138ca8160408501602087016142ab565b601f01601f19169190910160400192915050565b60208082526018908201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604082015260600190565b6020808252601f908201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604082015260600190565b60208082526023908201527f436f6e747261637420616c6c6f776564206f6e6c7920626c6f636b656420737460408201526261746560e81b606082015260800190565b60208082526026908201527f4f6e6c7920667265656c616e6365722063616e2063616c6c207468697320667560408201527f6e6374696f6e0000000000000000000000000000000000000000000000000000606082015260800190565b60208082526023908201527f436f6e747261637420616c6c6f776564206f6e6c79206372656174656420737460408201526261746560e81b606082015260800190565b60208082526016908201527f436f6e747261637420616c726561647920657869737400000000000000000000604082015260600190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604082015261756560f01b606082015260800190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60408201527f722063616c6c0000000000000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f467265656c616e636572207369676e617475726520697320696e636f727265636040820152601d60fa1b606082015260800190565b60208082526024908201527f4f6e6c7920637573746f6d65722063616e2063616c6c20746869732066756e636040820152633a34b7b760e11b606082015260800190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604082015261756560f01b606082015260800190565b60208082526021908201527f4e6f74207370656369666965642073657276696365206665652061646472657360408201527f7300000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526022908201527f4475726174696f6e206d7573742062652067726561746572207468616e207a6560408201527f726f000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601a908201527f496e636f727265637420706173736564206d73672e76616c7565000000000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602e908201527f4f6e6c79206469737075746572206f7220667265656c616e6365722063616e2060408201527f626c6f636b20636f6e7472616374000000000000000000000000000000000000606082015260800190565b60208082526032908201527f4f6e6c792073657276696365206665657320726563697069656e742063616e2060408201527f63616c6c20746869732066756e6374696f6e0000000000000000000000000000606082015260800190565b60208082526036908201527f596f752063616e6e6f7420726566756e64207468652066756e64732c2064656160408201527f646c696e6520706c757320657874726120686f75727300000000000000000000606082015260800190565b60208082526023908201527f596f752068617665206e6f20616363756d756c6174656420636f6d6d6973736960408201527f6f6e730000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600b908201527f496e697469616c697a6564000000000000000000000000000000000000000000604082015260600190565b60208082526021908201527f486967682076616c7565206f662074686520637573746f6d657220616d6f756e6040820152601d60fa1b606082015260800190565b6020808252603d908201527f50657263656e7420746f206261736520636f6e7665727420676f65732062657960408201527f6f6e6420746865206c696d6974732066726f6d203020746f2031303030000000606082015260800190565b60208082526028908201527f4f776e61626c653a2063616c6c6572206973206e6f74207468652070656e646960408201527f6e67206f776e6572000000000000000000000000000000000000000000000000606082015260800190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60408201527f6f74207375636365656400000000000000000000000000000000000000000000606082015260800190565b60208082526024908201527f4f6e6c792064697370757465722063616e2063616c6c20746869732066756e636040820152633a34b7b760e11b606082015260800190565b60208082526015908201527f4f6e6c7920616c6c6f7765642063757272656e63790000000000000000000000604082015260600190565b90815260200190565b918252602082015260400190565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff811182821017156140f6576140f6614308565b604052919050565b600067ffffffffffffffff82111561411857614118614308565b50601f01601f191660200190565b60008219821115614139576141396142f2565b500190565b60008261415957634e487b7160e01b81526012600452602481fd5b500490565b80825b6001808611614170575061419b565b818704821115614182576141826142f2565b8086161561418f57918102915b9490941c938002614161565b94509492505050565b6000612ea660001960ff8516846000826141c057506001612ea6565b816141cd57506000612ea6565b81600181146141e357600281146141ed5761421a565b6001915050612ea6565b60ff8411156141fe576141fe6142f2565b6001841b915084821115614214576142146142f2565b50612ea6565b5060208310610133831016604e8410600b841016171561424d575081810a83811115614248576142486142f2565b612ea6565b61425a848484600161415e565b80860482111561426c5761426c6142f2565b02949350505050565b600081600019048311821515161561428f5761428f6142f2565b500290565b6000828210156142a6576142a66142f2565b500390565b60005b838110156142c65781810151838201526020016142ae565b83811115612d785750506000910152565b60006000198214156142eb576142eb6142f2565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461433357600080fd5b50565b801515811461433357600080fdfea2646970667358221220de71b7c41386a1a550c30ca877e3aef3a789cc2c85125566d9d956ddcf0b889964736f6c63430008000033
Verified Source Code Full Match
Compiler: v0.8.0+commit.c7dfd78e
EVM: istanbul
Optimization: Yes (1000 runs)
ECDSA.sol 111 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
// Divide the signature in r, s and v variables
bytes32 r;
bytes32 s;
uint8 v;
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solhint-disable-next-line no-inline-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
} else if (signature.length == 64) {
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solhint-disable-next-line no-inline-assembly
assembly {
let vs := mload(add(signature, 0x40))
r := mload(add(signature, 0x20))
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
} else {
revert("ECDSA: invalid signature length");
}
return recover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value");
require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value");
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
require(signer != address(0), "ECDSA: invalid signature");
return signer;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
TokenManager.sol 69 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./access/Ownable.sol";
contract TokenManager is Ownable {
event TokenAdded(address indexed _tokenAddress);
event TokenRemoved(address indexed _tokenAddress);
struct Token {
address tokenAddress;
string name;
string symbol;
uint256 decimals;
address usdPriceContract;
bool isStable;
}
address[] public tokenAddresses;
mapping(address => Token) public tokens;
function addToken(
address _tokenAddress,
string memory _name,
string memory _symbol,
uint256 _decimals,
address _usdPriceContract,
bool _isStable
) public onlyOwner {
(bool found,) = indexOfToken(_tokenAddress);
require(!found, 'Token already added');
tokens[_tokenAddress] = Token(_tokenAddress, _name, _symbol, _decimals, _usdPriceContract, _isStable);
tokenAddresses.push(_tokenAddress);
emit TokenAdded(_tokenAddress);
}
function removeToken(
address _tokenAddress
) public onlyOwner {
(bool found, uint256 index) = indexOfToken(_tokenAddress);
require(found, 'Erc20 token not found');
if (tokenAddresses.length > 1) {
tokenAddresses[index] = tokenAddresses[tokenAddresses.length - 1];
}
tokenAddresses.pop();
delete tokens[_tokenAddress];
emit TokenRemoved(_tokenAddress);
}
function indexOfToken(address _address) public view returns (bool found, uint256 index) {
for (uint256 i = 0; i < tokenAddresses.length; i++) {
if (tokenAddresses[i] == _address) {
return (true, i);
}
}
return (false, 0);
}
function getListTokenAddresses() public view returns (address[] memory)
{
return tokenAddresses;
}
function getLengthTokenAddresses() public view returns (uint256)
{
return tokenAddresses.length;
}
}
Address.sol 189 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
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) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
LaborXContract.sol 391 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./interfaces/AggregatorV3Interface.sol";
import "./utils/ECDSA.sol";
import './access/Ownable.sol';
import './utils/SafeERC20.sol';
import './interfaces/IERC20.sol';
import './interfaces/IWETH.sol';
import "./TokenManager.sol";
contract LaborXContract is Ownable {
using SafeERC20 for IERC20;
using ECDSA for bytes32;
enum State {NULL, CREATED, BLOCKED, PAYED_TO_FREELANCER, RETURNED_FUNDS_TO_CUSTOMER, DISTRIBUTED_FUNDS_BY_ARBITER}
event ContractCreated(bytes32 indexed contractId, address token, uint256 amount, address disputer, uint256 deadline);
event ContractBlocked(bytes32 indexed contractId);
event PayedToFreelancer(bytes32 indexed contractId, uint256 freelancerFee, uint256 freelancerAmount);
event RefundedToCustomer(bytes32 indexed contractId, uint256 customerPayAmount);
event DistributedForPartials(bytes32 indexed contractId, uint256 freelancerFee, uint256 customerPayAmount, uint256 freelancerPayAmount);
event ServiceFeesChanged(uint256 customerFee, uint256 freelancerFee);
uint256 public constant FEE_PRECISION = 1000;
bool private initialized;
uint256 public customerFee = 0;
uint256 public freelancerFee = 100;
uint256 public extraDuration = 172800;
uint256 public precision = 10000000000;
uint256 public priceOutdateDelay = 14400;
uint256 public priceOutdateDelayStable = 172800;
bool public convertAvailable = true;
address public weth;
address public tokenManager;
address public serviceFeesRecipient;
address public disputer;
struct Contract {
bytes32 contractId;
address customer;
address freelancer;
address disputer;
address token;
uint256 amount;
uint256 customerFee;
uint256 deadline;
uint256 percentToBaseConvert;
State state;
}
struct ServiceFeeAccum {
address token;
uint256 amount;
}
mapping(bytes32 => Contract) public contracts;
mapping(address => uint256) public serviceFeesAccum;
function init(address _weth, address _tokenManager, address _disputer, address _serviceFeesRecipient) external onlyOwner {
require(!initialized, "Initialized");
weth = _weth;
tokenManager = _tokenManager;
disputer = _disputer;
serviceFeesRecipient = _serviceFeesRecipient;
initialized = true;
}
function createContract(
bytes32 _contractId,
address _freelancer,
address _disputer,
address _token,
uint256 _amount,
uint64 _duration,
uint256 _percentToBaseConvert
) external payable {
require(contracts[_contractId].state == State.NULL, "Contract already exist");
(bool found,) = TokenManager(tokenManager).indexOfToken(_token);
require(found, "Only allowed currency");
require((_percentToBaseConvert >= 0 && _percentToBaseConvert <= 1000), "Percent to base convert goes beyond the limits from 0 to 1000");
require(_duration > 0, "Duration must be greater than zero");
uint256 _deadline = _duration + block.timestamp;
uint256 feeAmount = customerFee * _amount / FEE_PRECISION;
uint256 amountWithFee = _amount + feeAmount;
if (_token == weth) {
require(msg.value == amountWithFee, 'Incorrect passed msg.value');
IWETH(weth).deposit{value : amountWithFee}();
} else {
IERC20(_token).safeTransferFrom(_msgSender(), address(this), amountWithFee);
}
Contract storage jobContract = contracts[_contractId];
jobContract.state = State.CREATED;
jobContract.customer = _msgSender();
jobContract.freelancer = _freelancer;
if (_disputer != address(0)) jobContract.disputer = _disputer;
jobContract.token = _token;
jobContract.amount = _amount;
if (customerFee != 0) jobContract.customerFee = customerFee;
jobContract.deadline = _deadline;
if (_percentToBaseConvert != 0) jobContract.percentToBaseConvert = _percentToBaseConvert;
emit ContractCreated(_contractId, _token, _amount, _disputer, _deadline);
}
function blockContract(bytes32 _contractId) external onlyCreatedState(_contractId) {
require(
((contracts[_contractId].disputer == address(0) && _msgSender() == disputer) || _msgSender() == contracts[_contractId].disputer) ||
_msgSender() == contracts[_contractId].freelancer,
"Only disputer or freelancer can block contract"
);
contracts[_contractId].state = State.BLOCKED;
emit ContractBlocked(_contractId);
}
function payToFreelancer(
bytes32 _contractId
) external onlyCustomer(_contractId) onlyCreatedState(_contractId) {
uint256 freelancerFeeAmount = freelancerFee * contracts[_contractId].amount / FEE_PRECISION;
uint256 customerFeeAmount = contracts[_contractId].customerFee * contracts[_contractId].amount / FEE_PRECISION;
uint256 freelancerAmount = contracts[_contractId].amount - freelancerFeeAmount;
contracts[_contractId].state = State.PAYED_TO_FREELANCER;
if (contracts[_contractId].token == weth) {
IWETH(weth).withdraw(freelancerAmount);
payable(contracts[_contractId].freelancer).transfer(freelancerAmount);
} else {
if (contracts[_contractId].percentToBaseConvert > 0) {
uint256 freelancerAmountToBase = freelancerAmount * contracts[_contractId].percentToBaseConvert / FEE_PRECISION;
bool success = _payInBase(contracts[_contractId].freelancer, contracts[_contractId].token, freelancerAmountToBase);
if (success) {
IERC20(contracts[_contractId].token).safeTransfer(contracts[_contractId].freelancer, freelancerAmount - freelancerAmountToBase);
} else {
IERC20(contracts[_contractId].token).safeTransfer(contracts[_contractId].freelancer, freelancerAmount);
}
} else {
IERC20(contracts[_contractId].token).safeTransfer(contracts[_contractId].freelancer, freelancerAmount);
}
}
serviceFeesAccum[contracts[_contractId].token] += freelancerFeeAmount + customerFeeAmount;
emit PayedToFreelancer(_contractId, freelancerFee, freelancerAmount);
}
function refundToCustomerByFreelancer(
bytes32 _contractId
) external onlyFreelancer(_contractId) onlyCreatedState(_contractId) {
uint256 customerFeeAmount = contracts[_contractId].customerFee * contracts[_contractId].amount / FEE_PRECISION;
uint256 customerAmount = contracts[_contractId].amount + customerFeeAmount;
contracts[_contractId].state = State.RETURNED_FUNDS_TO_CUSTOMER;
if (contracts[_contractId].token == weth) {
IWETH(weth).withdraw(customerAmount);
payable(contracts[_contractId].customer).transfer(customerAmount);
} else {
IERC20(contracts[_contractId].token).safeTransfer(
contracts[_contractId].customer,
customerAmount
);
}
emit RefundedToCustomer(_contractId, customerAmount);
}
function refundToCustomerByCustomer(
bytes32 _contractId
) external onlyCustomer(_contractId) onlyCreatedState(_contractId) {
require(contracts[_contractId].deadline + extraDuration < block.timestamp, "You cannot refund the funds, deadline plus extra hours");
uint256 customerFeeAmount = contracts[_contractId].customerFee * contracts[_contractId].amount / FEE_PRECISION;
uint256 customerAmount = contracts[_contractId].amount + customerFeeAmount;
contracts[_contractId].state = State.RETURNED_FUNDS_TO_CUSTOMER;
if (contracts[_contractId].token == weth) {
IWETH(weth).withdraw(customerAmount);
payable(contracts[_contractId].customer).transfer(customerAmount);
} else {
IERC20(contracts[_contractId].token).safeTransfer(
contracts[_contractId].customer,
customerAmount
);
}
emit RefundedToCustomer(_contractId, customerAmount);
}
function refundToCustomerWithFreelancerSignature(
bytes32 _contractId,
bytes memory signature
) public onlyCustomer(_contractId) onlyCreatedState(_contractId) {
address signerAddress = _contractId.toEthSignedMessageHash().recover(signature);
require(signerAddress == contracts[_contractId].freelancer, "Freelancer signature is incorrect");
uint256 customerFeeAmount = contracts[_contractId].customerFee * contracts[_contractId].amount / FEE_PRECISION;
uint256 customerAmount = contracts[_contractId].amount + customerFeeAmount;
contracts[_contractId].state = State.RETURNED_FUNDS_TO_CUSTOMER;
if (contracts[_contractId].token == weth) {
IWETH(weth).withdraw(customerAmount);
payable(contracts[_contractId].customer).transfer(customerAmount);
} else {
IERC20(contracts[_contractId].token).safeTransfer(
contracts[_contractId].customer,
customerAmount
);
}
emit RefundedToCustomer(_contractId, customerAmount);
}
function distributionForPartials(
bytes32 _contractId,
uint256 _customerAmount
) external onlyDisputer(_contractId) onlyBlockedState(_contractId) {
require(contracts[_contractId].amount >= _customerAmount, "High value of the customer amount");
uint256 customerBeginFee = contracts[_contractId].amount * contracts[_contractId].customerFee / FEE_PRECISION;
uint256 freelancerAmount = contracts[_contractId].amount - _customerAmount;
uint256 freelancerFeeAmount = freelancerAmount * freelancerFee / FEE_PRECISION;
uint256 freelancerPayAmount = freelancerAmount - freelancerFeeAmount;
uint256 customerFeeAmount = freelancerAmount * precision * customerBeginFee / contracts[_contractId].amount / precision;
uint256 customerPayAmount = _customerAmount + (customerBeginFee - customerFeeAmount);
contracts[_contractId].state = State.DISTRIBUTED_FUNDS_BY_ARBITER;
if (contracts[_contractId].token == weth) {
IWETH(weth).withdraw(customerPayAmount + freelancerPayAmount);
if (customerPayAmount != 0) {
payable(contracts[_contractId].customer).transfer(customerPayAmount);
}
if (freelancerPayAmount != 0) {
payable(contracts[_contractId].freelancer).transfer(freelancerPayAmount);
}
} else {
if (customerPayAmount != 0) {
IERC20(contracts[_contractId].token).safeTransfer(contracts[_contractId].customer, customerPayAmount);
}
if (freelancerPayAmount != 0) {
IERC20(contracts[_contractId].token).safeTransfer(contracts[_contractId].freelancer, freelancerPayAmount);
}
}
serviceFeesAccum[contracts[_contractId].token] += customerFeeAmount + freelancerFeeAmount;
emit DistributedForPartials(_contractId, freelancerFee, customerPayAmount, freelancerPayAmount);
}
function withdrawServiceFee(address token) external onlyServiceFeesRecipient {
require(serviceFeesRecipient != address(0), "Not specified service fee address");
require(serviceFeesAccum[token] > 0, "You have no accumulated commissions");
uint256 amount = serviceFeesAccum[token];
serviceFeesAccum[token] = 0;
if (token == weth) {
IWETH(weth).withdraw(amount);
payable(serviceFeesRecipient).transfer(amount);
} else {
IERC20(token).safeTransfer(serviceFeesRecipient, amount);
}
}
function withdrawServiceFees() external onlyServiceFeesRecipient {
address[] memory addresses = TokenManager(tokenManager).getListTokenAddresses();
for (uint256 i = 0; i < addresses.length; i++) {
if (serviceFeesAccum[addresses[i]] > 0) {
uint256 amount = serviceFeesAccum[addresses[i]];
serviceFeesAccum[addresses[i]] = 0;
if (addresses[i] == weth) {
IWETH(weth).withdraw(amount);
payable(serviceFeesRecipient).transfer(amount);
} else {
IERC20(addresses[i]).safeTransfer(serviceFeesRecipient, amount);
}
}
}
}
function checkAbilityConvertToBase(address fromToken, uint256 amount) public view returns (bool success, uint256 amountInBase) {
if (!convertAvailable) return (false, 0);
if (address(0) == weth) return (false, 1);
if (fromToken == weth) return (false, 2);
(bool found,) = TokenManager(tokenManager).indexOfToken(weth);
if (!found) return (false, 3);
(,,,,address priceContractToUSD, bool isStable) = TokenManager(tokenManager).tokens(fromToken);
if (priceContractToUSD == address(0)) return (false, 4);
(,int256 answerToUSD,,uint256 updatedAtToUSD,) = AggregatorV3Interface(priceContractToUSD).latestRoundData();
if ((updatedAtToUSD + (isStable ? priceOutdateDelayStable : priceOutdateDelay )) < block.timestamp) return (false, 5);
if (answerToUSD <= 0) return (false, 6);
(,,,,address priceContractToBase,) = TokenManager(tokenManager).tokens(weth);
(,int256 answerToBase,,uint256 updatedAtToBase,) = AggregatorV3Interface(priceContractToBase).latestRoundData();
if ((updatedAtToBase + priceOutdateDelay) < block.timestamp) return (false, 7);
if (answerToBase <= 0) return (false, 8);
uint256 amountInUSD = amount * uint(answerToUSD) / (10 ** AggregatorV3Interface(priceContractToUSD).decimals());
amountInBase = amountInUSD * (10 ** 18) / uint(answerToBase);
if (amountInBase > serviceFeesAccum[weth]) return (false, 9);
return (true, amountInBase);
}
function addToServiceFeeAccumBase() external payable onlyServiceFeesRecipient {
IWETH(weth).deposit{value : msg.value}();
serviceFeesAccum[weth] += msg.value;
}
function setPrecision(uint256 _precision) external onlyOwner {
precision = _precision;
}
function setServiceFeesRecipient(address _address) external onlyOwner {
serviceFeesRecipient = _address;
}
function setDisputer(address _address) external onlyOwner {
disputer = _address;
}
function setTokenManager(address _address) external onlyOwner {
tokenManager = _address;
}
function setServiceFees(uint256 _customerFee, uint256 _freelancerFee) external onlyOwner {
customerFee = _customerFee;
freelancerFee = _freelancerFee;
emit ServiceFeesChanged(customerFee, freelancerFee);
}
function setExtraDuration(uint256 _extraDuration) external onlyOwner {
extraDuration = _extraDuration;
}
function setPriceOutdateDelay(uint256 _priceOutdateDelay, uint256 _priceOutdateDelayStable) external onlyOwner {
priceOutdateDelay = _priceOutdateDelay;
priceOutdateDelayStable = _priceOutdateDelayStable;
}
function setConvertAvailable(bool _convertAvailable) external onlyOwner {
convertAvailable = _convertAvailable;
}
function _payInBase(address to, address fromToken, uint256 amount) internal returns (bool) {
(bool success, uint256 amountInBase) = checkAbilityConvertToBase(fromToken, amount);
if (!success) return false;
IWETH(weth).withdraw(amountInBase);
payable(to).transfer(amountInBase);
serviceFeesAccum[weth] -= amountInBase;
serviceFeesAccum[fromToken] += amount;
return true;
}
receive() external payable {
assert(msg.sender == weth);
}
// -------- Getters ----------
function getAccumulatedFees() public view returns (ServiceFeeAccum[] memory _fees) {
uint256 length = TokenManager(tokenManager).getLengthTokenAddresses();
ServiceFeeAccum[] memory fees = new ServiceFeeAccum[](length);
for (uint256 i = 0; i < length; i++) {
address token = TokenManager(tokenManager).tokenAddresses(i);
fees[i].token = token;
fees[i].amount = serviceFeesAccum[token];
}
return fees;
}
function getServiceFees() public view returns (uint256 _customerFee, uint256 _freelancerFee) {
_customerFee = customerFee;
_freelancerFee = freelancerFee;
}
// -------- Modifiers ----------
modifier onlyCreatedState (bytes32 _contractId) {
require(contracts[_contractId].state == State.CREATED, "Contract allowed only created state");
_;
}
modifier onlyBlockedState (bytes32 _contractId) {
require(contracts[_contractId].state == State.BLOCKED, "Contract allowed only blocked state");
_;
}
modifier onlyServiceFeesRecipient () {
require(_msgSender() == serviceFeesRecipient, "Only service fees recipient can call this function");
_;
}
modifier onlyFreelancer (bytes32 _contractId) {
require(_msgSender() == contracts[_contractId].freelancer, "Only freelancer can call this function");
_;
}
modifier onlyCustomer (bytes32 _contractId) {
require(_msgSender() == contracts[_contractId].customer, "Only customer can call this function");
_;
}
modifier onlyTxSender (bytes32 _contractId) {
require(msg.sender == tx.origin, "Only tx sender can call this function");
_;
}
modifier onlyDisputer (bytes32 _contractId) {
require((contracts[_contractId].disputer == address(0) && _msgSender() == disputer) || _msgSender() == contracts[_contractId].disputer, "Only disputer can call this function");
_;
}
}
Ownable.sol 73 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
address private _pendingOwner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view returns (address) {
return _pendingOwner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Throws if called by any account other than the pending owner.
*/
modifier onlyPendingOwner() {
require(pendingOwner() == _msgSender(), "Ownable: caller is not the pending owner");
_;
}
function transferOwnership(address newOwner) external onlyOwner {
_pendingOwner = newOwner;
}
function claimOwnership() external onlyPendingOwner {
_owner = _pendingOwner;
_pendingOwner = address(0);
emit OwnershipTransferred(_owner, _pendingOwner);
}
}
SafeERC20.sol 77 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../interfaces/IERC20.sol";
import "./Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {// Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
IWETH.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IWETH {
function deposit() external payable;
function transfer(address to, uint value) external returns (bool);
function withdraw(uint wad) external;
function balanceOf(address user) external returns (uint);
}
IERC20.sol 77 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @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);
}
AggregatorV3Interface.sol 54 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AggregatorV3Interface {
function decimals()
external
view
returns (
uint8
);
function description()
external
view
returns (
string memory
);
function version()
external
view
returns (
uint256
);
// getRoundData and latestRoundData should both raise "No data present"
// if they do not have data to report, instead of returning unset values
// which could be misinterpreted as actual reported values.
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
);
}
IUniswapV2.sol 110 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC20.sol";
interface IUniRouter {
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata path)
external
view
returns (uint256[] memory amounts);
}
interface IUniswapV2Factory {
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function getPair(IERC20 tokenA, IERC20 tokenB)
external
view
returns (IUniswapV2Exchange pair);
}
interface IUniswapV2Exchange {
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function getReserves()
external
view
returns (
uint112 _reserve0,
uint112 _reserve1,
uint32 _blockTimestampLast
);
function swap(
uint256 amount0Out,
uint256 amount1Out,
address to,
bytes calldata data
) external;
function skim(address to) external;
function sync() external;
function mint(address to) external returns (uint256 liquidity);
function burn(address to)
external
returns (uint256 amount0, uint256 amount1);
function token0() external view returns (address);
function token1() external view returns (address);
function transfer(address to, uint256 value) external returns (bool);
}
ERC20.sol 264 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./interfaces/IERC20.sol";
import "./utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 public decimals;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_, uint8 decimals_) {
_name = name_;
_symbol = symbol_;
decimals = decimals_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function mint(address account, uint256 amount) external virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
}
Read Contract
FEE_PRECISION 0xe63a391f → uint256
checkAbilityConvertToBase 0x23faa95d → bool, uint256
contracts 0xec56a373 → bytes32, address, address, address, address, uint256, uint256, uint256, uint256, uint8
convertAvailable 0x0442839d → bool
customerFee 0x439cc14a → uint256
disputer 0x6ac56103 → address
extraDuration 0x4781ca76 → uint256
freelancerFee 0x5609b22c → uint256
getAccumulatedFees 0x5df45a37 → tuple[]
getServiceFees 0xd5c40421 → uint256, uint256
owner 0x8da5cb5b → address
pendingOwner 0xe30c3978 → address
precision 0xd3b5dc3b → uint256
priceOutdateDelay 0xd17958e3 → uint256
priceOutdateDelayStable 0x2329deb7 → uint256
serviceFeesAccum 0x9f2a5166 → uint256
serviceFeesRecipient 0xeb663661 → address
tokenManager 0x2a709b14 → address
weth 0x3fc8cef3 → address
Write Contract 21 functions
These functions modify contract state and require a wallet transaction to execute.
addToServiceFeeAccumBase 0x031212f0
No parameters
blockContract 0x3cab6dbb
bytes32 _contractId
claimOwnership 0x4e71e0c8
No parameters
createContract 0x538ba7cc
bytes32 _contractId
address _freelancer
address _disputer
address _token
uint256 _amount
uint64 _duration
uint256 _percentToBaseConvert
distributionForPartials 0x9e9d6685
bytes32 _contractId
uint256 _customerAmount
init 0x06552ff3
address _weth
address _tokenManager
address _disputer
address _serviceFeesRecipient
payToFreelancer 0xca699f6d
bytes32 _contractId
refundToCustomerByCustomer 0x6b76aeca
bytes32 _contractId
refundToCustomerByFreelancer 0x1e7a51ac
bytes32 _contractId
refundToCustomerWithFreelancerSignature 0xcb858091
bytes32 _contractId
bytes signature
setConvertAvailable 0xa3a992c6
bool _convertAvailable
setDisputer 0x8ee5074d
address _address
setExtraDuration 0x2c4dbed2
uint256 _extraDuration
setPrecision 0x176f832e
uint256 _precision
setPriceOutdateDelay 0x4da22a73
uint256 _priceOutdateDelay
uint256 _priceOutdateDelayStable
setServiceFees 0xc7d316a9
uint256 _customerFee
uint256 _freelancerFee
setServiceFeesRecipient 0xd220496f
address _address
setTokenManager 0x7cb2b79c
address _address
transferOwnership 0xf2fde38b
address newOwner
withdrawServiceFee 0xe482eef4
address token
withdrawServiceFees 0xd72e481d
No parameters
Token Balances (3)
View Transfers →Recent Transactions
Transaction index is loading. Only unfinalized transactions are shown while the index starts up.